Client Hard

This commit is contained in:
Алишер Бустонов 2023-06-01 16:47:56 +04:00
parent 8e21d57f05
commit 64aac679cf
142 changed files with 78784 additions and 48 deletions

View File

@ -3,7 +3,7 @@ Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17 # Visual Studio Version 17
VisualStudioVersion = 17.3.32825.248 VisualStudioVersion = 17.3.32825.248
MinimumVisualStudioVersion = 10.0.40219.1 MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FishFactoryView", "FishFactory\FishFactoryView.csproj", "{493271EC-376B-4F9E-A22B-433080D12559}" Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FishFactoryView", "FishFactoryView\FishFactoryView.csproj", "{493271EC-376B-4F9E-A22B-433080D12559}"
EndProject EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FishFactoryDataModels", "FishFactoryDataModels\FishFactoryDataModels.csproj", "{F6B5393D-1D0E-4A9C-A7F3-48C29DC996B4}" Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FishFactoryDataModels", "FishFactoryDataModels\FishFactoryDataModels.csproj", "{F6B5393D-1D0E-4A9C-A7F3-48C29DC996B4}"
EndProject EndProject
@ -17,9 +17,11 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FishFactoryFileImplement",
EndProject EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FishFactoryDatabaseImplement", "FishFactoryDatabaseImplement\FishFactoryDatabaseImplement.csproj", "{F5D03645-1AAA-492E-87CD-9903C526FD7B}" Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FishFactoryDatabaseImplement", "FishFactoryDatabaseImplement\FishFactoryDatabaseImplement.csproj", "{F5D03645-1AAA-492E-87CD-9903C526FD7B}"
EndProject EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FishFactoryRestApi", "FishFactoryRestApi\FishFactoryRestApi.csproj", "{9781080B-C8D4-47F4-B30D-B46E30AE1E24}" Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FishFactoryRestApi", "FishFactoryRestApi\FishFactoryRestApi.csproj", "{9781080B-C8D4-47F4-B30D-B46E30AE1E24}"
EndProject EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FishFactoryClientApp", "FishFactoryClientApp\FishFactoryClientApp.csproj", "{92455D8F-A94F-498B-853E-479DCF272DED}" Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FishFactoryClientApp", "FishFactoryClientApp\FishFactoryClientApp.csproj", "{92455D8F-A94F-498B-853E-479DCF272DED}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FishFactoryShopApp", "FishFactoryShopApp\FishFactoryShopApp.csproj", "{95515FE3-E992-44F2-9EB5-A7D9EFBF1ABB}"
EndProject EndProject
Global Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution GlobalSection(SolutionConfigurationPlatforms) = preSolution
@ -63,6 +65,10 @@ Global
{92455D8F-A94F-498B-853E-479DCF272DED}.Debug|Any CPU.Build.0 = Debug|Any CPU {92455D8F-A94F-498B-853E-479DCF272DED}.Debug|Any CPU.Build.0 = Debug|Any CPU
{92455D8F-A94F-498B-853E-479DCF272DED}.Release|Any CPU.ActiveCfg = Release|Any CPU {92455D8F-A94F-498B-853E-479DCF272DED}.Release|Any CPU.ActiveCfg = Release|Any CPU
{92455D8F-A94F-498B-853E-479DCF272DED}.Release|Any CPU.Build.0 = Release|Any CPU {92455D8F-A94F-498B-853E-479DCF272DED}.Release|Any CPU.Build.0 = Release|Any CPU
{95515FE3-E992-44F2-9EB5-A7D9EFBF1ABB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{95515FE3-E992-44F2-9EB5-A7D9EFBF1ABB}.Debug|Any CPU.Build.0 = Debug|Any CPU
{95515FE3-E992-44F2-9EB5-A7D9EFBF1ABB}.Release|Any CPU.ActiveCfg = Release|Any CPU
{95515FE3-E992-44F2-9EB5-A7D9EFBF1ABB}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection EndGlobalSection
GlobalSection(SolutionProperties) = preSolution GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE HideSolutionNode = FALSE

View File

@ -12,11 +12,15 @@ namespace FishFactoryBusinessLogic.BusinessLogics
{ {
private readonly ILogger _logger; private readonly ILogger _logger;
private readonly IOrderStorage _orderStorage; private readonly IOrderStorage _orderStorage;
private readonly IShopLogic _shopLogic;
private readonly ICannedStorage _cannedStorage;
public OrderLogic(ILogger<OrderLogic> logger, IOrderStorage orderStorage) public OrderLogic(ILogger<OrderLogic> logger, IOrderStorage orderStorage, IShopLogic shopLogic, ICannedStorage cannedStorage)
{ {
_logger = logger; _logger = logger;
_orderStorage = orderStorage; _orderStorage = orderStorage;
_shopLogic = shopLogic;
_cannedStorage = cannedStorage;
} }
public bool CreateOrder(OrderBindingModel model) public bool CreateOrder(OrderBindingModel model)
@ -39,14 +43,35 @@ namespace FishFactoryBusinessLogic.BusinessLogics
public bool StatusUpdate(OrderBindingModel model, OrderStatus newStatus) public bool StatusUpdate(OrderBindingModel model, OrderStatus newStatus)
{ {
CheckModel(model); var viewModel = _orderStorage.GetElement(new OrderSearchModel { Id = model.Id });
if (model.Status + 1 != newStatus) if (viewModel == null)
{
throw new ArgumentNullException(nameof(model));
}
if (viewModel.Status + 1 != newStatus)
{ {
_logger.LogWarning("Status update to " + newStatus.ToString() + " operation failed. Order status incorrect."); _logger.LogWarning("Status update to " + newStatus.ToString() + " operation failed. Order status incorrect.");
return false; return false;
} }
model.Status = newStatus; model.Status = newStatus;
if (model.Status == OrderStatus.Выдан) model.DateImplement = DateTime.Now; if (model.Status == OrderStatus.Готов)
{
model.DateImplement = DateTime.Now;
var canned = _cannedStorage.GetElement(new() { Id = viewModel.CannedId });
if (canned == null)
{
throw new ArgumentNullException(nameof(canned));
}
if (!_shopLogic.AddCanned(canned, viewModel.Count))
{
throw new Exception($"AddCanned operation failed. Shop is full.");
}
}
else
{
model.DateImplement = viewModel.DateImplement;
}
CheckModel(model, false);
if (_orderStorage.Update(model) == null) if (_orderStorage.Update(model) == null)
{ {
model.Status--; model.Status--;

View File

@ -16,6 +16,8 @@ namespace FishFactoryBusinessLogic.BusinessLogics
private readonly IOrderStorage _orderStorage; private readonly IOrderStorage _orderStorage;
private readonly IShopStorage _shopStorage;
private readonly AbstractSaveToExcel _saveToExcel; private readonly AbstractSaveToExcel _saveToExcel;
private readonly AbstractSaveToWord _saveToWord; private readonly AbstractSaveToWord _saveToWord;
@ -23,11 +25,12 @@ namespace FishFactoryBusinessLogic.BusinessLogics
private readonly AbstractSaveToPdf _saveToPdf; private readonly AbstractSaveToPdf _saveToPdf;
public ReportLogic(ICannedStorage productStorage, IIngredientStorage ingredientStorage, IOrderStorage orderStorage, public ReportLogic(ICannedStorage productStorage, IIngredientStorage ingredientStorage, IOrderStorage orderStorage,
AbstractSaveToExcel saveToExcel, AbstractSaveToWord saveToWord, AbstractSaveToPdf saveToPdf) AbstractSaveToExcel saveToExcel, AbstractSaveToWord saveToWord, AbstractSaveToPdf saveToPdf, IShopStorage shopStorage)
{ {
_cannedStorage = productStorage; _cannedStorage = productStorage;
_ingredientStorage = ingredientStorage; _ingredientStorage = ingredientStorage;
_orderStorage = orderStorage; _orderStorage = orderStorage;
_shopStorage = shopStorage;
_saveToExcel = saveToExcel; _saveToExcel = saveToExcel;
_saveToWord = saveToWord; _saveToWord = saveToWord;
@ -70,6 +73,34 @@ namespace FishFactoryBusinessLogic.BusinessLogics
return list; return list;
} }
/// <summary>
/// Получение списка консерв с указанием, в каких магазинах используются
/// </summary>
/// <returns></returns>
public List<ReportShopCannedViewModel> GetShopCanned()
{
var shops = _shopStorage.GetFullList();
var list = new List<ReportShopCannedViewModel>();
foreach (var shop in shops)
{
var record = new ReportShopCannedViewModel
{
ShopName = shop.ShopName,
ListCanned = new(),
TotalCount = 0
};
foreach (var Canned in shop.ListCanned)
{
record.ListCanned.Add(new(Canned.Value.Item1.CannedName, Canned.Value.Item2));
record.TotalCount += Canned.Value.Item2;
}
list.Add(record);
}
return list;
}
/// <summary> /// <summary>
/// Получение списка заказов за определенный период /// Получение списка заказов за определенный период
/// </summary> /// </summary>
@ -89,6 +120,24 @@ namespace FishFactoryBusinessLogic.BusinessLogics
.ToList(); .ToList();
} }
/// <summary>
/// Получение списка заказов, сгруппированных по дате
/// </summary>
/// <param name="model"></param>
/// <returns></returns>
public List<ReportOrdersGroupedByDateViewModel> GetOrdersGroupedByDate()
{
return _orderStorage.GetFullList()
.GroupBy(x => x.DateCreate.Date)
.Select(x => new ReportOrdersGroupedByDateViewModel
{
DateCreate = x.Key,
Count = x.Count(),
Sum = x.Sum(x => x.Sum)
})
.ToList();
}
/// <summary> /// <summary>
/// Сохранение консерв в файл-Word /// Сохранение консерв в файл-Word
/// </summary> /// </summary>
@ -103,6 +152,20 @@ namespace FishFactoryBusinessLogic.BusinessLogics
}); });
} }
/// <summary>
/// Сохранение магазинов в файл-Word
/// </summary>
/// <param name="model"></param>
public void SaveShopsToWordFile(ReportBindingModel model)
{
_saveToWord.CreateShopsDoc(new WordInfo
{
FileName = model.FileName,
Title = "Список магазинов",
Shops = _shopStorage.GetFullList()
});
}
/// <summary> /// <summary>
/// Сохранение ингредиентов с указаеним консерв в файл-Excel /// Сохранение ингредиентов с указаеним консерв в файл-Excel
/// </summary> /// </summary>
@ -117,6 +180,20 @@ namespace FishFactoryBusinessLogic.BusinessLogics
}); });
} }
/// <summary>
/// Сохранение консерв с указаеним магазина в файл-Excel
/// </summary>
/// <param name="model"></param>
public void SaveShopCannedToExcelFile(ReportBindingModel model)
{
_saveToExcel.CreateShopReport(new ExcelInfo
{
FileName = model.FileName,
Title = "Список магазинов",
ShopListCanned = GetShopCanned()
});
}
/// <summary> /// <summary>
/// Сохранение заказов в файл-Pdf /// Сохранение заказов в файл-Pdf
/// </summary> /// </summary>
@ -132,5 +209,19 @@ namespace FishFactoryBusinessLogic.BusinessLogics
Orders = GetOrders(model) Orders = GetOrders(model)
}); });
} }
/// <summary>
/// Сохранение заказов в файл-Pdf
/// </summary>
/// <param name="model"></param>
public void SaveOrdersGroupedByDateToPdfFile(ReportBindingModel model)
{
_saveToPdf.CreateOrdersGroupedByDateDoc(new PdfInfo
{
FileName = model.FileName,
Title = "Список заказов",
OrdersGroupedByDate = GetOrdersGroupedByDate()
});
}
} }
} }

