Скиньте на Red bull

This commit is contained in:
Игорь Гордеев 2024-06-01 02:22:36 +04:00
parent d45167de0d
commit 7bb063fa2a
17 changed files with 203 additions and 92 deletions

View File

@ -0,0 +1,62 @@
using ElectronicsShopBusinessLogic.OfficePackage;
using ElectronicsShopBusinessLogic.OfficePackage.HelperModels;
using ElectronicsShopContracts.BindingModels;
using ElectronicsShopContracts.BusinessLogicContracts;
using ElectronicsShopContracts.SearchModels;
using ElectronicsShopContracts.StorageContracts;
using ElectronicsShopContracts.ViewModels;
namespace ElectronicsShopBusinessLogic.BusinessLogic
{
public class ReportClientLogic : IReportClientLogic
{
private readonly IPaymeantStorage _paymeantstorage;
private readonly AbstractSaveToExcelClient _saveToExcel;
private readonly AbstractSaveToWordClient _saveToWord;
public ReportClientLogic(AbstractSaveToExcelClient abstractSaveToExcelClient, AbstractSaveToWordClient abstractSaveToWordClient, IPaymeantStorage paymeantStorage) {
_saveToExcel = abstractSaveToExcelClient;
_saveToWord= abstractSaveToWordClient;
_paymeantstorage= paymeantStorage;
}
public List<ReportPaymeantsViewModel> GetPaymeants(ReportBindingModel model)
{
var paymeants = _paymeantstorage.GetFullList();
var list = new List<ReportPaymeantsViewModel>();
foreach(var paymeant in paymeants)
{
var record = new ReportPaymeantsViewModel
{
PaymeantID=paymeant.ID,
ProductID=paymeant.ProductID,
OrderID=paymeant.OrderID,
PayOption=paymeant.PayOption,
SumPayment=paymeant.SumPayment,
};
list.Add(record);
}
return list;
}
public void SavePaymeantToExcelFile(ReportBindingModel model)
{
_saveToExcel.CreateReport(new ExcelInfoClient
{
FileName = model.ProductName,
Title = "Список оплат",
Paymeants = _paymeantstorage.GetFullList(),
});
}
public void SavePaymeantToWordFile(ReportBindingModel model)
{
_saveToWord.CreateDoc(new WordInfoClient
{
FileName = model.ProductName,
Title = "Список оплат",
ListPaymeant = _paymeantstorage.GetFullList(),
}) ;
}
}
}

View File

@ -0,0 +1,50 @@
using ElectronicsShopBusinessLogic.OfficePackage;
using ElectronicsShopBusinessLogic.OfficePackage.HelperModels;
using ElectronicsShopContracts.BindingModels;
using ElectronicsShopContracts.BusinessLogicContracts;
using ElectronicsShopContracts.StorageContracts;
using ElectronicsShopContracts.ViewModels;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ElectronicsShopBusinessLogic.BusinessLogic
{
public class ReportEmployeeLogic : IReportEmployeeLogic
{
private readonly IProductStorage _productStorage;
private readonly AbstractSaveToWordEmployee _saveToWord;
private readonly AbstractSaveToExcelEmployee _saveToExcel;
public ReportEmployeeLogic(AbstractSaveToExcelEmployee abstractSaveToExcelEmployee, AbstractSaveToWordEmployee abstractSaveToWordEmployee, IProductStorage productStorage) {
_productStorage = productStorage;
_saveToExcel = abstractSaveToExcelEmployee;
_saveToWord = abstractSaveToWordEmployee;
}
public List<ReportProductsViewModel> GetProduct(ReportProductBindingModel model)
{
throw new NotImplementedException();
}
public void SaveProductsToExcelFile(ReportProductBindingModel model)
{
_saveToExcel.CreateReport(new ExcelInfoEmployee
{
FileName = model.FileName,
Title = "Список продуктов",
Products = _productStorage.GetFullList(),
});
}
public void SaveProductsToWordFile(ReportProductBindingModel model)
{
_saveToWord.CreateDoc(new WordInfoEmployee
{
FileName = model.FileName,
Title = "Список продуктов",
ListProduct = _productStorage.GetFullList()
});
}
}
}

