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="PopPort" value="995" />
<add key="MailLogin" value="labwork7Stroev@gmail.com" />
<add key="MailPassword" value="passlab7" />
<add key="MailPassword" value="ilvf bkyd gali fhus" />
</appSettings>
</configuration>

View File

@ -75,7 +75,12 @@ namespace PlumbingRepairBusinessLogic.BusinessLogics
_logger.LogWarning("Insert operation failed");
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;
}
public bool StatusUpdate(OrderBindingModel model, OrderStatus newStatus)
@ -113,24 +118,12 @@ namespace PlumbingRepairBusinessLogic.BusinessLogics
_logger.LogWarning("Update operation failed");
return false;
}
return true;
}
private bool SendOrderMessage(int clientId, string subject, string text)
Task.Run(() => _mailWorker.MailSendAsync(new MailSendInfoBindingModel
{
var client = _clientLogic.ReadElement(new() { Id = clientId });
if (client == null)
{
return false;
}
_mailWorker.MailSendAsync(new()
{
MailAddress = client.Email,
Subject = subject,
Text = text
});
MailAddress = viewModel.ClientEmail,
Subject = $"Изменение статуса заказа номер {viewModel.Id}",
Text = $"У заказа номер {viewModel.Id} изменен статус на {newStatus}"
}));
return true;
}
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);
[DisplayName("Дата выполнения")]
public DateTime? DateImplement { get; set; }
public string ClientEmail { get; set; } = string.Empty;
}
}

View File

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

View File

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