View File

@ -0,0 +1,216 @@
using Microsoft.Extensions.Logging;
using FishFactoryContracts.BindingModels;
using FishFactoryContracts.BusinessLogicsContracts;
using FishFactoryContracts.SearchModels;
using FishFactoryContracts.StoragesContracts;
using FishFactoryContracts.ViewModels;
using FishFactoryDataModels.Models;
namespace CannedBusinessLogic
{
public class ShopLogic : IShopLogic
{
private readonly ILogger _logger;
private readonly IShopStorage _shopStorage;
public ShopLogic(ILogger<ShopLogic> logger, IShopStorage shopStorage)
{
_logger = logger;
_shopStorage = shopStorage;
}
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;
}
private void CheckModel(ShopBindingModel model, bool withParams = true)
{
if (model == null)
{
throw new ArgumentNullException(nameof(model));
}
if (!withParams)
{
return;
}
if (string.IsNullOrEmpty(model.ShopName))
{
throw new ArgumentNullException("Нет названия магазина", nameof(model.ShopName));
}
if (model.MaxCountCanned < 0)
{
throw new ArgumentException(
"Максимальное количество консервы в магазине не может быть меньше нуля",
nameof(model.MaxCountCanned));
}
_logger.LogInformation("Shop. ShopName:{0}.Address:{1}. Id: {2}",
model.ShopName, model.Address, model.Id);
var element = _shopStorage.GetElement(new ShopSearchModel
{
ShopName = model.ShopName
});
if (element != null && element.Id != model.Id && element.ShopName == model.ShopName)
{
throw new InvalidOperationException("Магазин с таким названием уже есть");
}
}
public bool AddCannedInShop(ShopSearchModel model, ICannedModel canned, int count)
{
if (model == null)
{
throw new ArgumentNullException(nameof(model));
}
if (count <= 0)
{
throw new ArgumentException("Количество консерв должно быть больше 0", nameof(count));
}
_logger.LogInformation("AddCannedInShop. ShopName:{ShopName}.Id:{ Id}",
model.ShopName, model.Id);
var element = _shopStorage.GetElement(model);
if (element == null)
{
_logger.LogWarning("AddCannedInShop element not found");
return false;
}
if (element.MaxCountCanned -
element.ListCanned.Select(x => x.Value.Item2).Sum() < count)
{
throw new ArgumentNullException("Магазин переполнен", nameof(count));
}
_logger.LogInformation("AddCannedInShop find. Id:{Id}", element.Id);
if (element.ListCanned.TryGetValue(canned.Id, out var pair))
{
element.ListCanned[canned.Id] = (canned, count + pair.Item2);
_logger.LogInformation(
"AddCannedInShop. Added {count} {Canned} to '{ShopName}' shop",
count, canned.CannedName, element.ShopName);
}
else
{
element.ListCanned[canned.Id] = (canned, count);
_logger.LogInformation(
"AddCannedInShop. Added {count} new Canned {Canned} to '{ShopName}' shop",
count, canned.CannedName, element.ShopName);
}
_shopStorage.Update(new() {
Id = element.Id,
Address = element.Address,
ShopName = element.ShopName,
DateOpening = element.DateOpening,
MaxCountCanned = element.MaxCountCanned,
ListCanned = element.ListCanned
});
return true;
}
public bool AddCanned(ICannedModel model, int count)
{
if (model == null)
{
throw new ArgumentNullException(nameof(model));
}
if (count <= 0)
{
throw new ArgumentException("Количество консерв должно быть больше 0", nameof(count));
}
var freeCount = _shopStorage.GetFullList()
.Select(x => x.MaxCountCanned - x.ListCanned
.Select(p => p.Value.Item2).Sum()).Sum() - count;
if (freeCount < 0)
{
_logger.LogInformation("AddCanned. Не удалось добавить изделия в магазины, они переполнены.");
return false;
}
foreach (var shop in _shopStorage.GetFullList())
{
int countFree = shop.MaxCountCanned - shop.ListCanned.Select(x => x.Value.Item2).Sum();
if (countFree < count)
{
if (!AddCannedInShop(new() { Id = shop.Id }, model, countFree))
{
_logger.LogWarning("AddCannedInShop operation failed.");
return false;
}
count -= countFree;
}
else
{
if (!AddCannedInShop(new() { Id = shop.Id }, model, count))
{
_logger.LogWarning("AddCannedInShop operation failed.");
return false;
}
count = 0;
}
if (count == 0)
{
return true;
}
}
return false;
}
public bool SellCanned(ICannedModel model, int count)
{
return _shopStorage.SellCanned(model, count);
}
}
}

View File

@ -80,6 +80,81 @@ namespace FishFactoryBusinessLogic.OfficePackage
SaveExcel(info); SaveExcel(info);
} }
/// <summary>
/// Создание отчета по суши в магазинах
/// </summary>
/// <param name="info"></param>
public void CreateShopReport(ExcelInfo 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 sc in info.ShopListCanned)
{
InsertCellInWorksheet(new ExcelCellParameters
{
ColumnName = "A",
RowIndex = rowIndex,
Text = sc.ShopName,
StyleInfo = ExcelStyleInfoType.Text
});
rowIndex++;
foreach (var (Canned, Count) in sc.ListCanned)
{
InsertCellInWorksheet(new ExcelCellParameters
{
ColumnName = "B",
RowIndex = rowIndex,
Text = Canned,
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 = sc.TotalCount.ToString(),
StyleInfo = ExcelStyleInfoType.Text
});
rowIndex++;
}
SaveExcel(info);
}
/// <summary> /// <summary>
/// Создание excel-файла /// Создание excel-файла
/// </summary> /// </summary>

View File