View File

@ -31,31 +31,25 @@ namespace ElectronicsShopBusinessLogic.OfficePackage
{ {
ColumnName = "A", ColumnName = "A",
RowIndex = rowIndex, RowIndex = rowIndex,
Text = pc.PaymeantName.ToString(), Text = pc.OrderID.ToString(),
StyleInfo = ExcelStyleInfoType.Text StyleInfo = ExcelStyleInfoType.Text
}); });
rowIndex++; rowIndex++;
foreach (var payment in pc.PaymeantsList)
{
InsertCellInWorksheet(new ExcelCellParameters InsertCellInWorksheet(new ExcelCellParameters
{ {
ColumnName = "B", ColumnName = "B",
RowIndex = rowIndex, RowIndex = rowIndex,
Text = payment.PayOption.ToString(), Text = pc.PayOption.ToString(),
StyleInfo = ExcelStyleInfoType.Text StyleInfo = ExcelStyleInfoType.Text
}); });
InsertCellInWorksheet(new ExcelCellParameters InsertCellInWorksheet(new ExcelCellParameters
{ {
ColumnName = "C", ColumnName = "C",
RowIndex = rowIndex, RowIndex = rowIndex,
Text = payment.SumPayment.ToString(), Text = pc.SumPayment.ToString(),
StyleInfo = ExcelStyleInfoType.TextWithBroder StyleInfo = ExcelStyleInfoType.TextWithBroder
}); });
//Не хорошо, что доступны ID а не название продукта, в идеале пофиксить надо
//Это AbstractSaveToExcelClient
rowIndex++;
}
rowIndex++; rowIndex++;
} }

View File

@ -36,13 +36,11 @@ namespace ElectronicsShopBusinessLogic.OfficePackage
}); });
rowIndex++; rowIndex++;
foreach (var product in pc.Products)
{
InsertCellInWorksheet(new ExcelCellParameters InsertCellInWorksheet(new ExcelCellParameters
{ {
ColumnName = "B", ColumnName = "B",
RowIndex = rowIndex, RowIndex = rowIndex,
Text = product.ProductName.ToString(), Text = pc.ProductName.ToString(),
StyleInfo = ExcelStyleInfoType.TextWithBroder StyleInfo = ExcelStyleInfoType.TextWithBroder
}); });
@ -50,16 +48,13 @@ namespace ElectronicsShopBusinessLogic.OfficePackage
{ {
ColumnName = "C", ColumnName = "C",
RowIndex = rowIndex, RowIndex = rowIndex,
Text = product.Price.ToString(), Text = pc.Price.ToString(),
StyleInfo = ExcelStyleInfoType.TextWithBroder StyleInfo = ExcelStyleInfoType.TextWithBroder
}); });
rowIndex++; rowIndex++;
} }
rowIndex++;
}
SaveExcel(info); SaveExcel(info);
} }

View File

@ -29,7 +29,7 @@ namespace ElectronicsShopBusinessLogic.OfficePackage
CreateParagraph(new WordParagraph CreateParagraph(new WordParagraph
{ {
Texts = new List<(string, WordTextProperties)> Texts = new List<(string, WordTextProperties)>
{ (pre.PaymeantName, new WordTextProperties { Size = "24", Bold=true})}, { (pre.OrderID.ToString(), new WordTextProperties { Size = "24", Bold=true})},
TextProperties = new WordTextProperties TextProperties = new WordTextProperties
{ {
Size = "24", Size = "24",
@ -37,21 +37,16 @@ namespace ElectronicsShopBusinessLogic.OfficePackage
} }
}); });
foreach (var route in pre.PaymeantsList)
{
CreateParagraph(new WordParagraph CreateParagraph(new WordParagraph
{ {
Texts = new List<(string, WordTextProperties)> Texts = new List<(string, WordTextProperties)>
{ (route.PayOption.ToString(), new WordTextProperties { Size = "20", Bold=false})}, { (pre.PayOption.ToString(), new WordTextProperties { Size = "20", Bold=false})},
TextProperties = new WordTextProperties TextProperties = new WordTextProperties
{ {
Size = "24", Size = "24",
JustificationType = WordJustificationType.Both JustificationType = WordJustificationType.Both
} }
}); });
//Вот тут явно этого будет не хватать, но пока пусть будет только статуст
//Это AbstractSaveToWordClient
}
} }
SaveWord(info); SaveWord(info);

