This commit is contained in:
Вячеслав Иванов 2024-03-28 21:49:49 +04:00
commit d8b075f8eb
152 changed files with 79899 additions and 54 deletions

View File

@ -19,7 +19,9 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "PizzeriaDatabaseImplement",
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "PizzeriaRestApi", "PizzeriaRestApi\PizzeriaRestApi.csproj", "{0C775FE6-A461-47EA-907F-C3AE34F7B6C4}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PizzeriaClientApp", "PizzeriaClientApp\PizzeriaClientApp.csproj", "{7B233638-1F47-4A91-B483-7FFD9F5A4608}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "PizzeriaClientApp", "PizzeriaClientApp\PizzeriaClientApp.csproj", "{7B233638-1F47-4A91-B483-7FFD9F5A4608}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PizzeriaShopApp", "PizzeriaShopApp\PizzeriaShopApp.csproj", "{A7FCCF44-9D5B-4E68-8A70-7632227C39A2}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
@ -63,6 +65,10 @@ Global
{7B233638-1F47-4A91-B483-7FFD9F5A4608}.Debug|Any CPU.Build.0 = Debug|Any CPU
{7B233638-1F47-4A91-B483-7FFD9F5A4608}.Release|Any CPU.ActiveCfg = Release|Any CPU
{7B233638-1F47-4A91-B483-7FFD9F5A4608}.Release|Any CPU.Build.0 = Release|Any CPU
{A7FCCF44-9D5B-4E68-8A70-7632227C39A2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{A7FCCF44-9D5B-4E68-8A70-7632227C39A2}.Debug|Any CPU.Build.0 = Debug|Any CPU
{A7FCCF44-9D5B-4E68-8A70-7632227C39A2}.Release|Any CPU.ActiveCfg = Release|Any CPU
{A7FCCF44-9D5B-4E68-8A70-7632227C39A2}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE

View File

@ -14,9 +14,13 @@ namespace PizzeriaBusinessLogic.BusinessLogics
private readonly IOrderStorage _orderStorage;
static readonly object _locker = new object();
public OrderLogic(ILogger<OrderLogic> logger, IOrderStorage orderStorage)
private readonly IShopStorage _shopStorage;
public OrderLogic(ILogger<OrderLogic> logger, IOrderStorage orderStorage, IShopStorage shopStorage)
{
_logger = logger;
_orderStorage = orderStorage;
_shopStorage = shopStorage;
}
public OrderViewModel? ReadElement(OrderSearchModel model)
@ -80,6 +84,23 @@ namespace PizzeriaBusinessLogic.BusinessLogics
public bool DeliveryOrder(OrderBindingModel model)
{
var order = _orderStorage.GetElement(new OrderSearchModel
{
Id = model.Id,
});
if (order == null)
{
throw new ArgumentNullException(nameof(order));
}
if (!_shopStorage.RestockingShops(new SupplyBindingModel
{
PizzaId = order.PizzaId,
Count = order.Count
}))
{
throw new ArgumentException("Недостаточно места");
}
return ChangeStatus(model, OrderStatus.Выдан);
}

View File

@ -13,16 +13,18 @@ namespace PizzeriaBusinessLogic.BusinessLogics
private readonly IComponentStorage _componentStorage;
private readonly IPizzaStorage _pizzaStorage;
private readonly IOrderStorage _orderStorage;
private readonly IShopStorage _shopStorage;
private readonly AbstractSaveToExcel _saveToExcel;
private readonly AbstractSaveToWord _saveToWord;
private readonly AbstractSaveToPdf _saveToPdf;
public ReportLogic(IPizzaStorage pizzaStorage, IComponentStorage componentStorage, IOrderStorage orderStorage,
public ReportLogic(IPizzaStorage pizzaStorage, IComponentStorage componentStorage, IOrderStorage orderStorage, IShopStorage shopStorage,
AbstractSaveToExcel saveToExcel, AbstractSaveToWord saveToWord, AbstractSaveToPdf saveToPdf)
{
_pizzaStorage = pizzaStorage;
_componentStorage = componentStorage;
_orderStorage = orderStorage;
_shopStorage = shopStorage;
_saveToExcel = saveToExcel;
_saveToWord = saveToWord;
@ -55,7 +57,7 @@ namespace PizzeriaBusinessLogic.BusinessLogics
public void SavePizzasToWordFile(ReportBindingModel model)
{
_saveToWord.CreateDoc(new WordInfo
_saveToWord.CreatePizzaDoc(new WordInfo
{
FileName = model.FileName,
Title = "Список пицц",
@ -84,5 +86,55 @@ namespace PizzeriaBusinessLogic.BusinessLogics
Orders = GetOrders(model)
});
}
public List<ReportShopsViewModel> GetShops()
{
return _shopStorage.GetFullList().Select(x => new ReportShopsViewModel
{
ShopName = x.ShopName,
Pizzas = x.ShopPizzas.Select(x => (x.Value.Item1.PizzaName, x.Value.Item2)).ToList(),
TotalCount = x.ShopPizzas.Select(x => x.Value.Item2).Sum()
}).ToList();
}
public List<ReportGroupOrdersViewModel> GetGroupedOrders()
{
return _orderStorage.GetFullList().GroupBy(x => x.DateCreate.Date).Select(x => new ReportGroupOrdersViewModel
{
Date = x.Key,
OrdersCount = x.Count(),
OrdersSum = x.Select(y => y.Sum).Sum()
}).ToList();
}
public void SaveShopsToWordFile(ReportBindingModel model)
{
_saveToWord.CreateShopsDoc(new WordShopInfo
{
FileName = model.FileName,
Title = "Список магазинов",
Shops = _shopStorage.GetFullList()
});
}
public void SaveShopsToExcelFile(ReportBindingModel model)
{
_saveToExcel.CreateShopPizzasReport(new ExcelShop
{
FileName = model.FileName,
Title = "Наполненость магазинов",
ShopPizzas = GetShops()
});
}
public void SaveGroupedOrdersToPdfFile(ReportBindingModel model)
{
_saveToPdf.CreateGroupedOrdersDoc(new PdfGroupedOrdersInfo
{
FileName = model.FileName,
Title = "Список заказов сгруппированных по дате заказов",
GroupedOrders = GetGroupedOrders()
});
}
}
}

View File

@ -0,0 +1,187 @@
using Microsoft.Extensions.Logging;
using PizzeriaContracts.BindingModels;
using PizzeriaContracts.BusinessLogicsContracts;
using PizzeriaContracts.SearchModels;
using PizzeriaContracts.StoragesContracts;
using PizzeriaContracts.ViewModels;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace PizzeriaBusinessLogic.BusinessLogics
{
public class ShopLogic : IShopLogic
{
private readonly ILogger _logger;
private readonly IShopStorage _shopStorage;
private readonly IPizzaStorage _pizzaStorage;
public ShopLogic(ILogger<ShopLogic> logger, IShopStorage shopStorage, IPizzaStorage pizzaStorage)
{
_logger = logger;
_shopStorage = shopStorage;
_pizzaStorage = pizzaStorage;
}
public List<ShopViewModel>? ReadList(ShopSearchModel? model)
{
_logger.LogInformation("ReadList. ShopName:{ShopName}.Id:{ Id}", model?.ShopName, model?.Id);
var list = model == null ? _shopStorage.GetFullList() : _shopStorage.GetFilteredList(model);
if (list == null)
{
_logger.LogWarning("ReadList return null list");
return null;
}
_logger.LogInformation("ReadList. Count:{Count}", list.Count);
return list;
}
public ShopViewModel? ReadElement(ShopSearchModel model)
{
if (model == null)
{
throw new ArgumentNullException(nameof(model));
}
_logger.LogInformation("ReadElement. ShopName:{ShopName}.Id:{ Id}", model.ShopName, model.Id);
var element = _shopStorage.GetElement(model);
if (element == null)
{
_logger.LogWarning("ReadElement element not found");
return null;
}
_logger.LogInformation("ReadElement find. Id:{Id}", element.Id);
return element;
}
public bool Create(ShopBindingModel model)
{
CheckModel(model);
if (_shopStorage.Insert(model) == null)
{
_logger.LogWarning("Insert operation failed");
return false;
}
return true;
}
public bool Update(ShopBindingModel model)
{
CheckModel(model);
if (_shopStorage.Update(model) == null)
{
_logger.LogWarning("Update operation failed");
return false;
}
return true;
}
public bool Delete(ShopBindingModel model)
{
CheckModel(model, false);
_logger.LogInformation("Delete. Id:{Id}", model.Id);
if (_shopStorage.Delete(model) == null)
{
_logger.LogWarning("Delete operation failed");
return false;
}
return true;
}
public bool MakeSupply(SupplyBindingModel model)
{
if (model == null)
{
throw new ArgumentNullException(nameof(model));
}
if (model.Count <= 0)
{
throw new ArgumentException("Количество пиццы должно быть больше 0");
}
var shop = _shopStorage.GetElement(new ShopSearchModel
{
Id = model.ShopId
});
if (shop == null)
{
throw new ArgumentException("Магазина не существует");
}
if (shop.ShopPizzas.ContainsKey(model.PizzaId))
{
var oldValue = shop.ShopPizzas[model.PizzaId];
oldValue.Item2 += model.Count;
shop.ShopPizzas[model.PizzaId] = oldValue;
}
else
{
var pizza = _pizzaStorage.GetElement(new PizzaSearchModel
{
Id = model.PizzaId
});
if (pizza == null)
{
throw new ArgumentException($"Поставка: Товар с id:{model.PizzaId} не найденн");
}
shop.ShopPizzas.Add(model.PizzaId, (pizza, model.Count));
}
_shopStorage.Update(new ShopBindingModel()
{
Id = shop.Id,
ShopName = shop.ShopName,
Adress = shop.Adress,
OpeningDate = shop.OpeningDate,
ShopPizzas = shop.ShopPizzas,
PizzaMaxCount = shop.PizzaMaxCount,
});
return true;
}
private void CheckModel(ShopBindingModel model, bool withParams = true)
{
if (model == null)
{
throw new ArgumentNullException(nameof(model));
}
if (!withParams)
{
return;
}
if (string.IsNullOrEmpty(model.Adress))
{
throw new ArgumentException("Адрес магазина длжен быть заполнен", nameof(model.Adress));
}
if (string.IsNullOrEmpty(model.ShopName))
{
throw new ArgumentException("Название магазина должно быть заполнено", nameof(model.ShopName));
}
_logger.LogInformation("Shop. ShopName:{ShopName}.Adres:{Adres}.OpeningDate:{OpeningDate}.Id:{ Id}", model.ShopName, model.Adress, model.OpeningDate, model.Id);
var element = _shopStorage.GetElement(new ShopSearchModel
{
ShopName = model.ShopName
});
if (element != null && element.Id != model.Id)
{
throw new InvalidOperationException("Магазин с таким названием уже есть");
}
}
public bool Sale(SupplySearchModel model)
{
if (!model.PizzaId.HasValue || !model.Count.HasValue)
{
return false;
}
_logger.LogInformation("Check pizza count in all shops");
if (_shopStorage.Sale(model))
{
_logger.LogInformation("Selling sucsess");
return true;
}
_logger.LogInformation("Selling failed");
return false;
}
}
}

View File

@ -75,9 +75,82 @@ namespace PizzeriaBusinessLogic.OfficePackage
SaveExcel(info);
}
protected abstract void CreateExcel(ExcelInfo info);
public void CreateShopPizzasReport(ExcelShop info)
{
CreateExcel(info);
InsertCellInWorksheet(new ExcelCellParameters
{
ColumnName = "A",
RowIndex = 1,
Text = info.Title,
StyleInfo = ExcelStyleInfoType.Title
});
MergeCells(new ExcelMergeParameters
{
CellFromName = "A1",
CellToName = "C1"
});
uint rowIndex = 2;
foreach (var sr in info.ShopPizzas)
{
InsertCellInWorksheet(new ExcelCellParameters
{
ColumnName = "A",
RowIndex = rowIndex,
Text = sr.ShopName,
StyleInfo = ExcelStyleInfoType.Text
});
rowIndex++;
foreach (var (Pizza, Count) in sr.Pizzas)
{
InsertCellInWorksheet(new ExcelCellParameters
{
ColumnName = "B",
RowIndex = rowIndex,
Text = Pizza,
StyleInfo = ExcelStyleInfoType.TextWithBroder
});
InsertCellInWorksheet(new ExcelCellParameters
{
ColumnName = "C",
RowIndex = rowIndex,
Text = Count.ToString(),
StyleInfo = ExcelStyleInfoType.TextWithBroder
});
rowIndex++;
}
InsertCellInWorksheet(new ExcelCellParameters
{
ColumnName = "A",
RowIndex = rowIndex,
Text = "Итого",
StyleInfo = ExcelStyleInfoType.Text
});
InsertCellInWorksheet(new ExcelCellParameters
{
ColumnName = "C",
RowIndex = rowIndex,
Text = sr.TotalCount.ToString(),
StyleInfo = ExcelStyleInfoType.Text
});
rowIndex++;
}
SaveExcel(info);
}
protected abstract void CreateExcel(IDocument info);
protected abstract void InsertCellInWorksheet(ExcelCellParameters excelParams);
protected abstract void MergeCells(ExcelMergeParameters excelParams);
protected abstract void SaveExcel(ExcelInfo info);
protected abstract void SaveExcel(IDocument info);
}
}

View File