@ -34,6 +34,33 @@ namespace FishFactoryBusinessLogic.OfficePackage
SavePdf(info); SavePdf(info);
} }
public void CreateOrdersGroupedByDateDoc(PdfInfo info)
{
CreatePdf(info);
CreateParagraph(new PdfParagraph { Text = info.Title, Style = "NormalTitle", ParagraphAlignment = PdfParagraphAlignmentType.Center });
CreateTable(new List<string> { "3cm", "3cm", "3cm"});
CreateRow(new PdfRowParameters
{
Texts = new List<string> { "Дата заказов", "Количество заказов" ,"Сумма" },
Style = "NormalTitle",
ParagraphAlignment = PdfParagraphAlignmentType.Center
});
foreach (var order in info.OrdersGroupedByDate)
{
CreateRow(new PdfRowParameters
{
Texts = new List<string> { order.DateCreate.ToShortDateString(), order.Count.ToString(), order.Sum.ToString() },
Style = "Normal",
ParagraphAlignment = PdfParagraphAlignmentType.Left
});
}
SavePdf(info);
}
/// <summary> /// <summary>
/// Создание doc-файла /// Создание doc-файла
/// </summary> /// </summary>

View File

@ -38,12 +38,59 @@ namespace FishFactoryBusinessLogic.OfficePackage
SaveWord(info); SaveWord(info);
} }
public void CreateShopsDoc(WordInfo 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
}
});
List<WordRow> rows = new List<WordRow>();
rows.Add(new WordRow
{
Rows = new List<(string, WordTextProperties)> {
("Название", new WordTextProperties { Size = "24", Bold = true }),
("Адрес", new WordTextProperties { Size = "24", Bold = true }),
("Дата открытия", new WordTextProperties { Size = "24", Bold = true })
}
});
foreach (var shop in info.Shops)
{
rows.Add(new WordRow
{
Rows = new List<(string, WordTextProperties)> {
(shop.ShopName, new WordTextProperties { Size = "24" }),
(shop.Address, new WordTextProperties { Size = "24" }),
(shop.DateOpening.ToShortDateString(), new WordTextProperties { Size = "24" })
}
});
}
CreateTable(rows);
SaveWord(info);
}
/// <summary> /// <summary>
/// Создание doc-файла /// Создание doc-файла
/// </summary> /// </summary>
/// <param name="info"></param> /// <param name="info"></param>
protected abstract void CreateWord(WordInfo info); protected abstract void CreateWord(WordInfo info);
/// <summary>
/// Создание таблицы
/// </summary>
/// <param name="rows"></param>
protected abstract void CreateTable(List<WordRow> rows);
/// <summary> /// <summary>
/// Создание абзаца с текстом /// Создание абзаца с текстом
/// </summary> /// </summary>

View File

@ -9,5 +9,7 @@ namespace FishFactoryBusinessLogic.OfficePackage.HelperModels
public string Title { get; set; } = string.Empty; public string Title { get; set; } = string.Empty;
public List<ReportCannedIngredientViewModel> CannedIngredients { get; set; } = new(); public List<ReportCannedIngredientViewModel> CannedIngredients { get; set; } = new();
public List<ReportShopCannedViewModel> ShopListCanned { get; set; } = new();
} }
} }

View File

@ -13,5 +13,7 @@ namespace FishFactoryBusinessLogic.OfficePackage.HelperModels
public DateTime DateTo { get; set; } public DateTime DateTo { get; set; }
public List<ReportOrdersViewModel> Orders { get; set; } = new(); public List<ReportOrdersViewModel> Orders { get; set; } = new();
public List<ReportOrdersGroupedByDateViewModel> OrdersGroupedByDate { get; set; } = new();
} }
} }

View File

@ -9,5 +9,7 @@ namespace FishFactoryBusinessLogic.OfficePackage.HelperModels
public string Title { get; set; } = string.Empty; public string Title { get; set; } = string.Empty;
public List<CannedViewModel> ListCanned { get; set; } = new(); public List<CannedViewModel> ListCanned { get; set; } = new();
public List<ShopViewModel> Shops { get; set; } = new();
} }
} }

View File

@ -0,0 +1,7 @@
namespace FishFactoryBusinessLogic.OfficePackage.HelperModels
{
public class WordRow
{
public List<(string, WordTextProperties)> Rows { get; set; } = new();
}
}

View File

@ -119,6 +119,60 @@ namespace FishFactoryBusinessLogic.OfficePackage.Implements
_docBody.AppendChild(docParagraph); _docBody.AppendChild(docParagraph);
} }
protected override void CreateTable(List<WordRow> data)
{
if (_docBody == null || data == null)
{
return;
}
Table table = 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 });
table.AppendChild(tableProp);
TableGrid tableGrid = new TableGrid();
for (int j = 0; j < data[0].Rows.Count; ++j)
{
tableGrid.AppendChild(new GridColumn() { Width = "3200" });
}
table.AppendChild(tableGrid);
for (int i = 0; i < data.Count; ++i)
{
TableRow docRow = new TableRow();
for (int j = 0; j < data[i].Rows.Count; ++j)
{
var docParagraph = new Paragraph();
var docRun = new Run();
var runProperties = new RunProperties();
docParagraph.AppendChild(CreateParagraphProperties(data[i].Rows[j].Item2));
runProperties.AppendChild(new RunFonts() { Ascii = "Times New Roman", ComplexScript = "Times New Roman", HighAnsi = "Times New Roman" });
runProperties.AppendChild(new FontSize { Val = data[i].Rows[j].Item2.Size == null ? data[i].Rows[j].Item2.Size : "24" });
if (data[i].Rows[j].Item2.Bold)
runProperties.AppendChild(new Bold());
docRun.AppendChild(runProperties);
docRun.AppendChild(new Text { Text = data[i].Rows[j].Item1.ToString(), Space = SpaceProcessingModeValues.Preserve });
docParagraph.AppendChild(docRun);
TableCell docCell = new TableCell();
docCell.AppendChild(docParagraph);
docRow.AppendChild(docCell);
}
table.AppendChild(docRow);
}
_docBody.AppendChild(table);
}
protected override void SaveWord(WordInfo info) protected override void SaveWord(WordInfo info)
{ {
if (_docBody == null || _wordDocument == null) if (_docBody == null || _wordDocument == null)

View File

@ -0,0 +1,22 @@
using FishFactoryDataModels.Models;
namespace FishFactoryContracts.BindingModels
{
public class ShopBindingModel : IShopModel
{
public int Id { get; set; }
public string ShopName { get; set; } = string.Empty;
public string Address { get; set; } = string.Empty;
public DateTime DateOpening { get; set; } = DateTime.Now;
public Dictionary<int, (ICannedModel, int)> ListCanned
{
get;
set;
} = new();
public int MaxCountCanned { get; set; }
}
}

View File

@ -11,6 +11,12 @@ namespace FishFactoryContracts.BusinessLogicsContracts
/// <returns></returns> /// <returns></returns>
List<ReportCannedIngredientViewModel> GetCannedIngredient(); List<ReportCannedIngredientViewModel> GetCannedIngredient();
/// <summary>
/// Получение списка консерв с указанием, в каких магазинах используются
/// </summary>
/// <returns></returns>
List<ReportShopCannedViewModel> GetShopCanned();
/// <summary> /// <summary>
/// Получение списка заказов за определенный период /// Получение списка заказов за определенный период
/// </summary> /// </summary>
@ -18,22 +24,47 @@ namespace FishFactoryContracts.BusinessLogicsContracts
/// <returns></returns> /// <returns></returns>
List<ReportOrdersViewModel> GetOrders(ReportBindingModel model); List<ReportOrdersViewModel> GetOrders(ReportBindingModel model);
/// <summary>
/// Получение списка заказов, сгруппированных по дате
/// </summary>
/// <param name="model"></param>
/// <returns></returns>
List<ReportOrdersGroupedByDateViewModel> GetOrdersGroupedByDate();
/// <summary> /// <summary>
/// Сохранение индгредиентов в файл-Word /// Сохранение индгредиентов в файл-Word
/// </summary> /// </summary>
/// <param name="model"></param> /// <param name="model"></param>
void SaveListCannedToWordFile(ReportBindingModel model); void SaveListCannedToWordFile(ReportBindingModel model);
/// <summary>
/// Сохранение магазинов в файл-Word
/// </summary>
/// <param name="model"></param>
void SaveShopsToWordFile(ReportBindingModel model);
/// <summary> /// <summary>
/// Сохранение индгредиентов с указаеним консерв в файл-Excel /// Сохранение индгредиентов с указаеним консерв в файл-Excel
/// </summary> /// </summary>
/// <param name="model"></param> /// <param name="model"></param>
void SaveCannedIngredientToExcelFile(ReportBindingModel model); void SaveCannedIngredientToExcelFile(ReportBindingModel model);
/// <summary>
/// Сохранение суши с указаеним магазинов в файл-Excel
/// </summary>
/// <param name="model"></param>
void SaveShopCannedToExcelFile(ReportBindingModel model);
/// <summary> /// <summary>
/// Сохранение заказов в файл-Pdf /// Сохранение заказов в файл-Pdf
/// </summary> /// </summary>
/// <param name="model"></param> /// <param name="model"></param>
void SaveOrdersToPdfFile(ReportBindingModel model); void SaveOrdersToPdfFile(ReportBindingModel model);
/// <summary>
/// Сохранение сгруппированных заказов в файл-Pdf
/// </summary>
/// <param name="model"></param>
void SaveOrdersGroupedByDateToPdfFile(ReportBindingModel model);
} }
} }