View File

@ -37,21 +37,16 @@ namespace ElectronicsShopBusinessLogic.OfficePackage
} }
}); });
foreach (var pre in product.Products)
{
CreateParagraph(new WordParagraph CreateParagraph(new WordParagraph
{ {
Texts = new List<(string, WordTextProperties)> Texts = new List<(string, WordTextProperties)>
{ (pre.ProductName, new WordTextProperties { Size = "20", Bold=false})}, { (product.ProductName, new WordTextProperties { Size = "20", Bold=false})},
TextProperties = new WordTextProperties TextProperties = new WordTextProperties
{ {
Size = "24", Size = "24",
JustificationType = WordJustificationType.Both JustificationType = WordJustificationType.Both
} }
}); });
//Добавить ещё поля кроме названия продукта
//Это AbstractSaveToWordEmployee
}
} }
SaveWord(info); SaveWord(info);

View File

@ -8,6 +8,6 @@ namespace ElectronicsShopBusinessLogic.OfficePackage.HelperModels
public string Title { get; set; } = string.Empty; public string Title { get; set; } = string.Empty;
public List<ReportPaymeantsViewModel> Paymeants { get; set; } = new(); public List<PaymeantViewModel> Paymeants { get; set; } = new();
} }
} }

View File

@ -8,6 +8,6 @@ namespace ElectronicsShopBusinessLogic.OfficePackage.HelperModels
public string Title { get; set; } = string.Empty; public string Title { get; set; } = string.Empty;
public List<ReportProductsViewModel> Products { get; set; } = new(); public List<ProductViewModel> Products { get; set; } = new();
} }
} }

View File

@ -9,6 +9,6 @@ namespace ElectronicsShopBusinessLogic.OfficePackage.HelperModels
public string Title { get; set; } = string.Empty; public string Title { get; set; } = string.Empty;
public List<ReportPaymeantsViewModel> ListPaymeant { get; set; } = new(); public List<PaymeantViewModel> ListPaymeant { get; set; } = new();
} }
} }

View File

@ -9,6 +9,6 @@ namespace ElectronicsShopBusinessLogic.OfficePackage.HelperModels
public string Title { get; set; } = string.Empty; public string Title { get; set; } = string.Empty;
public List<ReportProductsViewModel> ListProduct { get; set; } = new(); public List<ProductViewModel> ListProduct { get; set; } = new();
} }
} }

View File

@ -10,8 +10,8 @@ namespace ElectronicsShopContracts.BusinessLogicContracts
{ {
public interface IReportClientLogic public interface IReportClientLogic
{ {
List<ReportPaymeantsViewModel> GetPaymeants(ReportPaymeantBindingModel model); List<ReportPaymeantsViewModel> GetPaymeants(ReportBindingModel model);
void SavePreservesToWordFile(ReportPaymeantBindingModel model); void SavePaymeantToWordFile(ReportBindingModel model);
void SavePreservesToExcelFile(ReportPaymeantBindingModel model); void SavePaymeantToExcelFile(ReportBindingModel model);
} }
} }

View File

