fix
This commit is contained in:
parent
e15ecf3e31
commit
76816dd5d3
@ -141,13 +141,13 @@ namespace CanteenBusinessLogic.BusinessLogics
|
||||
Lunch = lunch,
|
||||
Cooks = new List<CookViewModel>()
|
||||
};
|
||||
var lunchProducts = lunch.LunchProducts.Keys.ToList();
|
||||
foreach (var productId in lunchProducts)
|
||||
var lunchOrders = lunch.LunchOrders.Keys.ToList();
|
||||
foreach (var orderId in lunchOrders)
|
||||
{
|
||||
var product = productStorage.GetElement(new ProductSearchModel { Id = productId });
|
||||
var productCooks = product.ProductCooks.Keys.ToList();
|
||||
var order = orderStorage.GetElement(new OrderSearchModel { Id = orderId });
|
||||
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)
|
||||
{
|
||||
|
@ -1,14 +1,10 @@
|
||||
using CanteenContracts.BindingModels;
|
||||
using CanteenBusinessLogic.MailWorker;
|
||||
using CanteenContracts.BindingModels;
|
||||
using CanteenContracts.BusinessLogicsContracts;
|
||||
using CanteenContracts.SearchModel;
|
||||
using CanteenContracts.StoragesContracts;
|
||||
using CanteenContracts.View;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace CanteenBusinessLogic.BusinessLogics
|
||||
{
|
||||
@ -16,11 +12,13 @@ namespace CanteenBusinessLogic.BusinessLogics
|
||||
{
|
||||
private readonly ILogger _logger;
|
||||
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;
|
||||
_visitorStorage = visitorStorage;
|
||||
_mailWorker = mailWorker;
|
||||
}
|
||||
|
||||
public bool Create(VisitorBindingModel model)
|
||||
@ -97,6 +95,17 @@ namespace CanteenBusinessLogic.BusinessLogics
|
||||
|
||||
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)
|
||||
{
|
||||
if (model == null)
|
||||
|
@ -15,5 +15,6 @@ namespace CanteenContracts.BusinessLogicsContracts
|
||||
VisitorViewModel? ReadElement(VisitorSearchModel model);
|
||||
bool Create(VisitorBindingModel model);
|
||||
bool Update(VisitorBindingModel model);
|
||||
bool SendMail(MailSendInfoBindingModel emailInfo);
|
||||
}
|
||||
}
|
||||
|
@ -11,7 +11,7 @@ namespace CanteenDatabaseImplement
|
||||
{
|
||||
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);
|
||||
}
|
||||
|
@ -72,7 +72,7 @@ namespace CanteenRestApi.Controllers
|
||||
{
|
||||
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
|
||||
{
|
||||
FileName = path,
|
||||
|
@ -12,11 +12,13 @@ namespace CanteenRestApi.Controllers
|
||||
{
|
||||
private readonly ILogger _logger;
|
||||
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;
|
||||
_logic = logic;
|
||||
_report = report;
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
@ -64,5 +66,27 @@ namespace CanteenRestApi.Controllers
|
||||
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 = "Отчет",
|
||||
report = model
|
||||
});
|
||||
APIClient.PostRequest("api/main/SaveCooksToEMAIL", model);
|
||||
Response.Redirect("Index");
|
||||
Response.Redirect("Report");
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user