View File

@ -0,0 +1,19 @@
using FishFactoryContracts.BindingModels;
using FishFactoryContracts.SearchModels;
using FishFactoryContracts.ViewModels;
using FishFactoryDataModels.Models;
namespace FishFactoryContracts.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 AddCannedInShop(ShopSearchModel model, ICannedModel canned, int count);
bool AddCanned(ICannedModel canned, int count);
bool SellCanned(ICannedModel canned, int count);
}
}

View File

@ -0,0 +1,8 @@
namespace FishFactoryContracts.SearchModels
{
public class ShopSearchModel
{
public int? Id { get; set; }
public string? ShopName { get; set; }
}
}

View File

@ -0,0 +1,18 @@
using FishFactoryContracts.BindingModels;
using FishFactoryContracts.SearchModels;
using FishFactoryContracts.ViewModels;
using FishFactoryDataModels.Models;
namespace FishFactoryContracts.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 SellCanned(ICannedModel model, int count);
}
}

View File

@ -0,0 +1,11 @@
namespace FishFactoryContracts.ViewModels
{
public class ReportOrdersGroupedByDateViewModel
{
public DateTime DateCreate { get; set; }
public int Count { get; set; }
public double Sum { get; set; }
}
}

View File

@ -0,0 +1,11 @@
namespace FishFactoryContracts.ViewModels
{
public class ReportShopCannedViewModel
{
public string ShopName { get; set; } = string.Empty;
public int TotalCount { get; set; }
public List<(string Canned, int Count)> ListCanned { get; set; } = new();
}
}

View File

@ -0,0 +1,27 @@
using FishFactoryDataModels.Models;
using System.ComponentModel;
namespace FishFactoryContracts.ViewModels
{
public class ShopViewModel : IShopModel
{
public int Id { get; set; }
[DisplayName("Название магазина")]
public string ShopName { get; set; } = string.Empty;
[DisplayName("Адрес магазина")]
public string Address { get; set; } = string.Empty;
[DisplayName("Дата открытия")]
public DateTime DateOpening { get; set; } = DateTime.Now;
[DisplayName("Максимальное количество консерв")]
public int MaxCountCanned { get; set; }
public Dictionary<int, (ICannedModel, int)> ListCanned
{
get;
set;
} = new();
}
}

View File

@ -0,0 +1,11 @@
namespace FishFactoryDataModels.Models
{
public interface IShopModel : IId
{
string ShopName { get; }
string Address { get; }
DateTime DateOpening { get; }
Dictionary<int, (ICannedModel, int)> ListCanned { get; }
int MaxCountCanned { get; }
}
}

View File

@ -23,5 +23,9 @@ namespace FishFactoryDatabaseImplement
public virtual DbSet<Order> Orders { set; get; } public virtual DbSet<Order> Orders { set; get; }
public virtual DbSet<Client> Clients { set; get; } public virtual DbSet<Client> Clients { set; get; }
public virtual DbSet<Shop> Shops { set; get; }
public virtual DbSet<ShopCanned> ShopCanned { set; get; }
} }
} }

View File

@ -0,0 +1,150 @@
using Microsoft.EntityFrameworkCore;
using FishFactoryContracts.BindingModels;
using FishFactoryContracts.SearchModels;
using FishFactoryContracts.StoragesContracts;
using FishFactoryContracts.ViewModels;
using FishFactoryDatabaseImplement.Models;
using FishFactoryDataModels.Models;
namespace FishFactoryDatabaseImplement.Implements
{
public class ShopStorage : IShopStorage
{
public List<ShopViewModel> GetFullList()
{
using var context = new FishFactoryDatabase();
return context.Shops
.Include(x => x.ListCannedFk)
.ThenInclude(x => x.Canned)
.ToList()
.Select(x => x.GetViewModel)
.ToList();
}
public List<ShopViewModel> GetFilteredList(ShopSearchModel model)
{
if (string.IsNullOrEmpty(model.ShopName))
{
return new();
}
using var context = new FishFactoryDatabase();
return context.Shops
.Include(x => x.ListCannedFk)
.ThenInclude(x => x.Canned)
.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 null;
}
using var context = new FishFactoryDatabase();
return context.Shops
.Include(x => x.ListCannedFk)
.ThenInclude(x => x.Canned)
.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 FishFactoryDatabase();
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 FishFactoryDatabase();
using var transaction = context.Database.BeginTransaction();
try
{
var shop = context.Shops.FirstOrDefault(rec => rec.Id == model.Id);
if (shop == null)
{
return null;
}
shop.Update(model);
context.SaveChanges();
shop.UpdateCanned(context, model);
transaction.Commit();
return shop.GetViewModel;
}
catch
{
transaction.Rollback();
throw;
}
}
public ShopViewModel? Delete(ShopBindingModel model)
{
using var context = new FishFactoryDatabase();
var element = context.Shops
.Include(x => x.ListCannedFk)
.FirstOrDefault(rec => rec.Id == model.Id);
if (element != null)
{
context.Shops.Remove(element);
context.SaveChanges();
return element.GetViewModel;
}
return null;
}
public bool SellCanned(ICannedModel model, int count)
{
using var context = new FishFactoryDatabase();
using var transaction = context.Database.BeginTransaction();
try
{
foreach (var shop in context.Shops
.Include(x => x.ListCannedFk)
.ThenInclude(x => x.Canned)
.ToList()
.Where(x => x.ListCanned.ContainsKey(model.Id)))
{
int countInCurrentShop = shop.ListCanned[model.Id].Item2;
if (countInCurrentShop <= count)
{
var elem = context.ShopCanned
.Where(x => x.CannedId == model.Id)
.FirstOrDefault(x => x.ShopId == shop.Id);
context.ShopCanned.Remove(elem);
shop.ListCanned.Remove(model.Id);
count -= countInCurrentShop;
}
else
{
shop.ListCanned[model.Id] = (shop.ListCanned[model.Id].Item1, countInCurrentShop - count);
count = 0;
shop.UpdateCanned(context, new()
{
Id = shop.Id,
ListCanned = shop.ListCanned,
});
}
if (count == 0)
{
context.SaveChanges();
transaction.Commit();
return true;
}
}
transaction.Rollback();
return false;
}
catch
{
transaction.Rollback();
throw;
}
}
}
}

View File

@ -12,7 +12,7 @@ using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
namespace FishFactoryDatabaseImplement.Migrations namespace FishFactoryDatabaseImplement.Migrations
{ {
[DbContext(typeof(FishFactoryDatabase))] [DbContext(typeof(FishFactoryDatabase))]
[Migration("20230412125217_InitialCreate")] [Migration("20230601124435_InitialCreate")]
partial class InitialCreate partial class InitialCreate
{ {
/// <inheritdoc /> /// <inheritdoc />
@ -154,6 +154,59 @@ namespace FishFactoryDatabaseImplement.Migrations
b.ToTable("Orders"); b.ToTable("Orders");
}); });
modelBuilder.Entity("FishFactoryDatabaseImplement.Models.Shop", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<string>("Address")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<DateTime>("DateOpening")
.HasColumnType("datetime2");
b.Property<int>("MaxCountCanned")
.HasColumnType("int");
b.Property<string>("ShopName")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.HasKey("Id");
b.ToTable("Shops");
});
modelBuilder.Entity("FishFactoryDatabaseImplement.Models.ShopCanned", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<int>("CannedId")
.HasColumnType("int");
b.Property<int>("Count")
.HasColumnType("int");
b.Property<int>("ShopId")
.HasColumnType("int");
b.HasKey("Id");
b.HasIndex("CannedId");
b.HasIndex("ShopId");
b.ToTable("ShopCanned");
});
modelBuilder.Entity("FishFactoryDatabaseImplement.Models.CannedIngredient", b => modelBuilder.Entity("FishFactoryDatabaseImplement.Models.CannedIngredient", b =>
{ {
b.HasOne("FishFactoryDatabaseImplement.Models.Canned", "Canned") b.HasOne("FishFactoryDatabaseImplement.Models.Canned", "Canned")
@ -192,11 +245,32 @@ namespace FishFactoryDatabaseImplement.Migrations
b.Navigation("Client"); b.Navigation("Client");
}); });
modelBuilder.Entity("FishFactoryDatabaseImplement.Models.ShopCanned", b =>
{
b.HasOne("FishFactoryDatabaseImplement.Models.Canned", "Canned")
.WithMany("ShopsFk")
.HasForeignKey("CannedId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("FishFactoryDatabaseImplement.Models.Shop", "Shop")
.WithMany("ListCannedFk")
.HasForeignKey("ShopId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Canned");
b.Navigation("Shop");
});
modelBuilder.Entity("FishFactoryDatabaseImplement.Models.Canned", b => modelBuilder.Entity("FishFactoryDatabaseImplement.Models.Canned", b =>
{ {
b.Navigation("Ingredients"); b.Navigation("Ingredients");
b.Navigation("Orders"); b.Navigation("Orders");
b.Navigation("ShopsFk");
}); });
modelBuilder.Entity("FishFactoryDatabaseImplement.Models.Client", b => modelBuilder.Entity("FishFactoryDatabaseImplement.Models.Client", b =>
@ -208,6 +282,11 @@ namespace FishFactoryDatabaseImplement.Migrations
{ {
b.Navigation("SushiIngredients"); b.Navigation("SushiIngredients");
}); });
modelBuilder.Entity("FishFactoryDatabaseImplement.Models.Shop", b =>
{
b.Navigation("ListCannedFk");
});
#pragma warning restore 612, 618 #pragma warning restore 612, 618
} }
} }

