PIbd-22. Stroev V.M. Lab Work 07 #7

Closed
StroevVladimir wants to merge 4 commits from Lab7 into Lab6
5 changed files with 15 additions and 20 deletions
Showing only changes of commit d66cfeaa98 - Show all commits

View File

@ -6,6 +6,6 @@
<add key="PopHost" value="pop.gmail.com" /> <add key="PopHost" value="pop.gmail.com" />
<add key="PopPort" value="995" /> <add key="PopPort" value="995" />
<add key="MailLogin" value="labwork7Stroev@gmail.com" /> <add key="MailLogin" value="labwork7Stroev@gmail.com" />
<add key="MailPassword" value="passlab7" /> <add key="MailPassword" value="ilvf bkyd gali fhus" />
</appSettings> </appSettings>
</configuration> </configuration>

View File

@ -75,7 +75,12 @@ namespace PlumbingRepairBusinessLogic.BusinessLogics
_logger.LogWarning("Insert operation failed"); _logger.LogWarning("Insert operation failed");
return false; return false;
} }
SendOrderMessage(result.ClientId, $"Ремонт сантехники, Заказ №{result.Id}", $"Заказ №{result.Id} от {result.DateCreate} на сумму {result.Sum:0.00} принят"); Task.Run(() => _mailWorker.MailSendAsync(new MailSendInfoBindingModel
{
MailAddress = result.ClientEmail,
Subject = $"Новый заказ создан. Номер заказа - {result.Id}",
Text = $"Ваш заказ номер {result.Id} на работу {result.WorkName} от {result.DateCreate} на сумму {result.Sum} принят."
}));
return true; return true;
} }
public bool StatusUpdate(OrderBindingModel model, OrderStatus newStatus) public bool StatusUpdate(OrderBindingModel model, OrderStatus newStatus)
@ -113,24 +118,12 @@ namespace PlumbingRepairBusinessLogic.BusinessLogics
_logger.LogWarning("Update operation failed"); _logger.LogWarning("Update operation failed");
return false; return false;
} }
return true; Task.Run(() => _mailWorker.MailSendAsync(new MailSendInfoBindingModel
}
private bool SendOrderMessage(int clientId, string subject, string text)
{
var client = _clientLogic.ReadElement(new() { Id = clientId });
if (client == null)
{ {
return false; MailAddress = viewModel.ClientEmail,
} Subject = $"Изменение статуса заказа номер {viewModel.Id}",
Text = $"У заказа номер {viewModel.Id} изменен статус на {newStatus}"
_mailWorker.MailSendAsync(new() }));
{
MailAddress = client.Email,
Subject = subject,
Text = text
});
return true; return true;
} }
public bool TakeOrderInWork(OrderBindingModel model) public bool TakeOrderInWork(OrderBindingModel model)

View File

@ -33,5 +33,6 @@ namespace PlumbingRepairContracts.ViewModels
public DateTime DateCreate { get; set; } = DateTime.SpecifyKind(DateTime.Now, DateTimeKind.Utc); public DateTime DateCreate { get; set; } = DateTime.SpecifyKind(DateTime.Now, DateTimeKind.Utc);
[DisplayName("Дата выполнения")] [DisplayName("Дата выполнения")]
public DateTime? DateImplement { get; set; } public DateTime? DateImplement { get; set; }
public string ClientEmail { get; set; } = string.Empty;
} }
} }

View File

@ -86,6 +86,7 @@ namespace PlumbingRepairDataBaseImplement.Models
Sum = Sum, Sum = Sum,
Status = Status, Status = Status,
DateCreate = DateCreate, DateCreate = DateCreate,
ClientEmail = Client.Email,
DateImplement = DateImplement DateImplement = DateImplement
}; };
} }

View File

@ -12,5 +12,5 @@
"PopHost": "pop.gmail.com", "PopHost": "pop.gmail.com",
"PopPort": "995", "PopPort": "995",
"MailLogin": "labwork7Stroev@gmail.com", "MailLogin": "labwork7Stroev@gmail.com",
"MailPassword": "passlab7" "MailPassword": "ilvf bkyd gali fhus"
} }