Complete lab 7
This commit is contained in:
parent
542742e2ce
commit
2c4cb0dbb2
@ -31,6 +31,7 @@ Global
|
||||
{DB81A759-B157-477C-9281-EE358968519D}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{DB81A759-B157-477C-9281-EE358968519D}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{DB81A759-B157-477C-9281-EE358968519D}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{DB81A759-B157-477C-9281-EE358968519D}.Debug|Any CPU.Deploy.0 = Debug|Any CPU
|
||||
{CFB2D9F9-EA44-4E61-B6BE-5A2AA3C6AF07}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{CFB2D9F9-EA44-4E61-B6BE-5A2AA3C6AF07}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{CFB2D9F9-EA44-4E61-B6BE-5A2AA3C6AF07}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
@ -59,10 +60,12 @@ Global
|
||||
{0ADB6C71-701C-43A7-869C-A92D7C36C4EC}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{0ADB6C71-701C-43A7-869C-A92D7C36C4EC}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{0ADB6C71-701C-43A7-869C-A92D7C36C4EC}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{0ADB6C71-701C-43A7-869C-A92D7C36C4EC}.Debug|Any CPU.Deploy.0 = Debug|Any CPU
|
||||
{BF58D50B-0408-4124-8CD3-1D5DFEE83104}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{BF58D50B-0408-4124-8CD3-1D5DFEE83104}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{BF58D50B-0408-4124-8CD3-1D5DFEE83104}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{BF58D50B-0408-4124-8CD3-1D5DFEE83104}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{BF58D50B-0408-4124-8CD3-1D5DFEE83104}.Debug|Any CPU.Deploy.0 = Debug|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
|
@ -5,7 +5,7 @@
|
||||
<add key="SmtpClientPort" value="587" />
|
||||
<add key="PopHost" value="pop.gmail.com" />
|
||||
<add key="PopPort" value="995" />
|
||||
<add key="MailLogin" value="labwork15kafis@gmail.com" />
|
||||
<add key="MailPassword" value="passlab15" />
|
||||
<add key="MailLogin" value="sushibarulyanosk7@gmail.com" />
|
||||
<add key="MailPassword" value="qwzj uqlx uukp bpmc" />
|
||||
</appSettings>
|
||||
</configuration>
|
@ -67,6 +67,7 @@ namespace SushiBar
|
||||
services.AddTransient<ISushiStorage, SushiStorage>();
|
||||
services.AddTransient<IClientStorage, ClientStorage>();
|
||||
services.AddTransient<IImplementerStorage, ImplementerStorage>();
|
||||
services.AddTransient<IMessageInfoStorage, MessageStorage>();
|
||||
|
||||
services.AddTransient<IComponentLogic, ComponentLogic>();
|
||||
services.AddTransient<IOrderLogic, OrderLogic>();
|
||||
|
@ -92,7 +92,7 @@ public class ClientLogic : IClientLogic
|
||||
throw new ArgumentException("Invalid format for email", nameof(model.Email));
|
||||
|
||||
if (!Regex.IsMatch(model.Password, @"^^((\w+\d+\W+)|(\w+\W+\d+)|(\d+\w+\W+)|(\d+\W+\w+)|(\W+\w+\d+)|(\W+\d+\w+))[\w\d\W]*$", RegexOptions.IgnoreCase))
|
||||
throw new ArgumentException("Invalid format for email", nameof(model.Password));
|
||||
throw new ArgumentException("Invalid format for password", nameof(model.Password));
|
||||
|
||||
_logger.LogInformation("Client .FIO:{ClientFio} .EMAIL:{Email} .Password:{Password} .Id:{Id}", model.ClientFio, model.Email, model.Password, model.Id);
|
||||
var client = _clientStorage.GetElement(new ClientSearchModel
|
||||
|
@ -24,7 +24,6 @@ public class MessageInfoLogic : IMessageInfoLogic
|
||||
_logger.LogWarning("Insert operation failed");
|
||||
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
public List<MessageInfoViewModel>? ReadList(MessageInfoSearchModel? model)
|
||||
|
@ -57,11 +57,17 @@ namespace SushiBarBusinessLogic.BusinessLogics
|
||||
|
||||
model.Status = OrderStatus.Accepted;
|
||||
|
||||
if (_orderStorage.Insert(model) != null) return true;
|
||||
var result = _orderStorage.Insert(model);
|
||||
if (result == null)
|
||||
{
|
||||
_logger.LogWarning("Insert operation failed");
|
||||
return false;
|
||||
}
|
||||
|
||||
SendOrderMessage(result.ClientId, $"Sushi Bar, Order №{result.Id}", $"Order №{result.Id} date {result.DateCreate} with sum on {result.Sum:0.00} accepted");
|
||||
return true;
|
||||
}
|
||||
|
||||
public bool DeliveryOrder(OrderBindingModel model)
|
||||
{
|
||||
return UpdateStatus(model, OrderStatus.Ready);
|
||||
|
@ -1,6 +1,7 @@
|
||||
using Microsoft.Extensions.Logging;
|
||||
using SushiBarContracts.BindingModels;
|
||||
using SushiBarContracts.BusinessLogicsContracts;
|
||||
using SushiBarContracts.SearchModels;
|
||||
|
||||
namespace SushiBarBusinessLogic.MailWorker;
|
||||
|
||||
@ -14,12 +15,15 @@ public abstract class AbstractMailWorker
|
||||
protected int _popPort;
|
||||
private readonly IMessageInfoLogic _messageInfoLogic;
|
||||
private readonly ILogger _logger;
|
||||
private readonly IClientLogic _clientLogic;
|
||||
|
||||
public AbstractMailWorker(ILogger<AbstractMailWorker> logger,
|
||||
IMessageInfoLogic messageInfoLogic)
|
||||
IMessageInfoLogic messageInfoLogic,
|
||||
IClientLogic clientLogic)
|
||||
{
|
||||
_logger = logger;
|
||||
_messageInfoLogic = messageInfoLogic;
|
||||
_clientLogic = clientLogic;
|
||||
}
|
||||
public void MailConfig(MailConfigBindingModel config)
|
||||
{
|
||||
@ -72,6 +76,7 @@ public abstract class AbstractMailWorker
|
||||
_logger.LogDebug("Check Mail: {Count} new mails", list.Count);
|
||||
foreach (var mail in list)
|
||||
{
|
||||
mail.ClientId = _clientLogic.ReadElement(new ClientSearchModel { Email = mail.SenderName })?.Id;
|
||||
_messageInfoLogic.Create(mail);
|
||||
}
|
||||
}
|
||||
|
@ -13,8 +13,8 @@ namespace SushiBarBusinessLogic.MailWorker;
|
||||
public class MailKitWorker : AbstractMailWorker
|
||||
{
|
||||
public MailKitWorker(ILogger<MailKitWorker> logger,
|
||||
IMessageInfoLogic messageInfoLogic)
|
||||
: base(logger, messageInfoLogic) {}
|
||||
IMessageInfoLogic messageInfoLogic, IClientLogic clientLogic)
|
||||
: base(logger, messageInfoLogic, clientLogic) {}
|
||||
|
||||
protected override async Task SendMailAsync(MailSendInfoBindingModel info)
|
||||
{
|
||||
|
@ -54,6 +54,13 @@ public class ClientStorage : IClientStorage
|
||||
?.GetViewModel;
|
||||
}
|
||||
|
||||
if (!string.IsNullOrEmpty(model.Email))
|
||||
{
|
||||
return context.Clients
|
||||
.FirstOrDefault(x => x.Email == model.Email)
|
||||
?.GetViewModel;
|
||||
}
|
||||
|
||||
return context.Clients
|
||||
.FirstOrDefault(x => x.Email == model.Email && x.Password == model.Password)
|
||||
?.GetViewModel;
|
||||
|
Loading…
Reference in New Issue
Block a user