@ -33,10 +33,40 @@ namespace PizzeriaBusinessLogic.OfficePackage
SavePdf(info);
}
protected abstract void CreatePdf(PdfInfo info);
public void CreateGroupedOrdersDoc(PdfGroupedOrdersInfo info)
{
CreatePdf(info);
CreateParagraph(new PdfParagraph { Text = info.Title, Style = "NormalTitle", ParagraphAlignment = PdfParagraphAlignmentType.Center });
CreateTable(new List<string> { "4cm", "3cm", "2cm" });
CreateRow(new PdfRowParameters
{
Texts = new List<string> { "Дата заказа", "Кол-во", "Сумма" },
Style = "NormalTitle",
ParagraphAlignment = PdfParagraphAlignmentType.Center
});
foreach (var groupedOrder in info.GroupedOrders)
{
CreateRow(new PdfRowParameters
{
Texts = new List<string> { groupedOrder.Date.ToShortDateString(), groupedOrder.OrdersCount.ToString(), groupedOrder.OrdersSum.ToString() },
Style = "Normal",
ParagraphAlignment = PdfParagraphAlignmentType.Left
});
}
CreateParagraph(new PdfParagraph { Text = $"Итого: {info.GroupedOrders.Sum(x => x.OrdersSum)}\t", Style = "Normal", ParagraphAlignment = PdfParagraphAlignmentType.Center });
SavePdf(info);
}
protected abstract void CreatePdf(IDocument info);
protected abstract void CreateParagraph(PdfParagraph paragraph);
protected abstract void CreateTable(List<string> columns);
protected abstract void CreateRow(PdfRowParameters rowParameters);
protected abstract void SavePdf(PdfInfo info);
protected abstract void SavePdf(IDocument info);
}
}

View File

@ -10,7 +10,7 @@ namespace PizzeriaBusinessLogic.OfficePackage
{
public abstract class AbstractSaveToWord
{
public void CreateDoc(WordInfo info)
public void CreatePizzaDoc(WordInfo info)
{
CreateWord(info);
@ -42,8 +42,52 @@ namespace PizzeriaBusinessLogic.OfficePackage
SaveWord(info);
}
protected abstract void CreateWord(WordInfo info);
public void CreateShopsDoc(WordShopInfo info)
{
CreateWord(info);
CreateParagraph(new WordParagraph
{
Texts = new List<(string, WordTextProperties)> { (info.Title, new WordTextProperties { Bold = true, Size = "24", }) },
TextProperties = new WordTextProperties
{
Size = "24",
JustificationType = WordJustificationType.Center
}
});
CreateTable(new List<string> { "3000", "3000", "3000" });
CreateRow(new WordRowParameters
{
Texts = new List<string> { "Название", "Адрес", "Дата открытия" },
TextProperties = new WordTextProperties
{
Size = "24",
Bold = true,
JustificationType = WordJustificationType.Center
}
});
foreach (var shop in info.Shops)
{
CreateRow(new WordRowParameters
{
Texts = new List<string> { shop.ShopName, shop.Adress, shop.OpeningDate.ToString() },
TextProperties = new WordTextProperties
{
Size = "22",
JustificationType = WordJustificationType.Both
}
});
}
SaveWord(info);
}
protected abstract void CreateWord(IDocument info);
protected abstract void CreateParagraph(WordParagraph paragraph);
protected abstract void SaveWord(WordInfo info);
protected abstract void SaveWord(IDocument info);
protected abstract void CreateTable(List<string> colums);
protected abstract void CreateRow(WordRowParameters rowParameters);
}
}

View File