View File

@ -54,6 +54,22 @@ namespace FishFactoryDatabaseImplement.Migrations
table.PrimaryKey("PK_Ingredients", x => x.Id); table.PrimaryKey("PK_Ingredients", x => x.Id);
}); });
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),
Address = table.Column<string>(type: "nvarchar(max)", nullable: false),
DateOpening = table.Column<DateTime>(type: "datetime2", nullable: false),
MaxCountCanned = table.Column<int>(type: "int", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Shops", x => x.Id);
});
migrationBuilder.CreateTable( migrationBuilder.CreateTable(
name: "Orders", name: "Orders",
columns: table => new columns: table => new
@ -112,6 +128,33 @@ namespace FishFactoryDatabaseImplement.Migrations
onDelete: ReferentialAction.Cascade); onDelete: ReferentialAction.Cascade);
}); });
migrationBuilder.CreateTable(
name: "ShopCanned",
columns: table => new
{
Id = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
CannedId = 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_ShopCanned", x => x.Id);
table.ForeignKey(
name: "FK_ShopCanned_CannedList_CannedId",
column: x => x.CannedId,
principalTable: "CannedList",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_ShopCanned_Shops_ShopId",
column: x => x.ShopId,
principalTable: "Shops",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateIndex( migrationBuilder.CreateIndex(
name: "IX_CannedIngredients_CannedId", name: "IX_CannedIngredients_CannedId",
table: "CannedIngredients", table: "CannedIngredients",
@ -131,6 +174,16 @@ namespace FishFactoryDatabaseImplement.Migrations
name: "IX_Orders_ClientId", name: "IX_Orders_ClientId",
table: "Orders", table: "Orders",
column: "ClientId"); column: "ClientId");
migrationBuilder.CreateIndex(
name: "IX_ShopCanned_CannedId",
table: "ShopCanned",
column: "CannedId");
migrationBuilder.CreateIndex(
name: "IX_ShopCanned_ShopId",
table: "ShopCanned",
column: "ShopId");
} }
/// <inheritdoc /> /// <inheritdoc />
@ -142,14 +195,20 @@ namespace FishFactoryDatabaseImplement.Migrations
migrationBuilder.DropTable( migrationBuilder.DropTable(
name: "Orders"); name: "Orders");
migrationBuilder.DropTable(
name: "ShopCanned");
migrationBuilder.DropTable( migrationBuilder.DropTable(
name: "Ingredients"); name: "Ingredients");
migrationBuilder.DropTable(
name: "Clients");
migrationBuilder.DropTable( migrationBuilder.DropTable(
name: "CannedList"); name: "CannedList");
migrationBuilder.DropTable( migrationBuilder.DropTable(
name: "Clients"); name: "Shops");
} }
} }
} }

View File

@ -151,6 +151,59 @@ namespace FishFactoryDatabaseImplement.Migrations
b.ToTable("Orders"); b.ToTable("Orders");
}); });
modelBuilder.Entity("FishFactoryDatabaseImplement.Models.Shop", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<string>("Address")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<DateTime>("DateOpening")
.HasColumnType("datetime2");
b.Property<int>("MaxCountCanned")
.HasColumnType("int");
b.Property<string>("ShopName")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.HasKey("Id");
b.ToTable("Shops");
});
modelBuilder.Entity("FishFactoryDatabaseImplement.Models.ShopCanned", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<int>("CannedId")
.HasColumnType("int");
b.Property<int>("Count")
.HasColumnType("int");
b.Property<int>("ShopId")
.HasColumnType("int");
b.HasKey("Id");
b.HasIndex("CannedId");
b.HasIndex("ShopId");
b.ToTable("ShopCanned");
});
modelBuilder.Entity("FishFactoryDatabaseImplement.Models.CannedIngredient", b => modelBuilder.Entity("FishFactoryDatabaseImplement.Models.CannedIngredient", b =>
{ {
b.HasOne("FishFactoryDatabaseImplement.Models.Canned", "Canned") b.HasOne("FishFactoryDatabaseImplement.Models.Canned", "Canned")
@ -189,11 +242,32 @@ namespace FishFactoryDatabaseImplement.Migrations
b.Navigation("Client"); b.Navigation("Client");
}); });
modelBuilder.Entity("FishFactoryDatabaseImplement.Models.ShopCanned", b =>
{
b.HasOne("FishFactoryDatabaseImplement.Models.Canned", "Canned")
.WithMany("ShopsFk")
.HasForeignKey("CannedId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("FishFactoryDatabaseImplement.Models.Shop", "Shop")
.WithMany("ListCannedFk")
.HasForeignKey("ShopId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Canned");
b.Navigation("Shop");
});
modelBuilder.Entity("FishFactoryDatabaseImplement.Models.Canned", b => modelBuilder.Entity("FishFactoryDatabaseImplement.Models.Canned", b =>
{ {
b.Navigation("Ingredients"); b.Navigation("Ingredients");
b.Navigation("Orders"); b.Navigation("Orders");
b.Navigation("ShopsFk");
}); });
modelBuilder.Entity("FishFactoryDatabaseImplement.Models.Client", b => modelBuilder.Entity("FishFactoryDatabaseImplement.Models.Client", b =>
@ -205,6 +279,11 @@ namespace FishFactoryDatabaseImplement.Migrations
{ {
b.Navigation("SushiIngredients"); b.Navigation("SushiIngredients");
}); });
modelBuilder.Entity("FishFactoryDatabaseImplement.Models.Shop", b =>
{
b.Navigation("ListCannedFk");
});
#pragma warning restore 612, 618 #pragma warning restore 612, 618
} }
} }

View File

