fix
This commit is contained in:
parent
e15ecf3e31
commit
76816dd5d3
@ -141,13 +141,13 @@ namespace CanteenBusinessLogic.BusinessLogics
|
|||||||
Lunch = lunch,
|
Lunch = lunch,
|
||||||
Cooks = new List<CookViewModel>()
|
Cooks = new List<CookViewModel>()
|
||||||
};
|
};
|
||||||
var lunchProducts = lunch.LunchProducts.Keys.ToList();
|
var lunchOrders = lunch.LunchOrders.Keys.ToList();
|
||||||
foreach (var productId in lunchProducts)
|
foreach (var orderId in lunchOrders)
|
||||||
{
|
{
|
||||||
var product = productStorage.GetElement(new ProductSearchModel { Id = productId });
|
var order = orderStorage.GetElement(new OrderSearchModel { Id = orderId });
|
||||||
var productCooks = product.ProductCooks.Keys.ToList();
|
var orderCooks = order.OrderCooks.Keys.ToList();
|
||||||
|
|
||||||
foreach (var cookId in productCooks)
|
foreach (var cookId in orderCooks)
|
||||||
{
|
{
|
||||||
if (record.Cooks.Where(cook => cook.Id == cookId).ToList().Count == 0)
|
if (record.Cooks.Where(cook => cook.Id == cookId).ToList().Count == 0)
|
||||||
{
|
{
|
||||||
|
@ -1,14 +1,10 @@
|
|||||||
using CanteenContracts.BindingModels;
|
using CanteenBusinessLogic.MailWorker;
|
||||||
|
using CanteenContracts.BindingModels;
|
||||||
using CanteenContracts.BusinessLogicsContracts;
|
using CanteenContracts.BusinessLogicsContracts;
|
||||||
using CanteenContracts.SearchModel;
|
using CanteenContracts.SearchModel;
|
||||||
using CanteenContracts.StoragesContracts;
|
using CanteenContracts.StoragesContracts;
|
||||||
using CanteenContracts.View;
|
using CanteenContracts.View;
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace CanteenBusinessLogic.BusinessLogics
|
namespace CanteenBusinessLogic.BusinessLogics
|
||||||
{
|
{
|
||||||
@ -16,11 +12,13 @@ namespace CanteenBusinessLogic.BusinessLogics
|
|||||||
{
|
{
|
||||||
private readonly ILogger _logger;
|
private readonly ILogger _logger;
|
||||||
private readonly IVisitorStorage _visitorStorage;
|
private readonly IVisitorStorage _visitorStorage;
|
||||||
|
private readonly AbstractMailWorker _mailWorker;
|
||||||
|
|
||||||
public VisitorLogic(ILogger<VisitorLogic> logger, IVisitorStorage visitorStorage)
|
public VisitorLogic(ILogger<VisitorLogic> logger, IVisitorStorage visitorStorage, AbstractMailWorker mailWorker)
|
||||||
{
|
{
|
||||||
_logger = logger;
|
_logger = logger;
|
||||||
_visitorStorage = visitorStorage;
|
_visitorStorage = visitorStorage;
|
||||||
|
_mailWorker = mailWorker;
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool Create(VisitorBindingModel model)
|
public bool Create(VisitorBindingModel model)
|
||||||
@ -97,6 +95,17 @@ namespace CanteenBusinessLogic.BusinessLogics
|
|||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
public bool SendMail(MailSendInfoBindingModel emailInfo)
|
||||||
|
{
|
||||||
|
_mailWorker.MailSendAsync(new()
|
||||||
|
{
|
||||||
|
MailAddress = emailInfo.MailAddress,
|
||||||
|
Subject = emailInfo.Subject,
|
||||||
|
Path = emailInfo.Path,
|
||||||
|
});
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
private void CheckModel(VisitorBindingModel model, bool withParams = true)
|
private void CheckModel(VisitorBindingModel model, bool withParams = true)
|
||||||
{
|
{
|
||||||
if (model == null)
|
if (model == null)
|
||||||
|
@ -15,5 +15,6 @@ namespace CanteenContracts.BusinessLogicsContracts
|
|||||||
VisitorViewModel? ReadElement(VisitorSearchModel model);
|
VisitorViewModel? ReadElement(VisitorSearchModel model);
|
||||||
bool Create(VisitorBindingModel model);
|
bool Create(VisitorBindingModel model);
|
||||||
bool Update(VisitorBindingModel model);
|
bool Update(VisitorBindingModel model);
|
||||||
|
bool SendMail(MailSendInfoBindingModel emailInfo);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -11,7 +11,7 @@ namespace CanteenDatabaseImplement
|
|||||||
{
|
{
|
||||||
if (optionsBuilder.IsConfigured == false)
|
if (optionsBuilder.IsConfigured == false)
|
||||||
{
|
{
|
||||||
optionsBuilder.UseSqlServer(@"Data Source=MOVAVI-DESKTOP\SQLEXPRESS;Initial Catalog=CanteenDataBase;Integrated Security=True;MultipleActiveResultSets=True;;TrustServerCertificate=True");
|
optionsBuilder.UseSqlServer(@"Data Source=DESKTOP-A68O3K0;Initial Catalog=CanteenDataBase;Integrated Security=True;MultipleActiveResultSets=True;;TrustServerCertificate=True");
|
||||||
}
|
}
|
||||||
base.OnConfiguring(optionsBuilder);
|
base.OnConfiguring(optionsBuilder);
|
||||||
}
|
}
|
||||||
|
@ -72,7 +72,7 @@ namespace CanteenRestApi.Controllers
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
string path = $"C:\\PdfReports\\{DateTime.Now.ToString("HH.mm.ss_dd.MM.yyyy")}111111.pdf";
|
string path = $"C:\\PdfReports\\{DateTime.Now.ToString("HH.mm.ss_dd.MM.yyyy")}.pdf";
|
||||||
_report.saveCooksToPdfFile(new ReportBindingModel
|
_report.saveCooksToPdfFile(new ReportBindingModel
|
||||||
{
|
{
|
||||||
FileName = path,
|
FileName = path,
|
||||||
|
@ -12,11 +12,13 @@ namespace CanteenRestApi.Controllers
|
|||||||
{
|
{
|
||||||
private readonly ILogger _logger;
|
private readonly ILogger _logger;
|
||||||
private readonly IVisitorLogic _logic;
|
private readonly IVisitorLogic _logic;
|
||||||
|
private readonly IReportLogic _report;
|
||||||
|
|
||||||
public VisitorController(IVisitorLogic logic, ILogger<VisitorController> logger)
|
public VisitorController(IVisitorLogic logic, IReportLogic report, ILogger<VisitorController> logger)
|
||||||
{
|
{
|
||||||
_logger = logger;
|
_logger = logger;
|
||||||
_logic = logic;
|
_logic = logic;
|
||||||
|
_report = report;
|
||||||
}
|
}
|
||||||
|
|
||||||
[HttpGet]
|
[HttpGet]
|
||||||
@ -64,5 +66,27 @@ namespace CanteenRestApi.Controllers
|
|||||||
throw;
|
throw;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
[HttpPost]
|
||||||
|
public void SendEmail(MailSendInfoBindingModel emailInfo)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
string path = $"C:\\PdfReports\\{DateTime.Now.ToString("HH.mm.ss_dd.MM.yyyy")}.pdf";
|
||||||
|
_report.saveLunchesToPdfFile(new ReportBindingModel
|
||||||
|
{
|
||||||
|
FileName = path,
|
||||||
|
UserId = emailInfo.report.UserId,
|
||||||
|
DateBefore = emailInfo.report.DateBefore,
|
||||||
|
DateAfter = emailInfo.report.DateAfter
|
||||||
|
});
|
||||||
|
emailInfo.Path = path;
|
||||||
|
_logic.SendMail(emailInfo);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_logger.LogError(ex, "Error during updating");
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -574,8 +574,7 @@ namespace CanteenVisitorApp.Controllers
|
|||||||
Subject = "Отчет",
|
Subject = "Отчет",
|
||||||
report = model
|
report = model
|
||||||
});
|
});
|
||||||
APIClient.PostRequest("api/main/SaveCooksToEMAIL", model);
|
Response.Redirect("Report");
|
||||||
Response.Redirect("Index");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user