@ -2,7 +2,7 @@
namespace PizzeriaBusinessLogic.OfficePackage.HelperModels
{
public class ExcelInfo
public class ExcelInfo : IDocument
{
public string FileName { get; set; } = string.Empty;
public string Title { get; set; } = string.Empty;

View File

@ -0,0 +1,11 @@
using PizzeriaContracts.ViewModels;
namespace PizzeriaBusinessLogic.OfficePackage.HelperModels
{
public class ExcelShop : IDocument
{
public string FileName { get; set; } = string.Empty;
public string Title { get; set; } = string.Empty;
public List<ReportShopsViewModel> ShopPizzas { get; set; } = new();
}
}

View File

@ -0,0 +1,18 @@
using PizzeriaContracts.ViewModels;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace PizzeriaBusinessLogic.OfficePackage.HelperModels
{
public class PdfGroupedOrdersInfo : IDocument
{
public string FileName { get; set; } = string.Empty;
public string Title { get; set; } = string.Empty;
public DateTime DateFrom { get; set; }
public DateTime DateTo { get; set; }
public List<ReportGroupOrdersViewModel> GroupedOrders { get; set; } = new();
}
}

View File

@ -2,7 +2,7 @@
namespace PizzeriaBusinessLogic.OfficePackage.HelperModels
{
public class PdfInfo
public class PdfInfo : IDocument
{
public string FileName { get; set; } = string.Empty;
public string Title { get; set; } = string.Empty;

View File

@ -2,7 +2,7 @@
namespace PizzeriaBusinessLogic.OfficePackage.HelperModels
{
public class WordInfo
public class WordInfo : IDocument
{
public string FileName { get; set; } = string.Empty;
public string Title { get; set; } = string.Empty;

View File

@ -0,0 +1,14 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace PizzeriaBusinessLogic.OfficePackage.HelperModels
{
public class WordRowParameters
{
public List<string> Texts { get; set; } = new();
public WordTextProperties TextProperties { get; set; } = new();
}
}

View File

@ -0,0 +1,16 @@
using PizzeriaContracts.ViewModels;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace PizzeriaBusinessLogic.OfficePackage.HelperModels
{
public class WordShopInfo : IDocument
{
public string FileName { get; set; } = string.Empty;
public string Title { get; set; } = string.Empty;
public List<ShopViewModel> Shops { get; set; } = new();
}
}

View File

@ -0,0 +1,14 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace PizzeriaBusinessLogic.OfficePackage
{
public interface IDocument
{
public string FileName { get; set; }
public string Title { get; set; }
}
}

View File

@ -3,9 +3,9 @@ using DocumentFormat.OpenXml.Office2013.Excel;
using DocumentFormat.OpenXml.Packaging;
using DocumentFormat.OpenXml.Spreadsheet;
using DocumentFormat.OpenXml;
using PizzeriaBusinessLogic.OfficePackage;
using PizzeriaBusinessLogic.OfficePackage.HelperEnums;
using PizzeriaBusinessLogic.OfficePackage.HelperModels;
using PizzeriaBusinessLogic.OfficePackage;
namespace PizzeriaBusinessLogic.OfficePackage.Implements
{
@ -140,7 +140,7 @@ namespace PizzeriaBusinessLogic.OfficePackage.Implements
};
}
protected override void CreateExcel(ExcelInfo info)
protected override void CreateExcel(IDocument info)
{
_spreadsheetDocument = SpreadsheetDocument.Create(info.FileName, SpreadsheetDocumentType.Workbook);
// Создаем книгу (в ней хранятся листы)
@ -269,7 +269,7 @@ namespace PizzeriaBusinessLogic.OfficePackage.Implements
mergeCells.Append(mergeCell);
}
protected override void SaveExcel(ExcelInfo info)
protected override void SaveExcel(IDocument info)
{
if (_spreadsheetDocument == null)
{

View File

@ -34,7 +34,7 @@ namespace PizzeriaBusinessLogic.OfficePackage.Implements
style.Font.Bold = true;
}
protected override void CreatePdf(PdfInfo info)
protected override void CreatePdf(IDocument info)
{
_document = new Document();
DefineStyles(_document);
@ -96,7 +96,7 @@ namespace PizzeriaBusinessLogic.OfficePackage.Implements
}
}
protected override void SavePdf(PdfInfo info)
protected override void SavePdf(IDocument info)
{
var renderer = new PdfDocumentRenderer(true)
{

View File

@ -21,6 +21,7 @@ namespace PizzeriaBusinessLogic.OfficePackage.Implements
_ => JustificationValues.Left,
};
}
private static SectionProperties CreateSectionProperties()
{
var properties = new SectionProperties();
@ -34,6 +35,7 @@ namespace PizzeriaBusinessLogic.OfficePackage.Implements
return properties;
}
private static ParagraphProperties? CreateParagraphProperties(WordTextProperties? paragraphProperties)
{
if (paragraphProperties == null)
@ -64,13 +66,15 @@ namespace PizzeriaBusinessLogic.OfficePackage.Implements
return properties;
}
protected override void CreateWord(WordInfo info)
protected override void CreateWord(IDocument info)
{
_wordDocument = WordprocessingDocument.Create(info.FileName, WordprocessingDocumentType.Document);
MainDocumentPart mainPart = _wordDocument.AddMainDocumentPart();
mainPart.Document = new Document();
_docBody = mainPart.Document.AppendChild(new Body());
}
protected override void CreateParagraph(WordParagraph paragraph)
{
if (_docBody == null || paragraph == null)
@ -100,7 +104,8 @@ namespace PizzeriaBusinessLogic.OfficePackage.Implements
_docBody.AppendChild(docParagraph);
}
protected override void SaveWord(WordInfo info)
protected override void SaveWord(IDocument info)
{
if (_docBody == null || _wordDocument == null)
{
@ -112,5 +117,77 @@ namespace PizzeriaBusinessLogic.OfficePackage.Implements
_wordDocument.Close();
}
private Table? _lastTable;
protected override void CreateTable(List<string> columns)
{
if (_docBody == null)
return;
_lastTable = new Table();
var tableProp = new TableProperties();
tableProp.AppendChild(new TableLayout { Type = TableLayoutValues.Fixed });
tableProp.AppendChild(new TableBorders(
new TopBorder() { Val = new EnumValue<BorderValues>(BorderValues.Single), Size = 4 },
new LeftBorder() { Val = new EnumValue<BorderValues>(BorderValues.Single), Size = 4 },
new RightBorder() { Val = new EnumValue<BorderValues>(BorderValues.Single), Size = 4 },
new BottomBorder() { Val = new EnumValue<BorderValues>(BorderValues.Single), Size = 4 },
new InsideHorizontalBorder() { Val = new EnumValue<BorderValues>(BorderValues.Single), Size = 4 },
new InsideVerticalBorder() { Val = new EnumValue<BorderValues>(BorderValues.Single), Size = 4 }
));
tableProp.AppendChild(new TableWidth { Type = TableWidthUnitValues.Auto });
_lastTable.AppendChild(tableProp);
TableGrid tableGrid = new TableGrid();
foreach (var column in columns)
{
tableGrid.AppendChild(new GridColumn() { Width = column });
}
_lastTable.AppendChild(tableGrid);
_docBody.AppendChild(_lastTable);
}
protected override void CreateRow(WordRowParameters rowParameters)
{
if (_docBody == null || _lastTable == null)
return;
TableRow docRow = new TableRow();
foreach (var column in rowParameters.Texts)
{
var docParagraph = new Paragraph();
WordParagraph paragraph = new WordParagraph
{
Texts = new List<(string, WordTextProperties)> { (column, rowParameters.TextProperties) },
TextProperties = rowParameters.TextProperties
};
docParagraph.AppendChild(CreateParagraphProperties(paragraph.TextProperties));
foreach (var run in paragraph.Texts)
{
var docRun = new Run();
var properties = new RunProperties();
properties.AppendChild(new FontSize { Val = run.Item2.Size });
if (run.Item2.Bold)
{
properties.AppendChild(new Bold());
}
docRun.AppendChild(properties);
docRun.AppendChild(new Text { Text = run.Item1, Space = SpaceProcessingModeValues.Preserve });
docParagraph.AppendChild(docRun);
}
TableCell docCell = new TableCell();
docCell.AppendChild(docParagraph);
docRow.AppendChild(docCell);
}
_lastTable.AppendChild(docRow);
}
}
}

View File

@ -44,7 +44,7 @@
<footer class="border-top footer text-muted">
<div class="container">
&copy; 2023 - PizzeriaClientApp - <a asp-area="" asp-controller="Home" asp-action="Privacy">Privacy</a>
&copy; 2024 - PizzeriaClientApp - <a asp-area="" asp-controller="Home" asp-action="Privacy">Privacy</a>
</div>
</footer>
<script src="~/lib/jquery/dist/jquery.min.js"></script>

View File

@ -0,0 +1,19 @@
using PizzeriaDataModels.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace PizzeriaContracts.BindingModels
{
public class ShopBindingModel : IShopModel
{
public int Id { get; set; }
public string ShopName { get; set; } = string.Empty;
public string Adress { get; set; } = string.Empty;
public DateTime OpeningDate { get; set; } = DateTime.Now;
public Dictionary<int, (IPizzaModel, int)> ShopPizzas { get; set; } = new();
public int PizzaMaxCount { get; set; }
}
}

View File

@ -0,0 +1,16 @@
using PizzeriaDataModels.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace PizzeriaContracts.BindingModels
{
public class SupplyBindingModel : ISupplyModel
{
public int ShopId { get; set; }
public int PizzaId { get; set; }
public int Count { get; set; }
}
}

View File

@ -7,8 +7,13 @@ namespace PizzeriaContracts.BusinessLogicsContracts
{
List<ReportPizzaComponentViewModel> GetPizzaComponents();
List<ReportOrdersViewModel> GetOrders(ReportBindingModel model);
List<ReportShopsViewModel> GetShops();
List<ReportGroupOrdersViewModel> GetGroupedOrders();
void SavePizzasToWordFile(ReportBindingModel model);
void SavePizzaComponentToExcelFile(ReportBindingModel model);
void SaveOrdersToPdfFile(ReportBindingModel model);
void SaveShopsToWordFile(ReportBindingModel model);
void SaveShopsToExcelFile(ReportBindingModel model);
void SaveGroupedOrdersToPdfFile(ReportBindingModel model);
}
}

View File

@ -0,0 +1,22 @@
using PizzeriaContracts.BindingModels;
using PizzeriaContracts.SearchModels;
using PizzeriaContracts.ViewModels;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace PizzeriaContracts.BusinessLogicsContracts
{
public interface IShopLogic
{
List<ShopViewModel>? ReadList(ShopSearchModel? model);
ShopViewModel? ReadElement(ShopSearchModel model);
bool Create(ShopBindingModel model);
bool Update(ShopBindingModel model);
bool Delete(ShopBindingModel model);
bool MakeSupply(SupplyBindingModel model);
bool Sale(SupplySearchModel model);
}
}

View File

@ -0,0 +1,14 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace PizzeriaContracts.SearchModels
{
public class ShopSearchModel
{
public int? Id { get; set; }
public string? ShopName { get; set; }
}
}

View File

@ -0,0 +1,14 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace PizzeriaContracts.SearchModels
{
public class SupplySearchModel
{
public int? PizzaId { get; set; }
public int? Count { get; set; }
}
}

View File

@ -0,0 +1,23 @@
using PizzeriaContracts.BindingModels;
using PizzeriaContracts.SearchModels;
using PizzeriaContracts.ViewModels;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace PizzeriaContracts.StoragesContracts
{
public interface IShopStorage
{
List<ShopViewModel> GetFullList();
List<ShopViewModel> GetFilteredList(ShopSearchModel model);
ShopViewModel? GetElement(ShopSearchModel model);
ShopViewModel? Insert(ShopBindingModel model);
ShopViewModel? Update(ShopBindingModel model);
ShopViewModel? Delete(ShopBindingModel model);
bool Sale(SupplySearchModel model);
bool RestockingShops(SupplyBindingModel model);
}
}

View File

@ -0,0 +1,8 @@
namespace PizzeriaContracts.ViewModels
{
public class PizzaCount
{
public PizzaViewModel Pizza { get; set; }
public int Count { get; set; } = new();
}
}

View File

@ -0,0 +1,15 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace PizzeriaContracts.ViewModels
{
public class ReportGroupOrdersViewModel
{
public DateTime Date { get; set; } = DateTime.Now;
public int OrdersCount { get; set; }
public double OrdersSum { get; set; }
}
}

View File

@ -0,0 +1,15 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace PizzeriaContracts.ViewModels
{
public class ReportShopsViewModel
{
public string ShopName { get; set; } = string.Empty;
public int TotalCount { get; set; }
public List<(string Pizza, int count)> Pizzas { get; set; } = new();
}
}

View File

@ -0,0 +1,8 @@
namespace PizzeriaContracts.ViewModels
{
public class ShopPizzaViewModel
{
public ShopViewModel Shop { get; set; } = new();
public Dictionary<int, PizzaCount> ShopPizza { get; set; } = new();
}
}

View File

@ -0,0 +1,24 @@
using PizzeriaDataModels.Models;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace PizzeriaContracts.ViewModels
{
public class ShopViewModel : IShopModel
{
public int Id { get; set; }
[DisplayName("Название")]
public string ShopName { get; set; } = string.Empty;
[DisplayName("Адрес")]
public string Adress { get; set; } = string.Empty;
[DisplayName("Дата открытия")]
public DateTime OpeningDate { get; set; }
public Dictionary<int, (IPizzaModel, int)> ShopPizzas { get; set; } = new();
[DisplayName("Вместимость")]
public int PizzaMaxCount { get; set; }
}
}

View File

@ -0,0 +1,19 @@
using PizzeriaDataModels;
using PizzeriaDataModels.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace PizzeriaDataModels.Models
{
public interface IShopModel : IId
{
string ShopName { get; }
string Adress { get; }
DateTime OpeningDate { get; }
Dictionary<int, (IPizzaModel, int)> ShopPizzas { get; }
public int PizzaMaxCount { get; }
}
}

View File

@ -0,0 +1,15 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace PizzeriaDataModels.Models
{
public interface ISupplyModel
{
int ShopId { get; }
int PizzaId { get; }
int Count { get; }
}
}

View File

@ -0,0 +1,185 @@
using Microsoft.EntityFrameworkCore;
using PizzeriaContracts.BindingModels;
using PizzeriaContracts.SearchModels;
using PizzeriaContracts.StoragesContracts;
using PizzeriaContracts.ViewModels;
using PizzeriaDatabaseImplement.Models;
namespace PizzeriaDatabaseImplement.Implements
{
public class ShopStorage : IShopStorage
{
public List<ShopViewModel> GetFullList()
{
using var context = new PizzeriaDatabase();
return context.Shops.Include(x => x.Pizzas).ThenInclude(x => x.Pizza).ToList().
Select(x => x.GetViewModel).ToList();
}
public List<ShopViewModel> GetFilteredList(ShopSearchModel model)
{
if (string.IsNullOrEmpty(model.ShopName))
{
return new();
}
using var context = new PizzeriaDatabase();
return context.Shops.Include(x => x.Pizzas).ThenInclude(x => x.Pizza).Where(x => x.ShopName.Contains(model.ShopName)).
ToList().Select(x => x.GetViewModel).ToList();
}
public ShopViewModel? GetElement(ShopSearchModel model)
{
if (string.IsNullOrEmpty(model.ShopName) && !model.Id.HasValue)
{
return new();
}
using var context = new PizzeriaDatabase();
return context.Shops.Include(x => x.Pizzas).ThenInclude(x => x.Pizza)
.FirstOrDefault(x =>
(!string.IsNullOrEmpty(model.ShopName) && x.ShopName == model.ShopName) ||
(model.Id.HasValue && x.Id == model.Id))?.GetViewModel;
}
public ShopViewModel? Insert(ShopBindingModel model)
{
using var context = new PizzeriaDatabase();
var newShop = Shop.Create(context, model);
if (newShop == null)
{
return null;
}
context.Shops.Add(newShop);
context.SaveChanges();
return newShop.GetViewModel;
}
public ShopViewModel? Update(ShopBindingModel model)
{
using var context = new PizzeriaDatabase();
using var transaction = context.Database.BeginTransaction();
try
{
var shop = context.Shops.FirstOrDefault(x => x.Id == model.Id);
if (shop == null)
{
return null;
}
shop.Update(model);
context.SaveChanges();
shop.UpdatePizzas(context, model);
transaction.Commit();
return shop.GetViewModel;
}
catch
{
transaction.Rollback();
throw;
}
}
public ShopViewModel? Delete(ShopBindingModel model)
{
using var context = new PizzeriaDatabase();
var shop = context.Shops.Include(x => x.Pizzas).FirstOrDefault(x => x.Id == model.Id);
if (shop != null)
{
context.Shops.Remove(shop);
context.SaveChanges();
return shop.GetViewModel;
}
return null;
}
public bool RestockingShops(SupplyBindingModel model)
{
using var context = new PizzeriaDatabase();
var transaction = context.Database.BeginTransaction();
var Shops = context.Shops.Include(x => x.Pizzas).ThenInclude(x => x.Pizza).ToList().
Where(x => x.PizzaMaxCount > x.ShopPizzas.Select(x => x.Value.Item2).Sum()).ToList();
if (model == null)
{
return false;
}
try
{
foreach (Shop shop in Shops)
{
int difference = shop.PizzaMaxCount - shop.ShopPizzas.Select(x => x.Value.Item2).Sum();
int refill = Math.Min(difference, model.Count);
model.Count -= refill;
if (shop.ShopPizzas.ContainsKey(model.PizzaId))
{
var datePair = shop.ShopPizzas[model.PizzaId];
datePair.Item2 += refill;
shop.ShopPizzas[model.PizzaId] = datePair;
}
else
{
var pizza = context.Pizzas.First(x => x.Id == model.PizzaId);
shop.ShopPizzas.Add(model.PizzaId, (pizza, refill));
}
shop.PizzasDictionatyUpdate(context);
if (model.Count == 0)
{
transaction.Commit();
return true;
}
}
transaction.Rollback();
return false;
}
catch
{
transaction.Rollback();
throw;
}
}
public bool Sale(SupplySearchModel model)
{
using var context = new PizzeriaDatabase();
var transaction = context.Database.BeginTransaction();
try
{
var shops = context.Shops.Include(x => x.Pizzas).ThenInclude(x => x.Pizza).ToList().
Where(x => x.ShopPizzas.ContainsKey(model.PizzaId.Value)).OrderByDescending(x => x.ShopPizzas[model.PizzaId.Value].Item2).ToList();
foreach (var shop in shops)
{
int residue = model.Count.Value - shop.ShopPizzas[model.PizzaId.Value].Item2;
if (residue > 0)
{
shop.ShopPizzas.Remove(model.PizzaId.Value);
shop.PizzasDictionatyUpdate(context);
context.SaveChanges();
model.Count = residue;
}
else
{
if (residue == 0)
shop.ShopPizzas.Remove(model.PizzaId.Value);
else
{
var dataPair = shop.ShopPizzas[model.PizzaId.Value];
dataPair.Item2 = -residue;
shop.ShopPizzas[model.PizzaId.Value] = dataPair;
}
shop.PizzasDictionatyUpdate(context);
transaction.Commit();
return true;
}
}
transaction.Rollback();
return false;
}
catch
{
transaction.Rollback();
throw;
}
}
}
}

View File

@ -0,0 +1,248 @@
// <auto-generated />
using System;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using PizzeriaDatabaseImplement;
#nullable disable
namespace PizzeriaDatabaseImplement.Migrations
{
[DbContext(typeof(PizzeriaDatabase))]
[Migration("20240305050232_Hard_init")]
partial class Hard_init
{
/// <inheritdoc />
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("ProductVersion", "7.0.3")
.HasAnnotation("Relational:MaxIdentifierLength", 128);
SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder);
modelBuilder.Entity("PizzeriaDatabaseImplement.Models.Component", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<string>("ComponentName")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<double>("Cost")
.HasColumnType("float");
b.HasKey("Id");
b.ToTable("Components");
});
modelBuilder.Entity("PizzeriaDatabaseImplement.Models.Order", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<int>("Count")
.HasColumnType("int");
b.Property<DateTime>("DateCreate")
.HasColumnType("datetime2");
b.Property<DateTime?>("DateImplement")
.HasColumnType("datetime2");
b.Property<int>("PizzaId")
.HasColumnType("int");
b.Property<int>("Status")
.HasColumnType("int");
b.Property<double>("Sum")
.HasColumnType("float");
b.HasKey("Id");
b.HasIndex("PizzaId");
b.ToTable("Orders");
});
modelBuilder.Entity("PizzeriaDatabaseImplement.Models.Pizza", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<string>("PizzaName")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<double>("Price")
.HasColumnType("float");
b.HasKey("Id");
b.ToTable("Pizzas");
});
modelBuilder.Entity("PizzeriaDatabaseImplement.Models.PizzaComponent", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<int>("ComponentId")
.HasColumnType("int");
b.Property<int>("Count")
.HasColumnType("int");
b.Property<int>("PizzaId")
.HasColumnType("int");
b.HasKey("Id");
b.HasIndex("ComponentId");
b.HasIndex("PizzaId");
b.ToTable("PizzaComponents");
});
modelBuilder.Entity("PizzeriaDatabaseImplement.Models.Shop", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<string>("Adress")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<DateTime>("OpeningDate")
.HasColumnType("datetime2");
b.Property<int>("PizzaMaxCount")
.HasColumnType("int");
b.Property<string>("ShopName")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.HasKey("Id");
b.ToTable("Shops");
});
modelBuilder.Entity("PizzeriaDatabaseImplement.Models.ShopPizzas", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<int>("Count")
.HasColumnType("int");
b.Property<int>("PizzaId")
.HasColumnType("int");
b.Property<int>("ShopId")
.HasColumnType("int");
b.HasKey("Id");
b.HasIndex("PizzaId");
b.HasIndex("ShopId");
b.ToTable("ShopPizzas");
});
modelBuilder.Entity("PizzeriaDatabaseImplement.Models.Order", b =>
{
b.HasOne("PizzeriaDatabaseImplement.Models.Pizza", "Pizza")
.WithMany("Orders")
.HasForeignKey("PizzaId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Pizza");
});
modelBuilder.Entity("PizzeriaDatabaseImplement.Models.PizzaComponent", b =>
{
b.HasOne("PizzeriaDatabaseImplement.Models.Component", "Component")
.WithMany("PizzaComponents")
.HasForeignKey("ComponentId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("PizzeriaDatabaseImplement.Models.Pizza", "Pizza")
.WithMany("Components")
.HasForeignKey("PizzaId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Component");
b.Navigation("Pizza");
});
modelBuilder.Entity("PizzeriaDatabaseImplement.Models.ShopPizzas", b =>
{
b.HasOne("PizzeriaDatabaseImplement.Models.Pizza", "Pizza")
.WithMany("ShopPizzas")
.HasForeignKey("PizzaId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("PizzeriaDatabaseImplement.Models.Shop", "Shop")
.WithMany("Pizzas")
.HasForeignKey("ShopId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Pizza");
b.Navigation("Shop");
});
modelBuilder.Entity("PizzeriaDatabaseImplement.Models.Component", b =>
{
b.Navigation("PizzaComponents");
});
modelBuilder.Entity("PizzeriaDatabaseImplement.Models.Pizza", b =>
{
b.Navigation("Components");
b.Navigation("Orders");
});
modelBuilder.Entity("PizzeriaDatabaseImplement.Models.Shop", b =>
{
b.Navigation("Pizzas");
});
#pragma warning restore 612, 618
}
}
}

View File