@ -38,6 +38,9 @@ namespace FishFactoryDatabaseImplement.Models
[ForeignKey("CannedId")] [ForeignKey("CannedId")]
public virtual List<Order> Orders { get; set; } = new(); public virtual List<Order> Orders { get; set; } = new();
[ForeignKey("CannedId")]
public virtual List<ShopCanned> ShopsFk { get; set; } = new();
public static Canned Create(FishFactoryDatabase context, CannedBindingModel model) public static Canned Create(FishFactoryDatabase context, CannedBindingModel model)
{ {
return new Canned() return new Canned()

View File

@ -0,0 +1,105 @@
using FishFactoryContracts.BindingModels;
using FishFactoryContracts.ViewModels;
using FishFactoryDataModels.Models;
using System.ComponentModel.DataAnnotations.Schema;
using System.ComponentModel.DataAnnotations;
using System.Xml.Linq;
namespace FishFactoryDatabaseImplement.Models
{
public class Shop : IShopModel
{
public int Id { get; private set; }
[Required]
public string ShopName { get; private set; } = string.Empty;
[Required]
public string Address { get; private set; } = string.Empty;
[Required]
public DateTime DateOpening { get; private set; }
[Required]
public int MaxCountCanned { get; private set; }
private Dictionary<int, (ICannedModel, int)>? _shopCanned = null;
[NotMapped]
public Dictionary<int, (ICannedModel, int)> ListCanned
{
get
{
if (_shopCanned == null)
{
_shopCanned = ListCannedFk
.ToDictionary(recPC => recPC.CannedId, recPC => (recPC.Canned as ICannedModel, recPC.Count));
}
return _shopCanned;
}
}
[ForeignKey("ShopId")]
public virtual List<ShopCanned> ListCannedFk { get; set; } = new();
public static Shop Create(FishFactoryDatabase context, ShopBindingModel model)
{
return new Shop()
{
Id = model.Id,
ShopName = model.ShopName,
Address = model.Address,
DateOpening = model.DateOpening,
MaxCountCanned = model.MaxCountCanned,
ListCannedFk = model.ListCanned.Select(x => new ShopCanned
{
Canned = context.CannedList.First(y => y.Id == x.Key),
Count = x.Value.Item2
}).ToList()
};
}
public void Update(ShopBindingModel model)
{
ShopName = model.ShopName;
Address = model.Address;
DateOpening = model.DateOpening;
MaxCountCanned = model.MaxCountCanned;
}
public ShopViewModel GetViewModel => new()
{
Id = Id,
ShopName = ShopName,
Address = Address,
DateOpening = DateOpening,
MaxCountCanned = MaxCountCanned,
ListCanned = ListCanned
};
public void UpdateCanned(FishFactoryDatabase context, ShopBindingModel model)
{
var shopCanned = context.ShopCanned.Where(rec => rec.ShopId == model.Id).ToList();
if (shopCanned != null && shopCanned.Count > 0)
{ // удалили те, которых нет в модели
context.ShopCanned.RemoveRange(shopCanned.Where(rec => !model.ListCanned.ContainsKey(rec.CannedId)));
context.SaveChanges();
// обновили количество у существующих записей
foreach (var updateCanned in shopCanned)
{
updateCanned.Count = model.ListCanned[updateCanned.CannedId].Item2;
model.ListCanned.Remove(updateCanned.CannedId);
}
context.SaveChanges();
}
var shop = context.Shops.First(x => x.Id == Id);
foreach (var ss in model.ListCanned)
{
context.ShopCanned.Add(new ShopCanned
{
Shop = shop,
Canned = context.CannedList.First(x => x.Id == ss.Key),
Count = ss.Value.Item2
});
context.SaveChanges();
}
_shopCanned = null;
}
}
}

View File

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

View File

@ -10,10 +10,12 @@ namespace FishFactoryFileImplement
private readonly string OrderFileName = "Order.xml"; private readonly string OrderFileName = "Order.xml";
private readonly string CannedFileName = "Canned.xml"; private readonly string CannedFileName = "Canned.xml";
private readonly string ClientFileName = "Client.xml"; private readonly string ClientFileName = "Client.xml";
private readonly string ShopFileName = "Shop.xml";
public List<Ingredient> Ingredients { get; private set; } public List<Ingredient> Ingredients { get; private set; }
public List<Order> Orders { get; private set; } public List<Order> Orders { get; private set; }
public List<Canned> ListCanned { get; private set; } public List<Canned> ListCanned { get; private set; }
public List<Client> Clients { get; private set; } public List<Client> Clients { get; private set; }
public List<Shop> Shops { get; private set; }
public static DataFileSingleton GetInstance() public static DataFileSingleton GetInstance()
{ {
if (instance == null) if (instance == null)
@ -31,12 +33,16 @@ namespace FishFactoryFileImplement
public void SaveOrders() => SaveData(Orders, OrderFileName, "Orders", 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 SaveClients() => SaveData(Clients, ClientFileName, "Clients", x => x.GetXElement);
public void SaveShops() => SaveData(Shops, ShopFileName, "Shops", x => x.GetXElement);
private DataFileSingleton() private DataFileSingleton()
{ {
Ingredients = LoadData(IngredientFileName, "Ingredient", x => Ingredient.Create(x)!)!; Ingredients = LoadData(IngredientFileName, "Ingredient", x => Ingredient.Create(x)!)!;
ListCanned = LoadData(CannedFileName, "Canned", x => Canned.Create(x)!)!; ListCanned = LoadData(CannedFileName, "Canned", x => Canned.Create(x)!)!;
Orders = LoadData(OrderFileName, "Order", x => Order.Create(x)!)!; Orders = LoadData(OrderFileName, "Order", x => Order.Create(x)!)!;
Clients = LoadData(ClientFileName, "Client", x => Client.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, private static List<T>? LoadData<T>(string filename, string xmlNodeName,

View File

@ -0,0 +1,102 @@
using FishFactoryContracts.BindingModels;
using FishFactoryContracts.SearchModels;
using FishFactoryContracts.StoragesContracts;
using FishFactoryContracts.ViewModels;
using FishFactoryDataModels.Models;
using FishFactoryFileImplement.Models;
namespace FishFactoryFileImplement.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 element = source.Shops.FirstOrDefault(x => x.Id == model.Id);
if (element != null)
{
source.Shops.Remove(element);
source.SaveShops();
return element.GetViewModel;
}
return null;
}
public bool SellCanned(ICannedModel model, int count)
{
if (source.Shops.Select(x => x.ListCanned.FirstOrDefault(y => y.Key == model.Id).Value.Item2).Sum() < count)
{
return false;
}
foreach (var shop in source.Shops.Where(x => x.ListCanned.ContainsKey(model.Id)))
{
int countInCurrentShop = shop.ListCanned[model.Id].Item2;
if (countInCurrentShop <= count)
{
shop.ListCanned.Remove(model.Id);
count -= countInCurrentShop;
}
else
{
shop.ListCanned[model.Id] = (shop.ListCanned[model.Id].Item1, countInCurrentShop - count);
count = 0;
}
if (count == 0)
{
return true;
}
}
return false;
}
}
}

View File

@ -0,0 +1,105 @@
using FishFactoryContracts.BindingModels;
using FishFactoryContracts.ViewModels;
using FishFactoryDataModels.Models;
using System.Xml.Linq;
namespace FishFactoryFileImplement.Models
{
public class Shop : IShopModel
{
public int Id { get; private set; }
public string ShopName { get; private set; } = string.Empty;
public string Address { get; private set; } = string.Empty;
public DateTime DateOpening { get; private set; }
public int MaxCountCanned { get; private set; }
public Dictionary<int, int> CountCanned
{
get;
private set;
} = new();
private Dictionary<int, (ICannedModel, int)>? _shopCanned = null;
public Dictionary<int, (ICannedModel, int)> ListCanned
{
get
{
if (_shopCanned == null)
{
var source = DataFileSingleton.GetInstance();
_shopCanned =
CountCanned.ToDictionary(x => x.Key,
y => ((source.ListCanned.FirstOrDefault(z => z.Id == y.Key) as ICannedModel)!, y.Value));
}
return _shopCanned;
}
}
public static Shop? Create(ShopBindingModel? model)
{
if (model == null)
{
return null;
}
return new Shop()
{
Id = model.Id,
ShopName = model.ShopName,
Address = model.Address,
MaxCountCanned = model.MaxCountCanned,
DateOpening = model.DateOpening,
CountCanned = model.ListCanned.ToDictionary(x => x.Key, x => x.Value.Item2)
};
}
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,
Address = element.Element("Address")!.Value,
DateOpening = Convert.ToDateTime(element.Element("DateOpening")!.Value),
MaxCountCanned = Convert.ToInt32(element.Element("MaxCountCanned")!.Value),
CountCanned = element.Element("ListCanned")!.Elements("Canned").ToDictionary(
x => Convert.ToInt32(x.Element("Key")?.Value),
x => Convert.ToInt32(x.Element("Value")?.Value))
};
}
public void Update(ShopBindingModel? model)
{
if (model == null)
{
return;
}
ShopName = model.ShopName;
Address = model.Address;
DateOpening = model.DateOpening;
MaxCountCanned = model.MaxCountCanned;
CountCanned = model.ListCanned.ToDictionary(x => x.Key, x => x.Value.Item2);
_shopCanned = null;
}
public ShopViewModel GetViewModel => new()
{
Id = Id,
ShopName = ShopName,
Address = Address,
ListCanned = ListCanned,
DateOpening = DateOpening,
MaxCountCanned = MaxCountCanned,
};
public XElement GetXElement => new("Shop",
new XAttribute("Id", Id),
new XElement("ShopName", ShopName),
new XElement("Address", Address),
new XElement("DateOpening", DateOpening),
new XElement("MaxCountCanned", MaxCountCanned),
new XElement("ListCanned", CountCanned
.Select(x => new XElement("Canned",
new XElement("Key", x.Key),
new XElement("Value", x.Value))
).ToArray()));
}
}

View File

@ -9,6 +9,7 @@ namespace FishFactoryListImplement
public List<Order> Orders { get; set; } public List<Order> Orders { get; set; }
public List<Canned> ListCanned { get; set; } public List<Canned> ListCanned { get; set; }
public List<Client> Clients { get; set; } public List<Client> Clients { get; set; }
public List<Shop> Shops { get; set; }
private DataListSingleton() private DataListSingleton()
{ {
@ -16,6 +17,7 @@ namespace FishFactoryListImplement
Orders = new List<Order>(); Orders = new List<Order>();
ListCanned = new List<Canned>(); ListCanned = new List<Canned>();
Clients = new List<Client>(); Clients = new List<Client>();
Shops = new List<Shop>();
} }
public static DataListSingleton GetInstance() public static DataListSingleton GetInstance()

View File

@ -0,0 +1,108 @@
using FishFactoryContracts.BindingModels;
using FishFactoryContracts.SearchModels;
using FishFactoryContracts.StoragesContracts;
using FishFactoryContracts.ViewModels;
using FishFactoryDataModels.Models;
using FishFactoryListImplement.Models;
namespace FishFactoryListImplement.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 ?? string.Empty))
{
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 SellCanned(ICannedModel model, int count)
{
throw new NotImplementedException();
}
}
}

View File

@ -0,0 +1,55 @@
using FishFactoryContracts.BindingModels;
using FishFactoryContracts.ViewModels;
using FishFactoryDataModels.Models;
namespace FishFactoryListImplement.Models
{
public class Shop : IShopModel
{
public int Id { get; private set; }
public string ShopName { get; private set; } = string.Empty;
public string Address { get; private set; } = string.Empty;
public DateTime DateOpening { get; private set; }
public Dictionary<int, (ICannedModel, int)> ListCanned
{
get;
private set;
} = new();
public static Shop? Create(ShopBindingModel? model)
{
if (model == null)
{
return null;
}
return new Shop()
{
Id = model.Id,
ShopName = model.ShopName,
Address = model.Address,
DateOpening = model.DateOpening,
ListCanned = new()
};
}
public void Update(ShopBindingModel? model)
{
if (model == null)
{
return;
}
ShopName = model.ShopName;
Address = model.Address;
DateOpening = model.DateOpening;
ListCanned = model.ListCanned;
}
public ShopViewModel GetViewModel => new()
{
Id = Id,
ShopName = ShopName,
Address = Address,
ListCanned = ListCanned,
DateOpening = DateOpening,
};
public int MaxCountCanned => throw new NotImplementedException();
}
}

View File

@ -0,0 +1,113 @@
using FishFactoryContracts.BindingModels;
using FishFactoryContracts.BusinessLogicsContracts;
using FishFactoryContracts.SearchModels;
using FishFactoryContracts.ViewModels;
using Microsoft.AspNetCore.Mvc;
namespace FishFactoryRestApi.Controllers
{
[Route("api/[controller]/[action]")]
[ApiController]
public class ShopController : Controller
{
private readonly ILogger _logger;
private readonly IShopLogic _shop;
public ShopController(ILogger<MainController> logger, IShopLogic shop)
{
_logger = logger;
_shop = shop;
}
[HttpGet]
public List<ShopViewModel>? GetShops()
{
try
{
return _shop.ReadList(null);
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка получения списка магазинов");
throw;
}
}
[HttpGet]
public Tuple<ShopViewModel, List<Tuple<string, int>>>? GetShop(int shopId)
{
try
{
var elem = _shop.ReadElement(new ShopSearchModel { Id = shopId });
if (elem == null)
return null;
return Tuple.Create(elem, elem.ListCanned.Select(x => Tuple.Create(x.Value.Item1.CannedName, x.Value.Item2)).ToList());
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка получения магазина по id={Id}", shopId);
throw;
}
}
[HttpPost]
public void CreateShop(ShopBindingModel model)
{
try
{
_shop.Create(model);
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка создания магазина");
throw;
}
}
[HttpPost]
public void UpdateData(ShopBindingModel model)
{
ShopViewModel viewModel = null;
try
{
viewModel = _shop.ReadElement(new ShopSearchModel { Id = model.Id, ShopName = model.ShopName }) ;
model.ListCanned = viewModel != null ? viewModel.ListCanned : null!;
_shop.Update(model);
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка обновления данных");
throw;
}
}
[HttpPost]
public void DeleteShop(ShopBindingModel model)
{
try
{
_shop.Delete(model);
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка удаления магазина");
throw;
}
}
[HttpPost]
public void AddCannedInShop(Tuple<ShopSearchModel, CannedViewModel, int> model)
{
try
{
_shop.AddCannedInShop(model.Item1, model.Item2, model.Item3);
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка добавления суши в магазин");
throw;
}
}
}
}

View File

@ -2,6 +2,7 @@ using FishFactoryBusinessLogic.BusinessLogics;
using FishFactoryContracts.BusinessLogicsContracts; using FishFactoryContracts.BusinessLogicsContracts;
using FishFactoryContracts.StoragesContracts; using FishFactoryContracts.StoragesContracts;
using FishFactoryDatabaseImplement.Implements; using FishFactoryDatabaseImplement.Implements;
using CannedBusinessLogic;
using Microsoft.OpenApi.Models; using Microsoft.OpenApi.Models;
var builder = WebApplication.CreateBuilder(args); var builder = WebApplication.CreateBuilder(args);
@ -13,10 +14,12 @@ builder.Logging.AddLog4Net("log4net.config");
builder.Services.AddTransient<IClientStorage, ClientStorage>(); builder.Services.AddTransient<IClientStorage, ClientStorage>();
builder.Services.AddTransient<IOrderStorage, OrderStorage>(); builder.Services.AddTransient<IOrderStorage, OrderStorage>();
builder.Services.AddTransient<ICannedStorage, CannedStorage>(); builder.Services.AddTransient<ICannedStorage, CannedStorage>();
builder.Services.AddTransient<IShopStorage, ShopStorage>();
builder.Services.AddTransient<IOrderLogic, OrderLogic>(); builder.Services.AddTransient<IOrderLogic, OrderLogic>();
builder.Services.AddTransient<IClientLogic, ClientLogic>(); builder.Services.AddTransient<IClientLogic, ClientLogic>();
builder.Services.AddTransient<ICannedLogic, CannedLogic>(); builder.Services.AddTransient<ICannedLogic, CannedLogic>();
builder.Services.AddTransient<IShopLogic, ShopLogic>();
builder.Services.AddControllers(); builder.Services.AddControllers();
// Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle // Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle

View File

@ -0,0 +1,55 @@
using FishFactoryContracts.ViewModels;
using Newtonsoft.Json;
using System.Net.Http.Headers;
using System.Text;
namespace FishFactoryShopApp
{
public class APIClient
{
private static readonly HttpClient _client = new();
public static string Password { get; private set; } = string.Empty;
public static bool Access { get; private set; } = false;
public static void Connect(IConfiguration configuration)
{
Password = configuration["PasswordShop"];
_client.BaseAddress = new Uri(configuration["IPAddress"]);
_client.DefaultRequestHeaders.Accept.Clear();
_client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
}
public static bool CheckPassword(string password)
{
return APIClient.Access = password == Password;
}
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);
}
}
}
}

