Скиньте на Red bull
This commit is contained in:
parent
d45167de0d
commit
7bb063fa2a
@ -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(),
|
||||
}) ;
|
||||
}
|
||||
}
|
||||
}
|
@ -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()
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
@ -31,31 +31,25 @@ namespace ElectronicsShopBusinessLogic.OfficePackage
|
||||
{
|
||||
ColumnName = "A",
|
||||
RowIndex = rowIndex,
|
||||
Text = pc.PaymeantName.ToString(),
|
||||
Text = pc.OrderID.ToString(),
|
||||
StyleInfo = ExcelStyleInfoType.Text
|
||||
});
|
||||
rowIndex++;
|
||||
|
||||
foreach (var payment in pc.PaymeantsList)
|
||||
{
|
||||
InsertCellInWorksheet(new ExcelCellParameters
|
||||
{
|
||||
ColumnName = "B",
|
||||
RowIndex = rowIndex,
|
||||
Text = payment.PayOption.ToString(),
|
||||
Text = pc.PayOption.ToString(),
|
||||
StyleInfo = ExcelStyleInfoType.Text
|
||||
});
|
||||
InsertCellInWorksheet(new ExcelCellParameters
|
||||
{
|
||||
ColumnName = "C",
|
||||
RowIndex = rowIndex,
|
||||
Text = payment.SumPayment.ToString(),
|
||||
Text = pc.SumPayment.ToString(),
|
||||
StyleInfo = ExcelStyleInfoType.TextWithBroder
|
||||
});
|
||||
//Не хорошо, что доступны ID а не название продукта, в идеале пофиксить надо
|
||||
//Это AbstractSaveToExcelClient
|
||||
rowIndex++;
|
||||
}
|
||||
|
||||
rowIndex++;
|
||||
}
|
||||
|
@ -36,13 +36,11 @@ namespace ElectronicsShopBusinessLogic.OfficePackage
|
||||
});
|
||||
rowIndex++;
|
||||
|
||||
foreach (var product in pc.Products)
|
||||
{
|
||||
InsertCellInWorksheet(new ExcelCellParameters
|
||||
{
|
||||
ColumnName = "B",
|
||||
RowIndex = rowIndex,
|
||||
Text = product.ProductName.ToString(),
|
||||
Text = pc.ProductName.ToString(),
|
||||
StyleInfo = ExcelStyleInfoType.TextWithBroder
|
||||
});
|
||||
|
||||
@ -50,16 +48,13 @@ namespace ElectronicsShopBusinessLogic.OfficePackage
|
||||
{
|
||||
ColumnName = "C",
|
||||
RowIndex = rowIndex,
|
||||
Text = product.Price.ToString(),
|
||||
Text = pc.Price.ToString(),
|
||||
StyleInfo = ExcelStyleInfoType.TextWithBroder
|
||||
});
|
||||
|
||||
rowIndex++;
|
||||
}
|
||||
|
||||
rowIndex++;
|
||||
}
|
||||
|
||||
SaveExcel(info);
|
||||
}
|
||||
|
||||
|
@ -29,7 +29,7 @@ namespace ElectronicsShopBusinessLogic.OfficePackage
|
||||
CreateParagraph(new WordParagraph
|
||||
{
|
||||
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
|
||||
{
|
||||
Size = "24",
|
||||
@ -37,21 +37,16 @@ namespace ElectronicsShopBusinessLogic.OfficePackage
|
||||
}
|
||||
});
|
||||
|
||||
foreach (var route in pre.PaymeantsList)
|
||||
{
|
||||
CreateParagraph(new WordParagraph
|
||||
{
|
||||
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
|
||||
{
|
||||
Size = "24",
|
||||
JustificationType = WordJustificationType.Both
|
||||
}
|
||||
});
|
||||
//Вот тут явно этого будет не хватать, но пока пусть будет только статуст
|
||||
//Это AbstractSaveToWordClient
|
||||
}
|
||||
}
|
||||
|
||||
SaveWord(info);
|
||||
|
@ -37,21 +37,16 @@ namespace ElectronicsShopBusinessLogic.OfficePackage
|
||||
}
|
||||
});
|
||||
|
||||
foreach (var pre in product.Products)
|
||||
{
|
||||
CreateParagraph(new WordParagraph
|
||||
{
|
||||
Texts = new List<(string, WordTextProperties)>
|
||||
{ (pre.ProductName, new WordTextProperties { Size = "20", Bold=false})},
|
||||
{ (product.ProductName, new WordTextProperties { Size = "20", Bold=false})},
|
||||
TextProperties = new WordTextProperties
|
||||
{
|
||||
Size = "24",
|
||||
JustificationType = WordJustificationType.Both
|
||||
}
|
||||
});
|
||||
//Добавить ещё поля кроме названия продукта
|
||||
//Это AbstractSaveToWordEmployee
|
||||
}
|
||||
}
|
||||
|
||||
SaveWord(info);
|
||||
|
@ -8,6 +8,6 @@ namespace ElectronicsShopBusinessLogic.OfficePackage.HelperModels
|
||||
|
||||
public string Title { get; set; } = string.Empty;
|
||||
|
||||
public List<ReportPaymeantsViewModel> Paymeants { get; set; } = new();
|
||||
public List<PaymeantViewModel> Paymeants { get; set; } = new();
|
||||
}
|
||||
}
|
||||
|
@ -8,6 +8,6 @@ namespace ElectronicsShopBusinessLogic.OfficePackage.HelperModels
|
||||
|
||||
public string Title { get; set; } = string.Empty;
|
||||
|
||||
public List<ReportProductsViewModel> Products { get; set; } = new();
|
||||
public List<ProductViewModel> Products { get; set; } = new();
|
||||
}
|
||||
}
|
||||
|
@ -9,6 +9,6 @@ namespace ElectronicsShopBusinessLogic.OfficePackage.HelperModels
|
||||
|
||||
public string Title { get; set; } = string.Empty;
|
||||
|
||||
public List<ReportPaymeantsViewModel> ListPaymeant { get; set; } = new();
|
||||
public List<PaymeantViewModel> ListPaymeant { get; set; } = new();
|
||||
}
|
||||
}
|
||||
|
@ -9,6 +9,6 @@ namespace ElectronicsShopBusinessLogic.OfficePackage.HelperModels
|
||||
|
||||
public string Title { get; set; } = string.Empty;
|
||||
|
||||
public List<ReportProductsViewModel> ListProduct { get; set; } = new();
|
||||
public List<ProductViewModel> ListProduct { get; set; } = new();
|
||||
}
|
||||
}
|
||||
|
@ -10,8 +10,8 @@ namespace ElectronicsShopContracts.BusinessLogicContracts
|
||||
{
|
||||
public interface IReportClientLogic
|
||||
{
|
||||
List<ReportPaymeantsViewModel> GetPaymeants(ReportPaymeantBindingModel model);
|
||||
void SavePreservesToWordFile(ReportPaymeantBindingModel model);
|
||||
void SavePreservesToExcelFile(ReportPaymeantBindingModel model);
|
||||
List<ReportPaymeantsViewModel> GetPaymeants(ReportBindingModel model);
|
||||
void SavePaymeantToWordFile(ReportBindingModel model);
|
||||
void SavePaymeantToExcelFile(ReportBindingModel model);
|
||||
}
|
||||
}
|
||||
|
@ -10,8 +10,8 @@ namespace ElectronicsShopContracts.BusinessLogicContracts
|
||||
{
|
||||
public interface IReportEmployeeLogic
|
||||
{
|
||||
List<ReportProductsViewModel> GetRoute(ReportProductBindingModel model);
|
||||
void SaveRoutesToWordFile(ReportProductBindingModel model);
|
||||
void SaveRoutesToExcelFile(ReportProductBindingModel model);
|
||||
List<ReportProductsViewModel> GetProduct(ReportProductBindingModel model);
|
||||
void SaveProductsToWordFile(ReportProductBindingModel model);
|
||||
void SaveProductsToExcelFile(ReportProductBindingModel model);
|
||||
}
|
||||
}
|
||||
|
@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using ElectronicsShopDataModels.Enums;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
@ -8,7 +9,12 @@ namespace ElectronicsShopContracts.ViewModels
|
||||
{
|
||||
public class ReportPaymeantsViewModel
|
||||
{
|
||||
public string PaymeantName { get; set; } = string.Empty;
|
||||
public List<PaymeantViewModel> PaymeantsList { get; set; } = new();
|
||||
public int PaymeantID { get; set; }
|
||||
|
||||
public int ProductID { get; set; }
|
||||
|
||||
public int OrderID { get; set; }
|
||||
public double SumPayment { get; set; }
|
||||
public PaymeantOption PayOption { get; set; } = PaymeantOption.Неоплачено;
|
||||
}
|
||||
}
|
||||
|
@ -12,7 +12,7 @@ namespace ElectronicsShopDataBaseImplement
|
||||
optionsBuilder)
|
||||
{
|
||||
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);
|
||||
}
|
||||
|
@ -187,5 +187,17 @@ namespace ElectronicsShopUserApp.Controllers {
|
||||
var _product = APIClient.GetRequset<ProductViewModel>($"api/main/getproduct?_productid={product}");
|
||||
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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -6,8 +6,7 @@
|
||||
}
|
||||
|
||||
<div class="text-center">
|
||||
<h1 class="display-4">Отчёты</h1>
|
||||
<a asp-action="CreateProduct">Создать товар</a>
|
||||
<h1 class="display-4">Письма</h1>
|
||||
</div>
|
||||
<div class="text-center">
|
||||
@{
|
||||
|
@ -35,7 +35,10 @@
|
||||
<a class="nav-link text-dark" asp-area="" asp-controller="Home" asp-action="Orders">Корзины</a>
|
||||
</li>
|
||||
<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>
|
||||
</ul>
|
||||
</div>
|
||||
|
Loading…
Reference in New Issue
Block a user