@ -0,0 +1,78 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace PizzeriaDatabaseImplement.Migrations
{
/// <inheritdoc />
public partial class Hard_init : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "Shops",
columns: table => new
{
Id = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
ShopName = table.Column<string>(type: "nvarchar(max)", nullable: false),
Adress = table.Column<string>(type: "nvarchar(max)", nullable: false),
OpeningDate = table.Column<DateTime>(type: "datetime2", nullable: false),
PizzaMaxCount = table.Column<int>(type: "int", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Shops", x => x.Id);
});
migrationBuilder.CreateTable(
name: "ShopPizzas",
columns: table => new
{
Id = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
PizzaId = table.Column<int>(type: "int", nullable: false),
ShopId = table.Column<int>(type: "int", nullable: false),
Count = table.Column<int>(type: "int", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_ShopPizzas", x => x.Id);
table.ForeignKey(
name: "FK_ShopPizzas_Pizzas_PizzaId",
column: x => x.PizzaId,
principalTable: "Pizzas",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_ShopPizzas_Shops_ShopId",
column: x => x.ShopId,
principalTable: "Shops",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateIndex(
name: "IX_ShopPizzas_PizzaId",
table: "ShopPizzas",
column: "PizzaId");
migrationBuilder.CreateIndex(
name: "IX_ShopPizzas_ShopId",
table: "ShopPizzas",
column: "ShopId");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "ShopPizzas");
migrationBuilder.DropTable(
name: "Shops");
}
}
}

View File

@ -183,6 +183,59 @@ namespace PizzeriaDatabaseImplement.Migrations
b.ToTable("PizzaComponents");
});
modelBuilder.Entity("PizzeriaDatabaseImplement.Models.Shop", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<string>("Adress")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<DateTime>("OpeningDate")
.HasColumnType("datetime2");
b.Property<int>("PizzaMaxCount")
.HasColumnType("int");
b.Property<string>("ShopName")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.HasKey("Id");
b.ToTable("Shops");
});
modelBuilder.Entity("PizzeriaDatabaseImplement.Models.ShopPizzas", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<int>("Count")
.HasColumnType("int");
b.Property<int>("PizzaId")
.HasColumnType("int");
b.Property<int>("ShopId")
.HasColumnType("int");
b.HasKey("Id");
b.HasIndex("PizzaId");
b.HasIndex("ShopId");
b.ToTable("ShopPizzas");
});
modelBuilder.Entity("PizzeriaDatabaseImplement.Models.Order", b =>
{
b.HasOne("PizzeriaDatabaseImplement.Models.Client", "Client")
@ -227,6 +280,25 @@ namespace PizzeriaDatabaseImplement.Migrations
b.Navigation("Pizza");
});
modelBuilder.Entity("PizzeriaDatabaseImplement.Models.ShopPizzas", b =>
{
b.HasOne("PizzeriaDatabaseImplement.Models.Pizza", "Pizza")
.WithMany("ShopPizzas")
.HasForeignKey("PizzaId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("PizzeriaDatabaseImplement.Models.Shop", "Shop")
.WithMany("Pizzas")
.HasForeignKey("ShopId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Pizza");
b.Navigation("Shop");
});
modelBuilder.Entity("PizzeriaDatabaseImplement.Models.Client", b =>
{
b.Navigation("Orders");
@ -248,6 +320,11 @@ namespace PizzeriaDatabaseImplement.Migrations
b.Navigation("Orders");
});
modelBuilder.Entity("PizzeriaDatabaseImplement.Models.Shop", b =>
{
b.Navigation("Pizzas");
});
#pragma warning restore 612, 618
}
}

View File

@ -28,6 +28,7 @@ namespace PizzeriaDatabaseImplement.Models
return _pizzaComponents;
}
}
[ForeignKey("PizzaId")]
public virtual List<PizzaComponent> Components { get; set; } = new();
[ForeignKey("PizzaId")]

View File

@ -0,0 +1,114 @@
using PizzeriaContracts.BindingModels;
using PizzeriaContracts.ViewModels;
using PizzeriaDataModels.Models;
using System.ComponentModel.DataAnnotations.Schema;
namespace PizzeriaDatabaseImplement.Models
{
public class Shop : IShopModel
{
public int Id { get; set; }
public string ShopName { get; set; } = string.Empty;
public string Adress { get; set; } = string.Empty;
public DateTime OpeningDate { get; set; }
public int PizzaMaxCount { get; set; }
private Dictionary<int, (IPizzaModel, int)>? _shopPizzas = null;
public Dictionary<int, (IPizzaModel, int)> ShopPizzas
{
get
{
if (_shopPizzas == null)
{
if (_shopPizzas == null)
{
_shopPizzas = Pizzas
.ToDictionary(recSP => recSP.PizzaId, recSP => (recSP.Pizza as IPizzaModel, recSP.Count));
}
return _shopPizzas;
}
return _shopPizzas;
}
}
[ForeignKey("ShopId")]
public List<ShopPizzas> Pizzas { get; set; } = new();
public static Shop Create(PizzeriaDatabase context, ShopBindingModel model)
{
return new Shop()
{
Id = model.Id,
ShopName = model.ShopName,
Adress = model.Adress,
OpeningDate = model.OpeningDate,
Pizzas = model.ShopPizzas.Select(x => new ShopPizzas
{
Pizza = context.Pizzas.First(y => y.Id == x.Key),
Count = x.Value.Item2
}).ToList(),
PizzaMaxCount = model.PizzaMaxCount
};
}
public void Update(ShopBindingModel model)
{
ShopName = model.ShopName;
Adress = model.Adress;
OpeningDate = model.OpeningDate;
PizzaMaxCount = model.PizzaMaxCount;
}
public ShopViewModel GetViewModel => new()
{
Id = Id,
ShopName = ShopName,
Adress = Adress,
OpeningDate = OpeningDate,
ShopPizzas = ShopPizzas,
PizzaMaxCount = PizzaMaxCount
};
public void UpdatePizzas(PizzeriaDatabase context, ShopBindingModel model)
{
var ShopPizzas = context.ShopPizzas.Where(rec => rec.ShopId == model.Id).ToList();
if (ShopPizzas != null && ShopPizzas.Count > 0)
{
context.ShopPizzas.RemoveRange(ShopPizzas.Where(rec => !model.ShopPizzas.ContainsKey(rec.PizzaId)));
context.SaveChanges();
ShopPizzas = context.ShopPizzas.Where(rec => rec.ShopId == model.Id).ToList();
foreach (var updatePizza in ShopPizzas)
{
updatePizza.Count = model.ShopPizzas[updatePizza.PizzaId].Item2;
model.ShopPizzas.Remove(updatePizza.PizzaId);
}
context.SaveChanges();
}
var shop = context.Shops.First(x => x.Id == Id);
foreach (var ar in model.ShopPizzas)
{
context.ShopPizzas.Add(new ShopPizzas
{
Shop = shop,
Pizza = context.Pizzas.First(x => x.Id == ar.Key),
Count = ar.Value.Item2
});
context.SaveChanges();
}
_shopPizzas = null;
}
public void PizzasDictionatyUpdate(PizzeriaDatabase context)
{
UpdatePizzas(context, new ShopBindingModel
{
Id = Id,
ShopPizzas = ShopPizzas,
});
}
}
}

View File

@ -0,0 +1,22 @@
using System.ComponentModel.DataAnnotations;
namespace PizzeriaDatabaseImplement.Models
{
public class ShopPizzas
{
public int Id { get; set; }
[Required]
public int PizzaId { get; set; }
[Required]
public int ShopId { get; set; }
[Required]
public int Count { get; set; }
public virtual Shop Shop { get; set; } = new();
public virtual Pizza Pizza { get; set; } = new();
}
}

View File

@ -1,5 +1,4 @@
using Microsoft.EntityFrameworkCore;
using PizzeriaDatabaseImplement.Models;
namespace PizzeriaDatabaseImplement
{
@ -19,5 +18,7 @@ namespace PizzeriaDatabaseImplement
public virtual DbSet<Order> Orders { set; get; }
public virtual DbSet<Client> Clients { set; get; }
public virtual DbSet<Implementer> Implementers { set; get; }
public virtual DbSet<Shop> Shops { set; get; }
public virtual DbSet<ShopPizzas> ShopPizzas { set; get; }
}
}

View File