View File

@ -0,0 +1,207 @@
using Microsoft.AspNetCore.Mvc;
using FishFactoryContracts.BindingModels;
using FishFactoryContracts.SearchModels;
using FishFactoryContracts.ViewModels;
using FishFactoryDataModels.Models;
using FishFactoryShopApp.Models;
using System.Diagnostics;
namespace FishFactoryShopApp.Controllers
{
public class HomeController : Controller
{
private readonly ILogger<HomeController> _logger;
public HomeController(ILogger<HomeController> logger)
{
_logger = logger;
}
[HttpGet]
public IActionResult Enter()
{
return View();
}
[HttpPost]
public void Enter(string password)
{
if (string.IsNullOrEmpty(password))
{
throw new Exception("Введите пароль");
}
if (!APIClient.CheckPassword(password))
{
throw new Exception("Неправильный пароль");
}
Response.Redirect("Index");
}
public IActionResult Index()
{
if (APIClient.Access == false)
{
return Redirect("~/Home/Enter");
}
return View(APIClient.GetRequest<List<ShopViewModel>>($"api/shop/getshops"));
}
[ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)]
public IActionResult Error()
{
return View(new ErrorViewModel { RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier });
}
public IActionResult Create()
{
if (APIClient.Access == false)
{
return Redirect("~/Home/Enter");
}
return View();
}
[HttpPost]
public void Create(string name, string address, DateTime date, int count)
{
if (APIClient.Access == false)
{
throw new Exception("Вы как сюда попали? Сюда вход только авторизованным");
}
if (string.IsNullOrEmpty(name) || string.IsNullOrEmpty(address)
|| count <= 0)
{
throw new Exception("Введите название");
}
if (string.IsNullOrEmpty(address))
{
throw new Exception("Введите адресс");
}
if (count <= 0)
{
throw new Exception("Введите количество");
}
APIClient.PostRequest("api/shop/createshop", new ShopBindingModel
{
ShopName = name,
Address = address,
MaxCountCanned = count,
DateOpening = date
});
Response.Redirect("Index");
}
public IActionResult Delete()
{
if (APIClient.Access == false)
{
return Redirect("~/Home/Enter");
}
ViewBag.Shops = APIClient.GetRequest<List<ShopViewModel>>("api/shop/getshops");
return View();
}
[HttpPost]
public void Delete(int shop)
{
if (APIClient.Access == false)
{
throw new Exception("Вы как сюда попали? Сюда вход только авторизованным");
}
APIClient.PostRequest("api/shop/deleteshop", new ShopBindingModel
{
Id = shop
});
Response.Redirect("Index");
}
public IActionResult Update()
{
if (APIClient.Access == false)
{
return Redirect("~/Home/Enter");
}
ViewBag.Shops = APIClient.GetRequest<List<ShopViewModel>>("api/shop/getshops");
return View();
}
[HttpPost]
public void Update(int shop, string name, string address, DateTime date, int count)
{
if (APIClient.Access == false)
{
throw new Exception("Вы как сюда попали? Сюда вход только авторизованным");
}
if (string.IsNullOrEmpty(name))
{
throw new Exception("Название магазина не может быть пустым");
}
if (string.IsNullOrEmpty(address))
{
throw new Exception("Адрес магазина не может быть пустым");
}
if (count <= 0)
{
throw new Exception("Вместимость магазина не может быть меньше нуля");
}
APIClient.PostRequest("api/shop/updatedata", new ShopBindingModel
{
Id = shop,
ShopName = name,
Address = address,
DateOpening = date,
MaxCountCanned = count
});
Response.Redirect("Index");
}
[HttpGet]
public Tuple<ShopViewModel, string>? GetShop(int shopId)
{
if (APIClient.Access == false)
{
throw new Exception("Вы как сюда попали? Сюда вход только авторизованным");
}
var result = APIClient.GetRequest<Tuple<ShopViewModel, List<Tuple<string, int>>>>($"api/shop/getshop?shopid={shopId}");
if (result == null)
{
return default;
}
string table = "";
for (int i = 0; i < result.Item2.Count; i++)
{
var canned = result.Item2[i].Item1;
var count = result.Item2[i].Item2;
table += "<tr>";
table += $"<td>{canned}</td>";
table += $"<td>{count}</td>";
table += "</tr>";
}
return Tuple.Create(result.Item1, table);
}
public IActionResult AddCanned()
{
if (APIClient.Access == false)
{
return Redirect("~/Home/Enter");
}
ViewBag.Shops = APIClient.GetRequest<List<ShopViewModel>>("api/shop/getshops");
ViewBag.ListCanned = APIClient.GetRequest<List<CannedViewModel>>("api/main/getlistCanned");
return View();
}
[HttpPost]
public void AddCanned(int shop, int canned, int count)
{
if (APIClient.Access == false)
{
throw new Exception("Вы как сюда попали? Сюда вход только авторизованным");
}
APIClient.PostRequest("api/shop/AddCannedInShop", Tuple.Create(
new ShopSearchModel() { Id = shop },
new CannedViewModel() { Id = canned },
count
));
Response.Redirect("Index");
}
}
}