@ -10,8 +10,8 @@ namespace ElectronicsShopContracts.BusinessLogicContracts
{ {
public interface IReportEmployeeLogic public interface IReportEmployeeLogic
{ {
List<ReportProductsViewModel> GetRoute(ReportProductBindingModel model); List<ReportProductsViewModel> GetProduct(ReportProductBindingModel model);
void SaveRoutesToWordFile(ReportProductBindingModel model); void SaveProductsToWordFile(ReportProductBindingModel model);
void SaveRoutesToExcelFile(ReportProductBindingModel model); void SaveProductsToExcelFile(ReportProductBindingModel model);
} }
} }

View File

@ -1,4 +1,5 @@
using System; using ElectronicsShopDataModels.Enums;
using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
@ -8,7 +9,12 @@ namespace ElectronicsShopContracts.ViewModels
{ {
public class ReportPaymeantsViewModel public class ReportPaymeantsViewModel
{ {
public string PaymeantName { get; set; } = string.Empty; public int PaymeantID { get; set; }
public List<PaymeantViewModel> PaymeantsList { get; set; } = new();
public int ProductID { get; set; }
public int OrderID { get; set; }
public double SumPayment { get; set; }
public PaymeantOption PayOption { get; set; } = PaymeantOption.Неоплачено;
} }
} }

View File

@ -12,7 +12,7 @@ namespace ElectronicsShopDataBaseImplement
optionsBuilder) optionsBuilder)
{ {
if (optionsBuilder.IsConfigured == false) { if (optionsBuilder.IsConfigured == false) {
optionsBuilder.UseSqlServer(@"Data Source=DESKTOP-O0N00SH\SQLEXPRESS;Initial Catalog=ElectronicsShopDatabase;Integrated Security=True;MultipleActiveResultSets=True;;TrustServerCertificate=True"); optionsBuilder.UseSqlServer(@"Data Source=DESKTOP-E2VPEN3\SQLEXPRESS;Initial Catalog=ElectronicsShopDatabase;Integrated Security=True;MultipleActiveResultSets=True;;TrustServerCertificate=True");
} }
base.OnConfiguring(optionsBuilder); base.OnConfiguring(optionsBuilder);
} }

View File

@ -187,5 +187,17 @@ namespace ElectronicsShopUserApp.Controllers {
var _product = APIClient.GetRequset<ProductViewModel>($"api/main/getproduct?_productid={product}"); var _product = APIClient.GetRequset<ProductViewModel>($"api/main/getproduct?_productid={product}");
return count * (_product?.Price ?? 1); return count * (_product?.Price ?? 1);
} }
[HttpGet]
public IActionResult Report()
{
//ViewBag.Reports = APIClient.GetRequset<List<ProductViewModel>>($"api/main/getproducts"); íàïèñàòü íîðìàëüíûå äàííûå îá îò÷¸òàõ
return View();
}
[HttpGet]
public IActionResult Message()
{
//ViewBag.Reports = APIClient.GetRequset<List<ProductViewModel>>($"api/main/getproducts"); Ïèñåì òàê æå ïîêà íåìà
return View();
}
} }
} }

View File

@ -6,8 +6,7 @@
} }
<div class="text-center"> <div class="text-center">
<h1 class="display-4">Отчёты</h1> <h1 class="display-4">Письма</h1>
<a asp-action="CreateProduct">Создать товар</a>
</div> </div>
<div class="text-center"> <div class="text-center">
@{ @{

View File

@ -35,7 +35,10 @@
<a class="nav-link text-dark" asp-area="" asp-controller="Home" asp-action="Orders">Корзины</a> <a class="nav-link text-dark" asp-area="" asp-controller="Home" asp-action="Orders">Корзины</a>
</li> </li>
<li class="nav-item"> <li class="nav-item">
<a class="nav-link text-dark" asp-area="" asp-controller="Home" asp-action="Message">Отчёты</a> <a class="nav-link text-dark" asp-area="" asp-controller="Home" asp-action="Report">Отчёты</a>
</li>
<li class="nav-item">
<a class="nav-link text-dark" asp-area="" asp-controller="Home" asp-action="Message">Письма</a>
</li> </li>
</ul> </ul>
</div> </div>