@ -1,9 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using PizzeriaFileImplement.Models;
using PizzeriaFileImplement.Models;
using System.Xml.Linq;
namespace PizzeriaFileImplement
@ -15,10 +10,12 @@ namespace PizzeriaFileImplement
private readonly string OrderFileName = "Order.xml";
private readonly string PizzaFileName = "Pizza.xml";
private readonly string ClientFileName = "Client.xml";
private readonly string ShopFileName = "Shop.xml";
public List<Component> Components { get; private set; }
public List<Order> Orders { get; private set; }
public List<Pizza> Pizzas { get; private set; }
public List<Client> Clients { get; private set; }
public List<Shop> Shops { get; private set; }
public static DataFileSingleton GetInstance()
{
@ -33,6 +30,7 @@ namespace PizzeriaFileImplement
public void SavePizzas() => SaveData(Pizzas, PizzaFileName, "Pizzas", x => x.GetXElement);
public void SaveOrders() => SaveData(Orders, OrderFileName, "Orders", x => x.GetXElement);
public void SaveClients() => SaveData(Clients, ClientFileName, "Clients", x => x.GetXElement);
public void SaveShops() => SaveData(Shops, ShopFileName, "Shops", x => x.GetXElement);
private DataFileSingleton()
{
@ -40,6 +38,7 @@ namespace PizzeriaFileImplement
Pizzas = LoadData(PizzaFileName, "Pizza", x => Pizza.Create(x)!)!;
Orders = LoadData(OrderFileName, "Order", x => Order.Create(x)!)!;
Clients = LoadData(ClientFileName, "Client", x => Client.Create(x)!)!;
Shops = LoadData(ShopFileName, "Shop", x => Shop.Create(x)!)!;
}
private static List<T>? LoadData<T>(string filename, string xmlNodeName, Func<XElement, T> selectFunction)

View File

@ -0,0 +1,154 @@
using PizzeriaContracts.BindingModels;
using PizzeriaContracts.SearchModels;
using PizzeriaContracts.StoragesContracts;
using PizzeriaContracts.ViewModels;
using PizzeriaFileImplement.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace PizzeriaFileImplement.Implements
{
public class ShopStorage : IShopStorage
{
private readonly DataFileSingleton source;
public ShopStorage()
{
source = DataFileSingleton.GetInstance();
}
public List<ShopViewModel> GetFullList()
{
return source.Shops.Select(x => x.GetViewModel).ToList();
}
public List<ShopViewModel> GetFilteredList(ShopSearchModel model)
{
if (string.IsNullOrEmpty(model.ShopName))
{
return new();
}
return source.Shops.Where(x => x.ShopName.Contains(model.ShopName)).Select(x => x.GetViewModel).ToList();
}
public ShopViewModel? GetElement(ShopSearchModel model)
{
if (string.IsNullOrEmpty(model.ShopName) && !model.Id.HasValue)
{
return null;
}
return source.Shops.FirstOrDefault(x =>
(!string.IsNullOrEmpty(model.ShopName) && x.ShopName == model.ShopName) ||
(model.Id.HasValue && x.Id == model.Id))?.GetViewModel;
}
public ShopViewModel? Insert(ShopBindingModel model)
{
model.Id = source.Shops.Count > 0 ? source.Shops.Max(x => x.Id) + 1 : 1;
var newShop = Shop.Create(model);
if (newShop == null)
{
return null;
}
source.Shops.Add(newShop);
source.SaveShops();
return newShop.GetViewModel;
}
public ShopViewModel? Update(ShopBindingModel model)
{
var shop = source.Shops.FirstOrDefault(x => x.Id == model.Id);
if (shop == null)
{
return null;
}
shop.Update(model);
source.SaveShops();
return shop.GetViewModel;
}
public ShopViewModel? Delete(ShopBindingModel model)
{
var shop = source.Shops.FirstOrDefault(x => x.Id == model.Id);
if (shop != null)
{
source.Shops.Remove(shop);
source.SaveShops();
return shop.GetViewModel;
}
return null;
}
public bool Sale(SupplySearchModel model)
{
if (model == null || !model.PizzaId.HasValue || !model.Count.HasValue)
return false;
int remainingSpace = source.Shops.Select(x => x.Pizzas.ContainsKey(model.PizzaId.Value) ? x.Pizzas[model.PizzaId.Value] : 0).Sum();
if (remainingSpace < model.Count)
{
return false;
}
var shops = source.Shops.Where(x => x.Pizzas.ContainsKey(model.PizzaId.Value)).OrderByDescending(x => x.Pizzas[model.PizzaId.Value]).ToList();
foreach (var shop in shops)
{
int residue = model.Count.Value - shop.Pizzas[model.PizzaId.Value];
if (residue > 0)
{
shop.Pizzas.Remove(model.PizzaId.Value);
shop.PizzasUpdate();
model.Count = residue;
}
else
{
if (residue == 0)
{
shop.Pizzas.Remove(model.PizzaId.Value);
}
else
{
shop.Pizzas[model.PizzaId.Value] = -residue;
}
shop.PizzasUpdate();
source.SaveShops();
return true;
}
}
source.SaveShops();
return false;
}
public bool RestockingShops(SupplyBindingModel model)
{
if (model == null || source.Shops.Select(x => x.PizzaMaxCount - x.ShopPizzas.Select(y => y.Value.Item2).Sum()).Sum() < model.Count)
{
return false;
}
foreach (Shop shop in source.Shops)
{
int free_places = shop.PizzaMaxCount - shop.ShopPizzas.Select(x => x.Value.Item2).Sum();
if (free_places <= 0)
continue;
free_places = Math.Min(free_places, model.Count);
model.Count -= free_places;
if (shop.Pizzas.ContainsKey(model.PizzaId))
{
shop.Pizzas[model.PizzaId] += free_places;
}
else
{
shop.Pizzas.Add(model.PizzaId, free_places);
}
shop.PizzasUpdate();
if (model.Count == 0)
{
source.SaveShops();
return true;
}
}
return false;
}
}
}

View File

@ -0,0 +1,111 @@
using PizzeriaDataModels.Models;
using PizzeriaContracts.BindingModels;
using PizzeriaContracts.ViewModels;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Xml.Linq;
namespace PizzeriaFileImplement.Models
{
public class Shop : IShopModel
{
public int Id { get; private set; }
public string ShopName { get; private set; } = string.Empty;
public string Adress { get; private set; } = string.Empty;
public DateTime OpeningDate { get; private set; }
public Dictionary<int, int> Pizzas { get; private set; } = new();
private Dictionary<int, (IPizzaModel, int)>? _shopPizzas = null;
public Dictionary<int, (IPizzaModel, int)> ShopPizzas
{
get
{
if (_shopPizzas == null)
{
var source = DataFileSingleton.GetInstance();
_shopPizzas = Pizzas.ToDictionary(x => x.Key, y => ((source.Pizzas.FirstOrDefault(z => z.Id == y.Key) as IPizzaModel)!, y.Value));
}
return _shopPizzas;
}
}
public int PizzaMaxCount { get; private set; }
public static Shop? Create(ShopBindingModel? model)
{
if (model == null)
{
return null;
}
return new Shop()
{
Id = model.Id,
ShopName = model.ShopName,
Adress = model.Adress,
OpeningDate = model.OpeningDate,
Pizzas = model.ShopPizzas.ToDictionary(x => x.Key, x => x.Value.Item2),
PizzaMaxCount = model.PizzaMaxCount
};
}
public static Shop? Create(XElement element)
{
if (element == null)
{
return null;
}
return new()
{
Id = Convert.ToInt32(element.Attribute("Id")!.Value),
ShopName = element.Element("ShopName")!.Value,
Adress = element.Element("Adress")!.Value,
OpeningDate = Convert.ToDateTime(element.Element("OpeningDate")!.Value),
Pizzas = element.Element("ShopPizzas")!.Elements("ShopPizza")!.ToDictionary(x => Convert.ToInt32(x.Element("Key")?.Value),
x => Convert.ToInt32(x.Element("Value")?.Value)),
PizzaMaxCount = Convert.ToInt32(element.Element("PizzaMaxCount")!.Value)
};
}
public void Update(ShopBindingModel? model)
{
if (model == null)
{
return;
}
ShopName = model.ShopName;
Adress = model.Adress;
OpeningDate = model.OpeningDate;
PizzaMaxCount = model.PizzaMaxCount;
Pizzas = model.ShopPizzas.ToDictionary(x => x.Key, x => x.Value.Item2);
_shopPizzas = null;
}
public ShopViewModel GetViewModel => new()
{
Id = Id,
ShopName = ShopName,
Adress = Adress,
OpeningDate = OpeningDate,
ShopPizzas = ShopPizzas,
PizzaMaxCount = PizzaMaxCount
};
public XElement GetXElement => new("Shop",
new XAttribute("Id", Id),
new XElement("ShopName", ShopName),
new XElement("Adress", Adress),
new XElement("OpeningDate", OpeningDate.ToString()),
new XElement("ShopPizzas", Pizzas.Select(
x => new XElement("ShopPizza", new XElement("Key", x.Key), new XElement("Value", x.Value))).ToArray()),
new XElement("PizzaMaxCount", PizzaMaxCount.ToString())
);
public void PizzasUpdate()
{
_shopPizzas = null;
}
}
}

View File

@ -14,6 +14,7 @@ namespace PizzeriaListImplement
public List<Order> Orders { get; set; }
public List<Pizza> Pizzas { get; set; }
public List<Client> Clients { get; set; }
public List<Shop> Shops { get; set; }
private DataListSingleton()
{
@ -21,6 +22,7 @@ namespace PizzeriaListImplement
Orders = new List<Order>();
Pizzas = new List<Pizza>();
Clients = new List<Client>();
Shops = new List<Shop>();
}
public static DataListSingleton GetInstance()

View File

@ -0,0 +1,123 @@
using PizzeriaContracts.BindingModels;
using PizzeriaContracts.SearchModels;
using PizzeriaContracts.StoragesContracts;
using PizzeriaContracts.ViewModels;
using PizzeriaListImplement.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace PizzeriaListImplement.Implements
{
public class ShopStorage : IShopStorage
{
private readonly DataListSingleton _source;
public ShopStorage()
{
_source = DataListSingleton.GetInstance();
}
public List<ShopViewModel> GetFullList()
{
var result = new List<ShopViewModel>();
foreach (var shop in _source.Shops)
{
result.Add(shop.GetViewModel);
}
return result;
}
public List<ShopViewModel> GetFilteredList(ShopSearchModel model)
{
var result = new List<ShopViewModel>();
if (string.IsNullOrEmpty(model.ShopName))
{
return result;
}
foreach (var shop in _source.Shops)
{
if (shop.ShopName.Contains(model.ShopName))
{
result.Add(shop.GetViewModel);
}
}
return result;
}
public ShopViewModel? GetElement(ShopSearchModel model)
{
if (string.IsNullOrEmpty(model.ShopName) && !model.Id.HasValue)
{
return null;
}
foreach (var shop in _source.Shops)
{
if ((!string.IsNullOrEmpty(model.ShopName) && shop.ShopName == model.ShopName) ||
(model.Id.HasValue && shop.Id == model.Id))
{
return shop.GetViewModel;
}
}
return null;
}
public ShopViewModel? Insert(ShopBindingModel model)
{
model.Id = 1;
foreach (var shop in _source.Shops)
{
if (model.Id <= shop.Id)
{
model.Id = shop.Id + 1;
}
}
var newShop = Shop.Create(model);
if (newShop == null)
{
return null;
}
_source.Shops.Add(newShop);
return newShop.GetViewModel;
}
public ShopViewModel? Update(ShopBindingModel model)
{
foreach (var shop in _source.Shops)
{
if (shop.Id == model.Id)
{
shop.Update(model);
return shop.GetViewModel;
}
}
return null;
}
public ShopViewModel? Delete(ShopBindingModel model)
{
for (int i = 0; i < _source.Shops.Count; ++i)
{
if (_source.Shops[i].Id == model.Id)
{
var element = _source.Shops[i];
_source.Shops.RemoveAt(i);
return element.GetViewModel;
}
}
return null;
}
public bool Sale(SupplySearchModel model)
{
throw new NotImplementedException();
}
public bool RestockingShops(SupplyBindingModel model)
{
throw new NotImplementedException();
}
}
}

View File

@ -0,0 +1,59 @@
using PizzeriaDataModels.Models;
using PizzeriaContracts.BindingModels;
using PizzeriaContracts.ViewModels;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace PizzeriaListImplement.Models
{
public class Shop : IShopModel
{
public int Id { get; private set; }
public string ShopName { get; private set; } = string.Empty;
public string Adress { get; private set; } = string.Empty;
public DateTime OpeningDate { get; private set; }
public Dictionary<int, (IPizzaModel, int)> ShopPizzas { get; private set; } = new();
public int PizzaMaxCount { get; private set; }
public static Shop? Create(ShopBindingModel? model)
{
if (model == null)
{
return null;
}
return new Shop()
{
Id = model.Id,
ShopName = model.ShopName,
Adress = model.Adress,
OpeningDate = model.OpeningDate,
PizzaMaxCount = model.PizzaMaxCount,
};
}
public void Update(ShopBindingModel? model)
{
if (model == null)
{
return;
}
ShopName = model.ShopName;
Adress = model.Adress;
OpeningDate = model.OpeningDate;
PizzaMaxCount = model.PizzaMaxCount;
}
public ShopViewModel GetViewModel => new()
{
Id = Id,
ShopName = ShopName,
Adress = Adress,
OpeningDate = OpeningDate,
ShopPizzas = ShopPizzas,
PizzaMaxCount = PizzaMaxCount,
};
}
}

View File

@ -0,0 +1,13 @@
namespace PizzeriaRestApi
{
public class APIConfig
{
public static string? ShopPassword;
public static void LoadData(IConfiguration configuration)
{
ShopPassword = configuration["ShopAPIPassword"];
}
}
}

View File

@ -0,0 +1,156 @@
using Microsoft.AspNetCore.Mvc;
using PizzeriaContracts.BindingModels;
using PizzeriaContracts.BusinessLogicsContracts;
using PizzeriaContracts.SearchModels;
using PizzeriaContracts.ViewModels;
namespace PizzeriaRestApi.Controllers
{
[Route("api/[controller]/[action]")]
[ApiController]
public class ShopController : Controller
{
private readonly ILogger _logger;
private readonly IShopLogic _shopLogic;
public ShopController(ILogger<ShopController> logger, IShopLogic shopLogic)
{
_logger = logger;
_shopLogic = shopLogic;
}
[HttpGet]
public bool Authentication(string password)
{
return CheckPassword(password);
}
[HttpGet]
public List<ShopViewModel>? GetShopList(string password)
{
if (!CheckPassword(password))
{
return null;
}
try
{
return _shopLogic.ReadList(null);
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка получения списка магазинов");
throw;
}
}
[HttpGet]
public ShopPizzaViewModel? GetShop(int shopId, string password)
{
if (!CheckPassword(password))
{
return null;
}
try
{
var shop = _shopLogic.ReadElement(new ShopSearchModel { Id = shopId });
return new ShopPizzaViewModel
{
Shop = shop,
ShopPizza = shop.ShopPizzas.ToDictionary(x => x.Key, x => new PizzaCount
{
Pizza = new PizzaViewModel()
{
Id = x.Value.Item1.Id,
PizzaName = x.Value.Item1.PizzaName,
PizzaComponents = x.Value.Item1.PizzaComponents,
Price = x.Value.Item1.Price,
},
Count = x.Value.Item2
})
};
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка получения магазина");
throw;
}
}
[HttpPost]
public void CreateShop(ShopBindingModel model, string password)
{
if (!CheckPassword(password))
{
return;
}
try
{
_shopLogic.Create(model);
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка создания магазина");
throw;
}
}
[HttpPost]
public void UpdateShop(ShopBindingModel model, string password)
{
if (!CheckPassword(password))
{
return;
}
try
{
_shopLogic.Update(model);
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка обновления магазина");
throw;
}
}
[HttpDelete]
public void DeleteShop(int shopId, string password)
{
if (!CheckPassword(password))
{
return;
}
try
{
_shopLogic.Delete(new ShopBindingModel { Id = shopId });
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка удаления магазина");
throw;
}
}
[HttpPost]
public void MakeSypply(SupplyBindingModel model, string password)
{
if (!CheckPassword(password))
{
return;
}
try
{
_shopLogic.MakeSupply(model);
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка создания поставки в магазин");
throw;
}
}
private bool CheckPassword(string password)
{
return APIConfig.ShopPassword == password;
}
}
}

View File

@ -3,6 +3,7 @@ using PizzeriaContracts.BusinessLogicsContracts;
using PizzeriaContracts.StoragesContracts;
using PizzeriaDatabaseImplement.Implements;
using Microsoft.OpenApi.Models;
using PizzeriaRestApi;
var builder = WebApplication.CreateBuilder(args);
@ -14,11 +15,13 @@ builder.Services.AddTransient<IClientStorage, ClientStorage>();
builder.Services.AddTransient<IImplementerStorage, ImplementerStorage>();
builder.Services.AddTransient<IOrderStorage, OrderStorage>();
builder.Services.AddTransient<IPizzaStorage, PizzaStorage>();
builder.Services.AddTransient<IShopStorage, ShopStorage>();
builder.Services.AddTransient<IOrderLogic, OrderLogic>();
builder.Services.AddTransient<IImplementerLogic, ImplementerLogic>();
builder.Services.AddTransient<IClientLogic, ClientLogic>();
builder.Services.AddTransient<IPizzaLogic, PizzaLogic>();
builder.Services.AddTransient<IShopLogic, ShopLogic>();
builder.Services.AddControllers();
// Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle
@ -29,6 +32,7 @@ builder.Services.AddSwaggerGen(c =>
});
var app = builder.Build();
APIConfig.LoadData(builder.Configuration);
// Configure the HTTP request pipeline.
if (app.Environment.IsDevelopment())

View File

@ -5,5 +5,6 @@
"Microsoft.AspNetCore": "Warning"
}
},
"AllowedHosts": "*"
"AllowedHosts": "*",
"ShopAPIPassword": "123456"
}

View File

@ -0,0 +1,59 @@
using Microsoft.AspNetCore.Mvc;
using Newtonsoft.Json;
using System.Net.Http.Headers;
using System.Text;
namespace PizzeriaShopApp
{
public class APIClient
{
private static readonly HttpClient _client = new();
public static string? Password { get; set; }
public static void Connect(IConfiguration configuration)
{
_client.BaseAddress = new Uri(configuration["IPAddress"]);
_client.DefaultRequestHeaders.Accept.Clear();
_client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
}
public static T? GetRequest<T>(string requestUrl)
{
var response = _client.GetAsync(requestUrl);
var result = response.Result.Content.ReadAsStringAsync().Result;
if (response.Result.IsSuccessStatusCode)
{
return JsonConvert.DeserializeObject<T>(result);
}
else
{
throw new Exception(result);
}
}
public static void PostRequest<T>(string requestUrl, T model)
{
var json = JsonConvert.SerializeObject(model);
var data = new StringContent(json, Encoding.UTF8, "application/json");
var response = _client.PostAsync(requestUrl, data);
var result = response.Result.Content.ReadAsStringAsync().Result;
if (!response.Result.IsSuccessStatusCode)
{
throw new Exception(result);
}
}
public static void DeleteRequest(string requestUrl)
{
var response = _client.DeleteAsync(requestUrl);
var result = response.Result.Content.ReadAsStringAsync().Result;
if (!response.Result.IsSuccessStatusCode)
{
throw new Exception(result);
}
}
}
}