View File

@ -0,0 +1,17 @@
<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="..\FishFactoryContracts\FishFactoryContracts.csproj" />
</ItemGroup>
</Project>

View File

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

View File

@ -0,0 +1,30 @@
using FishFactoryShopApp;
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:55532",
"sslPort": 44383
}
},
"profiles": {
"SushiBarShopApp": {
"commandName": "Project",
"dotnetRunMessages": true,
"launchBrowser": true,
"applicationUrl": "https://localhost:7243;http://localhost:5243",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
},
"IIS Express": {
"commandName": "IISExpress",
"launchBrowser": true,
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
}
}
}

View File

@ -0,0 +1,35 @@
@using FishFactoryContracts.ViewModels;
@using FishFactoryDataModels.Models;
@{
ViewData["Title"] = "Create";
}
@model Dictionary<int, (ICannedModel, int)>
<div class="text-center">
<h2 class="display-4">Добавление консервы в магазин</h2>
</div>
<form method="post">
<div class="row">
<div class="col-4">Магазин:</div>
<div class="col-8">
<select id="shop" name="shop" class="form-control" asp-items="@(new SelectList(@ViewBag.Shops, "Id", "ShopName"))"></select>
</div>
</div>
<div class="row">
<div class="col-4">Консерва:</div>
<div class="col-8">
<select id="Canned" name="Canned" class="form-control" asp-items="@(new SelectList(@ViewBag.ListCanned, "Id", "CannedName"))"></select>
</div>
</div>
<div class="row">
<div class="col-4">Количество:</div>
<div class="col-8"><input type="number" id="count" name="count" min="1" class="form-control"/></div>
</div>
<div class="row">
<div class="col-8"></div>
<div class="col-4"><input type="submit" value="Создать" class="btn btn-primary" /></div>
</div>
</form>

View File

@ -0,0 +1,29 @@
@{
ViewData["Title"] = "Create";
}
<div class="text-center">
<h2 class="display-4">Создание магазина</h2>
</div>
<form method="post">
<div class="row">
<div class="col-4">Название:</div>
<div class="col-8"><input type="text" name="name" id="name" class="form-control"/></div>
</div>
<div class="row">
<div class="col-4">Адрес:</div>
<div class="col-8"><input type="text" id="address" name="address" class="form-control"/></div>
</div>
<div class="row">
<div class="col-4">Максимальное количество консерв:</div>
<div class="col-8"><input type="number" id="count" name="count" class="form-control"/></div>
</div>
<div class="row">
<div class="col-4">Дата открытия:</div>
<div class="col-8"><input type="date" id="date" name="date" class="form-control" required/></div>
</div>
<div class="row">
<div class="col-8"></div>
<div class="col-4"><input type="submit" value="Создать" class="btn btn-primary" /></div>
</div>
</form>

View File

@ -0,0 +1,18 @@
@{
ViewData["Title"] = "Delete";
}
<div class="text-center">
<h2 class="display-4">Удаление магазина</h2>
</div>
<form method="post">
<div class="row">
<div class="col-4">Магазин:</div>
<div class="col-8">
<select id="shop" name="shop" class="form-control" asp-items="@(new SelectList(@ViewBag.Shops, "Id", "ShopName"))"></select>
</div>
</div>
<div class="row">
<div class="col-4"></div>
<div class="col-8"><input type="submit" value="Удалить" class="btn btn-danger" /></div>
</div>
</form>

View File

@ -0,0 +1,15 @@
@{
ViewData["Title"] = "Enter";
}
<div class="text-center">
<h2 class="display-4">Вход в приложение</h2>
</div>
<form method="post">
<div class="row">
<div class="col-4">Пароль:</div>
<div class="col-8"><input type="password" name="password" /></div>
<div class="col-8"></div>
<div class="col-4"><input type="submit" value="Вход" class="btn btn-primary" /></div>
</div>
</form>

View File

@ -0,0 +1,61 @@
@using FishFactoryContracts.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>
<a asp-action="Update">Редактировать магазин</a>
<a asp-action="Delete">Удалить магазин</a>
<a asp-action="AddCanned">Добавить консерву в магазин</a>
</p>
<table class="table">
<thead>
<tr>
<th>
Название
</th>
<th>
Адрес
</th>
<th>
Дата открытия
</th>
<th>
Максимальное количество консерв
</th>
</tr>
</thead>
<tbody>
@foreach (var item in Model)
{
<tr>
<td>
@Html.DisplayFor(modelItem => item.ShopName)
</td>
<td>
@Html.DisplayFor(modelItem => item.Address)
</td>
<td>
@Html.DisplayFor(modelItem => item.DateOpening)
</td>
<td>
@Html.DisplayFor(modelItem => item.MaxCountCanned)
</td>
</tr>
}
</tbody>
</table>
}
</div>

View File

@ -0,0 +1,82 @@
@using FishFactoryContracts.ViewModels;
@using FishFactoryDataModels.Models;
@{
ViewData["Title"] = "Update";
}
<div class="text-center">
<h2 class="display-4">Редактирование магазина</h2>
</div>
<form method="post">
<div class="row">
<div class="col-4">Магазин:</div>
<div class="col-8">
<select id="shop" name="shop" class="form-control" asp-items="@(new SelectList(@ViewBag.Shops, "Id", "ShopName"))"></select>
</div>
</div>
<div class="row">
<div class="col-4">Название:</div>
<div class="col-8"><input type="text" name="name" id="name" class="form-control"/></div>
</div>
<div class="row">
<div class="col-4">Адрес:</div>
<div class="col-8"><input type="text" id="address" name="address" class="form-control"/></div>
</div>
<div class="row">
<div class="col-4">Дата открытия:</div>
<div class="col-8"><input type="datetime-local" id="date" name="date" class="form-control" required/></div>
</div>
<div class="row">
<div class="col-4">Вместимость:</div>
<div class="col-8"><input type="number" id="count" name="count" class="form-control"/></div>
</div>
<table class="table">
<thead>
<tr>
<th>
Консерва
</th>
<th>
Количество
</th>
</tr>
</thead>
<tbody id="table-elements">
</tbody>
</table>
<div class="row">
<div class="col-8"></div>
<div class="col-4"><input type="submit" value="Сохранить" class="btn btn-primary" /></div>
</div>
</form>
@section Scripts
{
<script>
function check() {
var shop = $('#shop').val();
if (shop) {
$.ajax({
method: "GET",
url: "/Home/GetShop",
data: { shopId: shop },
success: function (result) {
$('#name').val(result.item1.shopName);
$('#address').val(result.item1.address);
$('#date').val(result.item1.dateOpening);
$('#count').val(result.item1.maxCountCanned);
$('#table-elements').html(result.item2);
}
});
};
}
check();
$('#shop').on('change', function () {
check();
});
</script>
}

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,46 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>@ViewData["Title"] - FishFactoryShopApp</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="~/FishFactoryShopApp.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">Рыбный завод</a>
<button class="navbar-toggler" type="button" data-toggle="collapse" data-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 flex-sm-row-reverse">
<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>
</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; 2023 - FishFactoryShopApp
</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 FishFactoryShopApp
@using FishFactoryShopApp.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,12 @@
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
}
},
"AllowedHosts": "*",
"IPAddress": "http://localhost:5038/",
"PasswordShop": "12345"
}

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

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