View File

@ -0,0 +1,149 @@
using Microsoft.AspNetCore.Mvc;
using PizzeriaContracts.BindingModels;
using PizzeriaContracts.ViewModels;
using PizzeriaShopApp.Models;
using System.Diagnostics;
namespace PizzeriaShopApp.Controllers
{
public class HomeController : Controller
{
private readonly ILogger<HomeController> _logger;
public HomeController(ILogger<HomeController> logger)
{
_logger = logger;
}
public IActionResult Index()
{
if (APIClient.Password == null)
{
return Redirect("~/Home/Enter");
}
return View(APIClient.GetRequest<List<ShopViewModel>>($"api/shop/getshoplist?password={APIClient.Password}"));
}
[HttpGet]
public IActionResult Enter()
{
return View();
}
[HttpPost]
public void Enter(string password)
{
bool resout = APIClient.GetRequest<bool>($"/api/shop/authentication?password={password}");
if (!resout)
{
Response.Redirect("../Home/Enter");
return;
}
APIClient.Password = password;
Response.Redirect("Index");
}
[HttpGet]
public IActionResult Create()
{
if (APIClient.Password == null)
{
return Redirect("~/Home/Enter");
}
return View("Shop");
}
[HttpPost]
public void Create(int id, string shopname, string adress, DateTime openingdate, int maxcount)
{
if (string.IsNullOrEmpty(shopname) || string.IsNullOrEmpty(adress))
{
throw new Exception("Название или адрес не может быть пустым");
}
if (openingdate == default(DateTime))
{
throw new Exception("Дата открытия не может быть пустой");
}
APIClient.PostRequest($"api/shop/createshop?password={APIClient.Password}", new ShopBindingModel
{
Id = id,
ShopName = shopname,
Adress = adress,
OpeningDate = openingdate,
PizzaMaxCount = maxcount
});
Response.Redirect("Index");
}
[HttpGet]
public IActionResult Update(int Id)
{
if (APIClient.Password == null)
{
return Redirect("~/Home/Enter");
}
return View("Shop", APIClient.GetRequest<ShopPizzaViewModel>($"api/shop/getshop?shopId={Id}&password={APIClient.Password}"));
}
[HttpPost]
public void Update(int id, string shopname, string adress, DateTime openingdate, int maxcount)
{
if (string.IsNullOrEmpty(shopname) || string.IsNullOrEmpty(adress))
{
throw new Exception("Название или адрес не может быть пустым");
}
if (openingdate == default(DateTime))
{
throw new Exception("Дата открытия не может быть пустой");
}
APIClient.PostRequest($"api/shop/updateshop?password={APIClient.Password}", new ShopBindingModel
{
Id = id,
ShopName = shopname,
Adress = adress,
OpeningDate = openingdate,
PizzaMaxCount = maxcount
});
Response.Redirect("../Index");
}
[HttpPost]
public void Delete(int Id)
{
APIClient.DeleteRequest($"api/shop/deleteshop?shopId={Id}&password={APIClient.Password}");
Response.Redirect("../Index");
}
[HttpGet]
public IActionResult Supply()
{
if (APIClient.Password == null)
{
return Redirect("~/Home/Enter");
}
ViewBag.Shops = APIClient.GetRequest<List<ShopViewModel>>($"api/shop/getshoplist?password={APIClient.Password}");
ViewBag.Pizzas = APIClient.GetRequest<List<PizzaViewModel>>($"api/main/getpizzalist");
return View();
}
[HttpPost]
public void Supply(int shop, int pizza, int count)
{
APIClient.PostRequest($"api/shop/makesypply?password={APIClient.Password}", new SupplyBindingModel
{
ShopId = shop,
PizzaId = pizza,
Count = count
});
Response.Redirect("Index");
}
[ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)]
public IActionResult Error()
{
return View(new ErrorViewModel { RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier });
}
}
}

View File

@ -0,0 +1,9 @@
namespace PizzeriaShopApp.Models
{
public class ErrorViewModel
{
public string? RequestId { get; set; }
public bool ShowRequestId => !string.IsNullOrEmpty(RequestId);
}
}

View File

@ -0,0 +1,18 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\PizzeriaContracts\PizzeriaContracts.csproj" />
<ProjectReference Include="..\PizzeriaDataModels\PizzeriaDataModels.csproj" />
</ItemGroup>
</Project>

View File

@ -0,0 +1,30 @@
using PizzeriaShopApp;
var builder = WebApplication.CreateBuilder(args);
// Add services to the container.
builder.Services.AddControllersWithViews();
var app = builder.Build();
APIClient.Connect(builder.Configuration);
// Configure the HTTP request pipeline.
if (!app.Environment.IsDevelopment())
{
app.UseExceptionHandler("/Home/Error");
// The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts.
app.UseHsts();
}
app.UseHttpsRedirection();
app.UseStaticFiles();
app.UseRouting();
app.UseAuthorization();
app.MapControllerRoute(
name: "default",
pattern: "{controller=Home}/{action=Index}/{id?}");
app.Run();

View File

@ -0,0 +1,28 @@
{
"iisSettings": {
"windowsAuthentication": false,
"anonymousAuthentication": true,
"iisExpress": {
"applicationUrl": "http://localhost:9856",
"sslPort": 44377
}
},
"profiles": {
"PizzeriaShopApp": {
"commandName": "Project",
"dotnetRunMessages": true,
"launchBrowser": true,
"applicationUrl": "https://localhost:7002;http://localhost:5279",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
},
"IIS Express": {
"commandName": "IISExpress",
"launchBrowser": true,
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
}
}
}

View File

@ -0,0 +1,15 @@
@{
ViewData["Title"] = "Enter";
}
<div class="text-center">
<h2 class="display-4">Вход в систему</h2>
</div>
<form method="post">
<div class="mb-3">
<label class="form-label">Пароль</label>
<input class="form-control" type="password" name="password">
</div>
<input type="submit" value="Вход" class="btn btn-primary" />
</form>

View File

@ -0,0 +1,68 @@
@using PizzeriaContracts.ViewModels
@model List<ShopViewModel>
@{
ViewData["Title"] = "Home Page";
}
<div class="text-center">
<h1 class="display-4">Магазины</h1>
</div>
<div class="text-center ">
<p>
<a asp-action="Create">Создать магазин</a>
</p>
<table class="table">
<thead>
<tr>
<th>
Номер
</th>
<th>
Название
</th>
<th>
Адрес
</th>
<th>
Дата открытия
</th>
<th>
Максимальная вместимость
</th>
<th>
</th>
</tr>
</thead>
<tbody>
@foreach (var item in Model)
{
<tr>
<td>
@Html.DisplayFor(modelItem => item.Id)
</td>
<td>
@Html.DisplayFor(modelItem => item.ShopName)
</td>
<td>
@Html.DisplayFor(modelItem => item.Adress)
</td>
<td>
@Html.DisplayFor(modelItem => item.OpeningDate)
</td>
<td>
@Html.DisplayFor(modelItem => item.PizzaMaxCount)
</td>
<td>
<a class="btn btn-primary" asp-action="Update" asp-route-Id="@(item.Id)" role="button">Изменить</a>
</td>
</tr>
}
</tbody>
</table>
</div>

View File

@ -0,0 +1,75 @@
@using PizzeriaDataModels.Models;
@using PizzeriaContracts.ViewModels;
@model ShopPizzaViewModel
@{
ViewData["Title"] = "Shop";
}
<div class="text-center">
@{
if (Model == null)
{
<h2 class="display-4">Создание магазина</h2>
}
else
{
<h2 class="display-4">Изменение магазина</h2>
}
}
</div>
<form method="post">
<div class="mb-3">
<label class="form-label">Название</label>
<input type="text" class="form-control" name="shopname" id="shopname" value="@(Model==null ? "" : Model.Shop?.ShopName)" />
</div>
<div class="mb-3">
<label class="form-label">Адрес</label>
<input type="text" class="form-control" name="adress" id="adress" value="@(Model==null ? "" : Model.Shop?.Adress)" />
</div>
<div class="mb-3">
<label for="startDate">Дата открытия</label>
<input class="form-control" type="date" name="openingdate" id="openingdate" value="@(Model==null ? "" : Model.Shop?.OpeningDate.ToString("yyyy-MM-dd"))" />
</div>
<div class="mb-3">
<label class="form-label">Вместимость</label>
<input type="number" min="0" step="1" pattern="[0-9]" class="form-control" name="maxcount" id="maxcount" value="@(Model==null ? "" : Model.Shop?.PizzaMaxCount)" />
</div>
<div class="mb-3 ">
<input class="btn btn-primary" type="submit" value="Сохранить">
@{
if (Model != null && Model.Shop != null)
{
<input class="btn btn-danger" asp-action="Delete" type="submit" value="Удалить" asp-route-Id="@(Model==null ? 0 : Model.Shop.Id.ToString())">
}
}
</div>
</form>
@{
if (Model != null && Model.Shop != null)
{
<div>
<h6>Содержимое магазина</h6>
</div>
<table class="table">
<thead>
<tr>
<th>Название</th>
<th>Количество</th>
</tr>
</thead>
<tbody>
@foreach (var item in Model.ShopPizza)
{
<tr>
<td>@Html.DisplayFor(modelItem => item.Value.Pizza.PizzaName)</td>
<td>@Html.DisplayFor(modelItem => item.Value.Count)</td>
</tr>
}
</tbody>
</table>
}
}

View File

@ -0,0 +1,22 @@
@{
ViewData["Title"] = "Supply";
}
<div class="text-center">
<h2 class="display-4">Создание поставки</h2>
</div>
<form method="post">
<div class="mb-3">
<label class="form-label">Магазин</label>
<select class="form-select form-select-lg" id="shop" name="shop" asp-items="@(new SelectList(@ViewBag.Shops,"Id", "ShopName"))"></select>
</div>
<div class="mb-3">
<label class="form-label">Пицца</label>
<select class="form-select form-select-lg" id="pizza" name="pizza" asp-items="@(new SelectList(@ViewBag.Pizzas,"Id", "PizzaName"))"></select>
</div>
<div class="mb-3">
<label class="form-label">Колличество</label>
<input type="number" min="0" step="1" pattern="[0-9]" class="form-control" name="count" id="count">
</div>
<input class="btn btn-success" type="submit" value="Создать поставку">
<a class="btn btn-primary" href="./Index" role="button">Отмена</a>
</form>

View File

@ -0,0 +1,25 @@
@model ErrorViewModel
@{
ViewData["Title"] = "Error";
}
<h1 class="text-danger">Error.</h1>
<h2 class="text-danger">An error occurred while processing your request.</h2>
@if (Model.ShowRequestId)
{
<p>
<strong>Request ID:</strong> <code>@Model.RequestId</code>
</p>
}
<h3>Development Mode</h3>
<p>
Swapping to <strong>Development</strong> environment will display more detailed information about the error that occurred.
</p>
<p>
<strong>The Development environment shouldn't be enabled for deployed applications.</strong>
It can result in displaying sensitive information from exceptions to end users.
For local debugging, enable the <strong>Development</strong> environment by setting the <strong>ASPNETCORE_ENVIRONMENT</strong> environment variable to <strong>Development</strong>
and restarting the app.
</p>

View File

@ -0,0 +1,49 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>@ViewData["Title"] - PizzeriaShopApp</title>
<link rel="stylesheet" href="~/lib/bootstrap/dist/css/bootstrap.min.css" />
<link rel="stylesheet" href="~/css/site.css" asp-append-version="true" />
<link rel="stylesheet" href="~/PizzeriaShopApp.styles.css" asp-append-version="true" />
</head>
<body>
<header>
<nav class="navbar navbar-expand-sm navbar-toggleable-sm navbar-light bg-white border-bottom box-shadow mb-3">
<div class="container-fluid">
<a class="navbar-brand" asp-area="" asp-controller="Home" asp-action="Index">PizzeriaShopsApi</a>
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target=".navbar-collapse" aria-controls="navbarSupportedContent"
aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="navbar-collapse collapse d-sm-inline-flex justify-content-between">
<ul class="navbar-nav flex-grow-1">
<li class="nav-item">
<a class="nav-link text-dark" asp-area="" asp-controller="Home" asp-action="Index">Главная</a>
</li>
<li class="nav-item">
<a class="nav-link text-dark" asp-area="" asp-controller="Home" asp-action="Supply">Поставка</a>
</li>
</ul>
</div>
</div>
</nav>
</header>
<div class="container">
<main role="main" class="pb-3">
@RenderBody()
</main>
</div>
<footer class="border-top footer text-muted">
<div class="container">
&copy; 2024 - PizzeriaShopApp - <a asp-area="" asp-controller="Home" asp-action="Index">Главная</a>
</div>
</footer>
<script src="~/lib/jquery/dist/jquery.min.js"></script>
<script src="~/lib/bootstrap/dist/js/bootstrap.bundle.min.js"></script>
<script src="~/js/site.js" asp-append-version="true"></script>
@await RenderSectionAsync("Scripts", required: false)
</body>
</html>

View File

@ -0,0 +1,48 @@
/* Please see documentation at https://docs.microsoft.com/aspnet/core/client-side/bundling-and-minification
for details on configuring this project to bundle and minify static web assets. */
a.navbar-brand {
white-space: normal;
text-align: center;
word-break: break-all;
}
a {
color: #0077cc;
}
.btn-primary {
color: #fff;
background-color: #1b6ec2;
border-color: #1861ac;
}
.nav-pills .nav-link.active, .nav-pills .show > .nav-link {
color: #fff;
background-color: #1b6ec2;
border-color: #1861ac;
}
.border-top {
border-top: 1px solid #e5e5e5;
}
.border-bottom {
border-bottom: 1px solid #e5e5e5;
}
.box-shadow {
box-shadow: 0 .25rem .75rem rgba(0, 0, 0, .05);
}
button.accept-policy {
font-size: 1rem;
line-height: inherit;
}
.footer {
position: absolute;
bottom: 0;
width: 100%;
white-space: nowrap;
line-height: 60px;
}

View File

@ -0,0 +1,2 @@
<script src="~/lib/jquery-validation/dist/jquery.validate.min.js"></script>
<script src="~/lib/jquery-validation-unobtrusive/jquery.validate.unobtrusive.min.js"></script>

View File

@ -0,0 +1,3 @@
@using PizzeriaShopApp
@using PizzeriaShopApp.Models
@addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers

View File

@ -0,0 +1,3 @@
@{
Layout = "_Layout";
}

View File

@ -0,0 +1,8 @@
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
}
}
}

View File

@ -0,0 +1,10 @@
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
}
},
"AllowedHosts": "*",
"IPAddress": "http://localhost:5175/"
}

View File

@ -0,0 +1,18 @@
html {
font-size: 14px;
}
@media (min-width: 768px) {
html {
font-size: 16px;
}
}
html {
position: relative;
min-height: 100%;
}
body {
margin-bottom: 60px;
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.3 KiB

View File

@ -0,0 +1,4 @@
// Please see documentation at https://docs.microsoft.com/aspnet/core/client-side/bundling-and-minification
// for details on configuring this project to bundle and minify static web assets.
// Write your JavaScript code.

View File

@ -0,0 +1,22 @@
The MIT License (MIT)
Copyright (c) 2011-2021 Twitter, Inc.
Copyright (c) 2011-2021 The Bootstrap Authors
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,427 @@
/*!
* Bootstrap Reboot v5.1.0 (https://getbootstrap.com/)
* Copyright 2011-2021 The Bootstrap Authors
* Copyright 2011-2021 Twitter, Inc.
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
* Forked from Normalize.css, licensed MIT (https://github.com/necolas/normalize.css/blob/master/LICENSE.md)
*/
*,
*::before,
*::after {
box-sizing: border-box;
}
@media (prefers-reduced-motion: no-preference) {
:root {
scroll-behavior: smooth;
}
}
body {
margin: 0;
font-family: var(--bs-body-font-family);
font-size: var(--bs-body-font-size);
font-weight: var(--bs-body-font-weight);
line-height: var(--bs-body-line-height);
color: var(--bs-body-color);
text-align: var(--bs-body-text-align);
background-color: var(--bs-body-bg);
-webkit-text-size-adjust: 100%;
-webkit-tap-highlight-color: rgba(0, 0, 0, 0);
}
hr {
margin: 1rem 0;
color: inherit;
background-color: currentColor;
border: 0;
opacity: 0.25;
}
hr:not([size]) {
height: 1px;
}
h6, h5, h4, h3, h2, h1 {
margin-top: 0;
margin-bottom: 0.5rem;
font-weight: 500;
line-height: 1.2;
}
h1 {
font-size: calc(1.375rem + 1.5vw);
}
@media (min-width: 1200px) {
h1 {
font-size: 2.5rem;
}
}
h2 {
font-size: calc(1.325rem + 0.9vw);
}
@media (min-width: 1200px) {
h2 {
font-size: 2rem;
}
}
h3 {
font-size: calc(1.3rem + 0.6vw);
}
@media (min-width: 1200px) {
h3 {
font-size: 1.75rem;
}
}
h4 {
font-size: calc(1.275rem + 0.3vw);
}
@media (min-width: 1200px) {
h4 {
font-size: 1.5rem;
}
}
h5 {
font-size: 1.25rem;
}
h6 {
font-size: 1rem;
}
p {
margin-top: 0;
margin-bottom: 1rem;
}
abbr[title],
abbr[data-bs-original-title] {
-webkit-text-decoration: underline dotted;
text-decoration: underline dotted;
cursor: help;
-webkit-text-decoration-skip-ink: none;
text-decoration-skip-ink: none;
}
address {
margin-bottom: 1rem;
font-style: normal;
line-height: inherit;
}
ol,
ul {
padding-left: 2rem;
}
ol,
ul,
dl {
margin-top: 0;
margin-bottom: 1rem;
}
ol ol,
ul ul,
ol ul,
ul ol {
margin-bottom: 0;
}
dt {
font-weight: 700;
}
dd {
margin-bottom: 0.5rem;
margin-left: 0;
}
blockquote {
margin: 0 0 1rem;
}
b,
strong {
font-weight: bolder;
}
small {
font-size: 0.875em;
}
mark {
padding: 0.2em;
background-color: #fcf8e3;
}
sub,
sup {
position: relative;
font-size: 0.75em;
line-height: 0;
vertical-align: baseline;
}
sub {
bottom: -0.25em;
}
sup {
top: -0.5em;
}
a {
color: #0d6efd;
text-decoration: underline;
}
a:hover {
color: #0a58ca;
}
a:not([href]):not([class]), a:not([href]):not([class]):hover {
color: inherit;
text-decoration: none;
}
pre,
code,
kbd,
samp {
font-family: SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
font-size: 1em;
direction: ltr /* rtl:ignore */;
unicode-bidi: bidi-override;
}
pre {
display: block;
margin-top: 0;
margin-bottom: 1rem;
overflow: auto;
font-size: 0.875em;
}
pre code {
font-size: inherit;
color: inherit;
word-break: normal;
}
code {
font-size: 0.875em;
color: #d63384;
word-wrap: break-word;
}
a > code {
color: inherit;
}
kbd {
padding: 0.2rem 0.4rem;
font-size: 0.875em;
color: #fff;
background-color: #212529;
border-radius: 0.2rem;
}
kbd kbd {
padding: 0;
font-size: 1em;
font-weight: 700;
}
figure {
margin: 0 0 1rem;
}
img,
svg {
vertical-align: middle;
}
table {
caption-side: bottom;
border-collapse: collapse;
}
caption {
padding-top: 0.5rem;
padding-bottom: 0.5rem;
color: #6c757d;
text-align: left;
}
th {
text-align: inherit;
text-align: -webkit-match-parent;
}
thead,
tbody,
tfoot,
tr,
td,
th {
border-color: inherit;
border-style: solid;
border-width: 0;
}
label {
display: inline-block;
}
button {
border-radius: 0;
}
button:focus:not(:focus-visible) {
outline: 0;
}
input,
button,
select,
optgroup,
textarea {
margin: 0;
font-family: inherit;
font-size: inherit;
line-height: inherit;
}
button,
select {
text-transform: none;
}
[role=button] {
cursor: pointer;
}
select {
word-wrap: normal;
}
select:disabled {
opacity: 1;
}
[list]::-webkit-calendar-picker-indicator {
display: none;
}
button,
[type=button],
[type=reset],
[type=submit] {
-webkit-appearance: button;
}
button:not(:disabled),
[type=button]:not(:disabled),
[type=reset]:not(:disabled),
[type=submit]:not(:disabled) {
cursor: pointer;
}
::-moz-focus-inner {
padding: 0;
border-style: none;
}
textarea {
resize: vertical;
}
fieldset {
min-width: 0;
padding: 0;
margin: 0;
border: 0;
}
legend {
float: left;
width: 100%;
padding: 0;
margin-bottom: 0.5rem;
font-size: calc(1.275rem + 0.3vw);
line-height: inherit;
}
@media (min-width: 1200px) {
legend {
font-size: 1.5rem;
}
}
legend + * {
clear: left;
}
::-webkit-datetime-edit-fields-wrapper,
::-webkit-datetime-edit-text,
::-webkit-datetime-edit-minute,
::-webkit-datetime-edit-hour-field,
::-webkit-datetime-edit-day-field,
::-webkit-datetime-edit-month-field,
::-webkit-datetime-edit-year-field {
padding: 0;
}
::-webkit-inner-spin-button {
height: auto;
}
[type=search] {
outline-offset: -2px;
-webkit-appearance: textfield;
}
/* rtl:raw:
[type="tel"],
[type="url"],
[type="email"],
[type="number"] {
direction: ltr;
}
*/
::-webkit-search-decoration {
-webkit-appearance: none;
}
::-webkit-color-swatch-wrapper {
padding: 0;
}
::file-selector-button {
font: inherit;
}
::-webkit-file-upload-button {
font: inherit;
-webkit-appearance: button;
}
output {
display: inline-block;
}
iframe {
border: 0;
}
summary {
display: list-item;
cursor: pointer;
}
progress {
vertical-align: baseline;
}
[hidden] {
display: none !important;
}
/*# sourceMappingURL=bootstrap-reboot.css.map */

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,8 @@
/*!
* Bootstrap Reboot v5.1.0 (https://getbootstrap.com/)
* Copyright 2011-2021 The Bootstrap Authors
* Copyright 2011-2021 Twitter, Inc.
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
* Forked from Normalize.css, licensed MIT (https://github.com/necolas/normalize.css/blob/master/LICENSE.md)
*/*,::after,::before{box-sizing:border-box}@media (prefers-reduced-motion:no-preference){:root{scroll-behavior:smooth}}body{margin:0;font-family:var(--bs-body-font-family);font-size:var(--bs-body-font-size);font-weight:var(--bs-body-font-weight);line-height:var(--bs-body-line-height);color:var(--bs-body-color);text-align:var(--bs-body-text-align);background-color:var(--bs-body-bg);-webkit-text-size-adjust:100%;-webkit-tap-highlight-color:transparent}hr{margin:1rem 0;color:inherit;background-color:currentColor;border:0;opacity:.25}hr:not([size]){height:1px}h1,h2,h3,h4,h5,h6{margin-top:0;margin-bottom:.5rem;font-weight:500;line-height:1.2}h1{font-size:calc(1.375rem + 1.5vw)}@media (min-width:1200px){h1{font-size:2.5rem}}h2{font-size:calc(1.325rem + .9vw)}@media (min-width:1200px){h2{font-size:2rem}}h3{font-size:calc(1.3rem + .6vw)}@media (min-width:1200px){h3{font-size:1.75rem}}h4{font-size:calc(1.275rem + .3vw)}@media (min-width:1200px){h4{font-size:1.5rem}}h5{font-size:1.25rem}h6{font-size:1rem}p{margin-top:0;margin-bottom:1rem}abbr[data-bs-original-title],abbr[title]{-webkit-text-decoration:underline dotted;text-decoration:underline dotted;cursor:help;-webkit-text-decoration-skip-ink:none;text-decoration-skip-ink:none}address{margin-bottom:1rem;font-style:normal;line-height:inherit}ol,ul{padding-left:2rem}dl,ol,ul{margin-top:0;margin-bottom:1rem}ol ol,ol ul,ul ol,ul ul{margin-bottom:0}dt{font-weight:700}dd{margin-bottom:.5rem;margin-left:0}blockquote{margin:0 0 1rem}b,strong{font-weight:bolder}small{font-size:.875em}mark{padding:.2em;background-color:#fcf8e3}sub,sup{position:relative;font-size:.75em;line-height:0;vertical-align:baseline}sub{bottom:-.25em}sup{top:-.5em}a{color:#0d6efd;text-decoration:underline}a:hover{color:#0a58ca}a:not([href]):not([class]),a:not([href]):not([class]):hover{color:inherit;text-decoration:none}code,kbd,pre,samp{font-family:SFMono-Regular,Menlo,Monaco,Consolas,"Liberation Mono","Courier New",monospace;font-size:1em;direction:ltr;unicode-bidi:bidi-override}pre{display:block;margin-top:0;margin-bottom:1rem;overflow:auto;font-size:.875em}pre code{font-size:inherit;color:inherit;word-break:normal}code{font-size:.875em;color:#d63384;word-wrap:break-word}a>code{color:inherit}kbd{padding:.2rem .4rem;font-size:.875em;color:#fff;background-color:#212529;border-radius:.2rem}kbd kbd{padding:0;font-size:1em;font-weight:700}figure{margin:0 0 1rem}img,svg{vertical-align:middle}table{caption-side:bottom;border-collapse:collapse}caption{padding-top:.5rem;padding-bottom:.5rem;color:#6c757d;text-align:left}th{text-align:inherit;text-align:-webkit-match-parent}tbody,td,tfoot,th,thead,tr{border-color:inherit;border-style:solid;border-width:0}label{display:inline-block}button{border-radius:0}button:focus:not(:focus-visible){outline:0}button,input,optgroup,select,textarea{margin:0;font-family:inherit;font-size:inherit;line-height:inherit}button,select{text-transform:none}[role=button]{cursor:pointer}select{word-wrap:normal}select:disabled{opacity:1}[list]::-webkit-calendar-picker-indicator{display:none}[type=button],[type=reset],[type=submit],button{-webkit-appearance:button}[type=button]:not(:disabled),[type=reset]:not(:disabled),[type=submit]:not(:disabled),button:not(:disabled){cursor:pointer}::-moz-focus-inner{padding:0;border-style:none}textarea{resize:vertical}fieldset{min-width:0;padding:0;margin:0;border:0}legend{float:left;width:100%;padding:0;margin-bottom:.5rem;font-size:calc(1.275rem + .3vw);line-height:inherit}@media (min-width:1200px){legend{font-size:1.5rem}}legend+*{clear:left}::-webkit-datetime-edit-day-field,::-webkit-datetime-edit-fields-wrapper,::-webkit-datetime-edit-hour-field,::-webkit-datetime-edit-minute,::-webkit-datetime-edit-month-field,::-webkit-datetime-edit-text,::-webkit-datetime-edit-year-field{padding:0}::-webkit-inner-spin-button{height:auto}[type=search]{outline-offset:-2px;-webkit-appearance:textfield}::-webkit-search-decoration{-webkit-appearance:none}::-webkit-color-swatch-wrapper{padding:0}::file-selector-button{font:inherit}::-webkit-file-upload-button{font:inherit;-webkit-appearance:button}output{display:inline-block}iframe{border:0}summary{display:list-item;cursor:pointer}progress{vertical-align:baseline}[hidden]{display:none!important}
/*# sourceMappingURL=bootstrap-reboot.min.css.map */

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,424 @@
/*!
* Bootstrap Reboot v5.1.0 (https://getbootstrap.com/)
* Copyright 2011-2021 The Bootstrap Authors
* Copyright 2011-2021 Twitter, Inc.
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
* Forked from Normalize.css, licensed MIT (https://github.com/necolas/normalize.css/blob/master/LICENSE.md)
*/
*,
*::before,
*::after {
box-sizing: border-box;
}
@media (prefers-reduced-motion: no-preference) {
:root {
scroll-behavior: smooth;
}
}
body {
margin: 0;
font-family: var(--bs-body-font-family);
font-size: var(--bs-body-font-size);
font-weight: var(--bs-body-font-weight);
line-height: var(--bs-body-line-height);
color: var(--bs-body-color);
text-align: var(--bs-body-text-align);
background-color: var(--bs-body-bg);
-webkit-text-size-adjust: 100%;
-webkit-tap-highlight-color: rgba(0, 0, 0, 0);
}
hr {
margin: 1rem 0;
color: inherit;
background-color: currentColor;
border: 0;
opacity: 0.25;
}
hr:not([size]) {
height: 1px;
}
h6, h5, h4, h3, h2, h1 {
margin-top: 0;
margin-bottom: 0.5rem;
font-weight: 500;
line-height: 1.2;
}
h1 {
font-size: calc(1.375rem + 1.5vw);
}
@media (min-width: 1200px) {
h1 {
font-size: 2.5rem;
}
}
h2 {
font-size: calc(1.325rem + 0.9vw);
}
@media (min-width: 1200px) {
h2 {
font-size: 2rem;
}
}
h3 {
font-size: calc(1.3rem + 0.6vw);
}
@media (min-width: 1200px) {
h3 {
font-size: 1.75rem;
}
}
h4 {
font-size: calc(1.275rem + 0.3vw);
}
@media (min-width: 1200px) {
h4 {
font-size: 1.5rem;
}
}
h5 {
font-size: 1.25rem;
}
h6 {
font-size: 1rem;
}
p {
margin-top: 0;
margin-bottom: 1rem;
}
abbr[title],
abbr[data-bs-original-title] {
-webkit-text-decoration: underline dotted;
text-decoration: underline dotted;
cursor: help;
-webkit-text-decoration-skip-ink: none;
text-decoration-skip-ink: none;
}
address {
margin-bottom: 1rem;
font-style: normal;
line-height: inherit;
}
ol,
ul {
padding-right: 2rem;
}
ol,
ul,
dl {
margin-top: 0;
margin-bottom: 1rem;
}
ol ol,
ul ul,
ol ul,
ul ol {
margin-bottom: 0;
}
dt {
font-weight: 700;
}
dd {
margin-bottom: 0.5rem;
margin-right: 0;
}
blockquote {
margin: 0 0 1rem;
}
b,
strong {
font-weight: bolder;
}
small {
font-size: 0.875em;
}
mark {
padding: 0.2em;
background-color: #fcf8e3;
}
sub,
sup {
position: relative;
font-size: 0.75em;
line-height: 0;
vertical-align: baseline;
}
sub {
bottom: -0.25em;
}
sup {
top: -0.5em;
}
a {
color: #0d6efd;
text-decoration: underline;
}
a:hover {
color: #0a58ca;
}
a:not([href]):not([class]), a:not([href]):not([class]):hover {
color: inherit;
text-decoration: none;
}
pre,
code,
kbd,
samp {
font-family: SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
font-size: 1em;
direction: ltr ;
unicode-bidi: bidi-override;
}
pre {
display: block;
margin-top: 0;
margin-bottom: 1rem;
overflow: auto;
font-size: 0.875em;
}
pre code {
font-size: inherit;
color: inherit;
word-break: normal;
}
code {
font-size: 0.875em;
color: #d63384;
word-wrap: break-word;
}
a > code {
color: inherit;
}
kbd {
padding: 0.2rem 0.4rem;
font-size: 0.875em;
color: #fff;
background-color: #212529;
border-radius: 0.2rem;
}
kbd kbd {
padding: 0;
font-size: 1em;
font-weight: 700;
}
figure {
margin: 0 0 1rem;
}
img,
svg {
vertical-align: middle;
}
table {
caption-side: bottom;
border-collapse: collapse;
}
caption {
padding-top: 0.5rem;
padding-bottom: 0.5rem;
color: #6c757d;
text-align: right;
}
th {
text-align: inherit;
text-align: -webkit-match-parent;
}
thead,
tbody,
tfoot,
tr,
td,
th {
border-color: inherit;
border-style: solid;
border-width: 0;
}
label {
display: inline-block;
}
button {
border-radius: 0;
}
button:focus:not(:focus-visible) {
outline: 0;
}
input,
button,
select,
optgroup,
textarea {
margin: 0;
font-family: inherit;
font-size: inherit;
line-height: inherit;
}
button,
select {
text-transform: none;
}
[role=button] {
cursor: pointer;
}
select {
word-wrap: normal;
}
select:disabled {
opacity: 1;
}
[list]::-webkit-calendar-picker-indicator {
display: none;
}
button,
[type=button],
[type=reset],
[type=submit] {
-webkit-appearance: button;
}
button:not(:disabled),
[type=button]:not(:disabled),
[type=reset]:not(:disabled),
[type=submit]:not(:disabled) {
cursor: pointer;
}
::-moz-focus-inner {
padding: 0;
border-style: none;
}
textarea {
resize: vertical;
}
fieldset {
min-width: 0;
padding: 0;
margin: 0;
border: 0;
}
legend {
float: right;
width: 100%;
padding: 0;
margin-bottom: 0.5rem;
font-size: calc(1.275rem + 0.3vw);
line-height: inherit;
}
@media (min-width: 1200px) {
legend {
font-size: 1.5rem;
}
}
legend + * {
clear: right;
}
::-webkit-datetime-edit-fields-wrapper,
::-webkit-datetime-edit-text,
::-webkit-datetime-edit-minute,
::-webkit-datetime-edit-hour-field,
::-webkit-datetime-edit-day-field,
::-webkit-datetime-edit-month-field,
::-webkit-datetime-edit-year-field {
padding: 0;
}
::-webkit-inner-spin-button {
height: auto;
}
[type=search] {
outline-offset: -2px;
-webkit-appearance: textfield;
}
[type="tel"],
[type="url"],
[type="email"],
[type="number"] {
direction: ltr;
}
::-webkit-search-decoration {
-webkit-appearance: none;
}
::-webkit-color-swatch-wrapper {
padding: 0;
}
::file-selector-button {
font: inherit;
}
::-webkit-file-upload-button {
font: inherit;
-webkit-appearance: button;
}
output {
display: inline-block;
}
iframe {
border: 0;
}
summary {
display: list-item;
cursor: pointer;
}
progress {
vertical-align: baseline;
}
[hidden] {
display: none !important;
}
/*# sourceMappingURL=bootstrap-reboot.rtl.css.map */

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,8 @@
/*!
* Bootstrap Reboot v5.1.0 (https://getbootstrap.com/)
* Copyright 2011-2021 The Bootstrap Authors
* Copyright 2011-2021 Twitter, Inc.
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
* Forked from Normalize.css, licensed MIT (https://github.com/necolas/normalize.css/blob/master/LICENSE.md)
*/*,::after,::before{box-sizing:border-box}@media (prefers-reduced-motion:no-preference){:root{scroll-behavior:smooth}}body{margin:0;font-family:var(--bs-body-font-family);font-size:var(--bs-body-font-size);font-weight:var(--bs-body-font-weight);line-height:var(--bs-body-line-height);color:var(--bs-body-color);text-align:var(--bs-body-text-align);background-color:var(--bs-body-bg);-webkit-text-size-adjust:100%;-webkit-tap-highlight-color:transparent}hr{margin:1rem 0;color:inherit;background-color:currentColor;border:0;opacity:.25}hr:not([size]){height:1px}h1,h2,h3,h4,h5,h6{margin-top:0;margin-bottom:.5rem;font-weight:500;line-height:1.2}h1{font-size:calc(1.375rem + 1.5vw)}@media (min-width:1200px){h1{font-size:2.5rem}}h2{font-size:calc(1.325rem + .9vw)}@media (min-width:1200px){h2{font-size:2rem}}h3{font-size:calc(1.3rem + .6vw)}@media (min-width:1200px){h3{font-size:1.75rem}}h4{font-size:calc(1.275rem + .3vw)}@media (min-width:1200px){h4{font-size:1.5rem}}h5{font-size:1.25rem}h6{font-size:1rem}p{margin-top:0;margin-bottom:1rem}abbr[data-bs-original-title],abbr[title]{-webkit-text-decoration:underline dotted;text-decoration:underline dotted;cursor:help;-webkit-text-decoration-skip-ink:none;text-decoration-skip-ink:none}address{margin-bottom:1rem;font-style:normal;line-height:inherit}ol,ul{padding-right:2rem}dl,ol,ul{margin-top:0;margin-bottom:1rem}ol ol,ol ul,ul ol,ul ul{margin-bottom:0}dt{font-weight:700}dd{margin-bottom:.5rem;margin-right:0}blockquote{margin:0 0 1rem}b,strong{font-weight:bolder}small{font-size:.875em}mark{padding:.2em;background-color:#fcf8e3}sub,sup{position:relative;font-size:.75em;line-height:0;vertical-align:baseline}sub{bottom:-.25em}sup{top:-.5em}a{color:#0d6efd;text-decoration:underline}a:hover{color:#0a58ca}a:not([href]):not([class]),a:not([href]):not([class]):hover{color:inherit;text-decoration:none}code,kbd,pre,samp{font-family:SFMono-Regular,Menlo,Monaco,Consolas,"Liberation Mono","Courier New",monospace;font-size:1em;direction:ltr;unicode-bidi:bidi-override}pre{display:block;margin-top:0;margin-bottom:1rem;overflow:auto;font-size:.875em}pre code{font-size:inherit;color:inherit;word-break:normal}code{font-size:.875em;color:#d63384;word-wrap:break-word}a>code{color:inherit}kbd{padding:.2rem .4rem;font-size:.875em;color:#fff;background-color:#212529;border-radius:.2rem}kbd kbd{padding:0;font-size:1em;font-weight:700}figure{margin:0 0 1rem}img,svg{vertical-align:middle}table{caption-side:bottom;border-collapse:collapse}caption{padding-top:.5rem;padding-bottom:.5rem;color:#6c757d;text-align:right}th{text-align:inherit;text-align:-webkit-match-parent}tbody,td,tfoot,th,thead,tr{border-color:inherit;border-style:solid;border-width:0}label{display:inline-block}button{border-radius:0}button:focus:not(:focus-visible){outline:0}button,input,optgroup,select,textarea{margin:0;font-family:inherit;font-size:inherit;line-height:inherit}button,select{text-transform:none}[role=button]{cursor:pointer}select{word-wrap:normal}select:disabled{opacity:1}[list]::-webkit-calendar-picker-indicator{display:none}[type=button],[type=reset],[type=submit],button{-webkit-appearance:button}[type=button]:not(:disabled),[type=reset]:not(:disabled),[type=submit]:not(:disabled),button:not(:disabled){cursor:pointer}::-moz-focus-inner{padding:0;border-style:none}textarea{resize:vertical}fieldset{min-width:0;padding:0;margin:0;border:0}legend{float:right;width:100%;padding:0;margin-bottom:.5rem;font-size:calc(1.275rem + .3vw);line-height:inherit}@media (min-width:1200px){legend{font-size:1.5rem}}legend+*{clear:right}::-webkit-datetime-edit-day-field,::-webkit-datetime-edit-fields-wrapper,::-webkit-datetime-edit-hour-field,::-webkit-datetime-edit-minute,::-webkit-datetime-edit-month-field,::-webkit-datetime-edit-text,::-webkit-datetime-edit-year-field{padding:0}::-webkit-inner-spin-button{height:auto}[type=search]{outline-offset:-2px;-webkit-appearance:textfield}[type=email],[type=number],[type=tel],[type=url]{direction:ltr}::-webkit-search-decoration{-webkit-appearance:none}::-webkit-color-swatch-wrapper{padding:0}::file-selector-button{font:inherit}::-webkit-file-upload-button{font:inherit;-webkit-appearance:button}output{display:inline-block}iframe{border:0}summary{display:list-item;cursor:pointer}progress{vertical-align:baseline}[hidden]{display:none!important}
/*# sourceMappingURL=bootstrap-reboot.rtl.min.css.map */

File diff suppressed because one or more lines are too long

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

Some files were not shown because too many files have changed in this diff Show More