я смог всю исправить )))

This commit is contained in:
Алексей Крюков 2024-02-26 14:27:55 +04:00
parent 9ad795f0ea
commit 581c059cf7
68 changed files with 569 additions and 590 deletions

View File

@ -1,23 +0,0 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Extensions.Logging" Version="8.0.0" />
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="8.0.0" />
<PackageReference Include="Microsoft.Extensions.Logging.Configuration" Version="8.0.0" />
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="8.0.0" />
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="8.0.0" />
<PackageReference Include="Microsoft.Extensions.Logging.EventLog" Version="8.0.0" />
<PackageReference Include="Microsoft.Extensions.Logging.EventSource" Version="8.0.0" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\SnackBarContracts\SnackBarContracts.csproj" />
</ItemGroup>
</Project>

View File

@ -1,17 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using SnackBarDataModels.Models;
namespace SnackBarContracts.BindingModels
{
public class SnackBindingModel : ISnackModel
{
public int Id { get; set; }
public string SnackName { get; set; } = string.Empty;
public double Price { get; set; }
public Dictionary<int, (IComponentModel, int)> SnackComponents { get; set; } = new();
}
}

View File

@ -1,20 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using SnackBarContracts.BindingModels;
using SnackBarContracts.SearchModels;
using SnackBarContracts.ViewModels;
namespace SnackBarContracts.BusinessLogicsContracts
{
public interface ISnackLogic
{
List<SnackViewModel>? ReadList(SnackSearchModel? model);
SnackViewModel? ReadElement(SnackSearchModel model);
bool Create(SnackBindingModel model);
bool Update(SnackBindingModel model);
bool Delete(SnackBindingModel model);
}
}

View File

@ -1,21 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using SnackBarContracts.BindingModels;
using SnackBarContracts.SearchModels;
using SnackBarContracts.ViewModels;
namespace SnackBarContracts.StoragesContracts
{
public interface ISnackStorage
{
List<SnackViewModel> GetFullList();
List<SnackViewModel> GetFilteredList(SnackSearchModel model);
SnackViewModel? GetElement(SnackSearchModel model);
SnackViewModel? Insert(SnackBindingModel model);
SnackViewModel? Update(SnackBindingModel model);
SnackViewModel? Delete(SnackBindingModel model);
}
}

View File

@ -1,16 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace SnackBarDataModels.Models
{
public interface ISnackModel : IId
{
string SnackName { get; }
double Price { get; }
Dictionary<int, (IComponentModel, int)> SnackComponents { get; }
}
}

View File

@ -1,51 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using SnackBarContracts.BindingModels;
using SnackBarContracts.ViewModels;
using SnackBarDataModels.Models;
namespace SnackBarListImplement.Models
{
public class Snack : ISnackModel
{
public int Id { get; private set; }
public string SnackName { get; private set; } = string.Empty;
public double Price { get; private set; }
public Dictionary<int, (IComponentModel, int)> SnackComponents { get; private set; } = new Dictionary<int, (IComponentModel, int)>();
public static Snack? Create(SnackBindingModel? model)
{
if (model == null)
{
return null;
}
return new Snack()
{
Id = model.Id,
SnackName = model.SnackName,
Price = model.Price,
SnackComponents = model.SnackComponents
};
}
public void Update(SnackBindingModel? model)
{
if (model == null)
{
return;
}
SnackName = model.SnackName;
Price = model.Price;
SnackComponents = model.SnackComponents;
}
public SnackViewModel GetViewModel => new()
{
Id = Id,
SnackName = SnackName,
Price = Price,
SnackComponents = SnackComponents
};
}
}

View File

@ -1,111 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.ConstrainedExecution;
using System.Text;
using System.Threading.Tasks;
using SnackBarContracts.BindingModels;
using SnackBarContracts.SearchModels;
using SnackBarContracts.StoragesContracts;
using SnackBarContracts.ViewModels;
using SnackBarListImplement.Models;
namespace SnackBarListImplement.Implements
{
public class SnackStorage : ISnackStorage
{
private readonly DataListSingleton _source;
public SnackStorage()
{
_source = DataListSingleton.GetInstance();
}
public List<SnackViewModel> GetFullList()
{
var result = new List<SnackViewModel>();
foreach (var snack in _source.Snacks)
{
result.Add(snack.GetViewModel);
}
return result;
}
public List<SnackViewModel> GetFilteredList(SnackSearchModel model)
{
var result = new List<SnackViewModel>();
if (string.IsNullOrEmpty(model.SnackName))
{
return result;
}
foreach (var snack in _source.Snacks)
{
if (snack.SnackName.Contains(model.SnackName))
{
result.Add(snack.GetViewModel);
}
}
return result;
}
public SnackViewModel? GetElement(SnackSearchModel model)
{
if (string.IsNullOrEmpty(model.SnackName) && !model.Id.HasValue)
{
return null;
}
foreach (var snack in _source.Snacks)
{
if ((!string.IsNullOrEmpty(model.SnackName) && snack.SnackName == model.SnackName) || (model.Id.HasValue && snack.Id == model.Id))
{
return snack.GetViewModel;
}
}
return null;
}
public SnackViewModel? Insert(SnackBindingModel model)
{
model.Id = 1;
foreach (var snack in _source.Snacks)
{
if (model.Id <= snack.Id)
{
model.Id = snack.Id + 1;
}
}
var newSnack = Snack.Create(model);
if (newSnack == null)
{
return null;
}
_source.Snacks.Add(newSnack);
return newSnack.GetViewModel;
}
public SnackViewModel? Update(SnackBindingModel model)
{
foreach (var snack in _source.Snacks)
{
if (snack.Id == model.Id)
{
snack.Update(model);
return snack.GetViewModel;
}
}
return null;
}
public SnackViewModel? Delete(SnackBindingModel model)
{
for (int i = 0; i < _source.Snacks.Count; ++i)
{
if (_source.Snacks[i].Id == model.Id)
{
var element = _source.Snacks[i];
_source.Snacks.RemoveAt(i);
return element.GetViewModel;
}
}
return null;
}
}
}

View File

@ -3,16 +3,16 @@ using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using SnackBarContracts.BindingModels; using TypographyContracts.BindingModels;
using SnackBarContracts.BusinessLogicsContracts; using TypographyContracts.BusinessLogicsContracts;
using SnackBarContracts.SearchModels; using TypographyContracts.SearchModels;
using SnackBarContracts.StoragesContracts; using TypographyContracts.StoragesContracts;
using SnackBarContracts.ViewModels; using TypographyContracts.ViewModels;
using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging;
namespace SnackBarBusinessLogic.BusinessLogics namespace TypographyBusinessLogic.BusinessLogics
{ {
public class ComponentLogic : IComponentLogic public class ComponentLogic : IComponentLogic
{ {

View File

@ -1,17 +1,17 @@
using SnackBarContracts.BusinessLogicsContracts; using TypographyContracts.BusinessLogicsContracts;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using SnackBarContracts.BindingModels; using TypographyContracts.BindingModels;
using SnackBarContracts.SearchModels; using TypographyContracts.SearchModels;
using SnackBarContracts.StoragesContracts; using TypographyContracts.StoragesContracts;
using SnackBarContracts.ViewModels; using TypographyContracts.ViewModels;
using SnackBarDataModels.Enums; using TypographyDataModels.Enums;
using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging;
namespace SnackBarBusinessLogic.BusinessLogics namespace TypographyBusinessLogic.BusinessLogics
{ {
public class OrderLogic : IOrderLogic public class OrderLogic : IOrderLogic
{ {
@ -102,9 +102,9 @@ namespace SnackBarBusinessLogic.BusinessLogics
{ {
return; return;
} }
if (model.SnackId < 0) if (model.PrintedId < 0)
{ {
throw new ArgumentNullException("Некорректный идентификатор закусок", nameof(model.SnackId)); throw new ArgumentNullException("Некорректный идентификатор закусок", nameof(model.PrintedId));
} }
if (model.Count <= 0) if (model.Count <= 0)
{ {

View File

@ -1,30 +1,30 @@
using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging;
using SnackBarBusinessLogic.BusinessLogics; using TypographyBusinessLogic.BusinessLogics;
using SnackBarContracts.BindingModels; using TypographyContracts.BindingModels;
using SnackBarContracts.BusinessLogicsContracts; using TypographyContracts.BusinessLogicsContracts;
using SnackBarContracts.SearchModels; using TypographyContracts.SearchModels;
using SnackBarContracts.StoragesContracts; using TypographyContracts.StoragesContracts;
using SnackBarContracts.ViewModels; using TypographyContracts.ViewModels;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
namespace SnackBarBusinessLogic.BusinessLogics namespace TypographyBusinessLogic.BusinessLogics
{ {
public class SnackLogic : ISnackLogic public class PrintedLogic : IPrintedLogic
{ {
private readonly ILogger _logger; private readonly ILogger _logger;
private readonly ISnackStorage _snackStorage; private readonly IPrintedStorage _snackStorage;
public SnackLogic(ILogger<SnackLogic> logger, ISnackStorage snackStorage) public PrintedLogic(ILogger<PrintedLogic> logger, IPrintedStorage snackStorage)
{ {
_logger = logger; _logger = logger;
_snackStorage = snackStorage; _snackStorage = snackStorage;
} }
public List<SnackViewModel>? ReadList(SnackSearchModel? model) public List<PrintedViewModel>? ReadList(PrintedSearchModel? model)
{ {
_logger.LogInformation("ReadList. SnackName:{SnackName}.Id:{ Id}", model?.SnackName, model?.Id); _logger.LogInformation("ReadList. PrintedName:{PrintedName}.Id:{ Id}", model?.PrintedName, model?.Id);
var list = model == null ? _snackStorage.GetFullList() : _snackStorage.GetFilteredList(model); var list = model == null ? _snackStorage.GetFullList() : _snackStorage.GetFilteredList(model);
if (list == null) if (list == null)
{ {
@ -34,13 +34,13 @@ namespace SnackBarBusinessLogic.BusinessLogics
_logger.LogInformation("ReadList. Count:{Count}", list.Count); _logger.LogInformation("ReadList. Count:{Count}", list.Count);
return list; return list;
} }
public SnackViewModel? ReadElement(SnackSearchModel model) public PrintedViewModel? ReadElement(PrintedSearchModel model)
{ {
if (model == null) if (model == null)
{ {
throw new ArgumentNullException(nameof(model)); throw new ArgumentNullException(nameof(model));
} }
_logger.LogInformation("ReadElement. SnackName:{SnackName}.Id:{ Id}", model.SnackName, model.Id); _logger.LogInformation("ReadElement. PrintedName:{PrintedName}.Id:{ Id}", model.PrintedName, model.Id);
var element = _snackStorage.GetElement(model); var element = _snackStorage.GetElement(model);
if (element == null) if (element == null)
{ {
@ -50,7 +50,7 @@ namespace SnackBarBusinessLogic.BusinessLogics
_logger.LogInformation("ReadElement find. Id:{Id}", element.Id); _logger.LogInformation("ReadElement find. Id:{Id}", element.Id);
return element; return element;
} }
public bool Create(SnackBindingModel model) public bool Create(PrintedBindingModel model)
{ {
CheckModel(model); CheckModel(model);
if (_snackStorage.Insert(model) == null) if (_snackStorage.Insert(model) == null)
@ -60,7 +60,7 @@ namespace SnackBarBusinessLogic.BusinessLogics
} }
return true; return true;
} }
public bool Update(SnackBindingModel model) public bool Update(PrintedBindingModel model)
{ {
CheckModel(model); CheckModel(model);
if (_snackStorage.Update(model) == null) if (_snackStorage.Update(model) == null)
@ -70,7 +70,7 @@ namespace SnackBarBusinessLogic.BusinessLogics
} }
return true; return true;
} }
public bool Delete(SnackBindingModel model) public bool Delete(PrintedBindingModel model)
{ {
CheckModel(model, false); CheckModel(model, false);
_logger.LogInformation("Delete. Id:{Id}", model.Id); _logger.LogInformation("Delete. Id:{Id}", model.Id);
@ -81,7 +81,7 @@ namespace SnackBarBusinessLogic.BusinessLogics
} }
return true; return true;
} }
private void CheckModel(SnackBindingModel model, bool withParams = true) private void CheckModel(PrintedBindingModel model, bool withParams = true)
{ {
if (model == null) if (model == null)
{ {
@ -91,19 +91,19 @@ namespace SnackBarBusinessLogic.BusinessLogics
{ {
return; return;
} }
if (string.IsNullOrEmpty(model.SnackName)) if (string.IsNullOrEmpty(model.PrintedName))
{ {
throw new ArgumentNullException("Нет названия закуски", throw new ArgumentNullException("Нет названия закуски",
nameof(model.SnackName)); nameof(model.PrintedName));
} }
if (model.Price <= 0) if (model.Price <= 0)
{ {
throw new ArgumentNullException("Цена закуски должна быть больше 0", nameof(model.Price)); throw new ArgumentNullException("Цена закуски должна быть больше 0", nameof(model.Price));
} }
_logger.LogInformation("Snack. SnackName:{SnackName}.Price:{ Price}. Id: { Id}", model.SnackName, model.Price, model.Id); _logger.LogInformation("Printed. PrintedName:{PrintedName}.Price:{ Price}. Id: { Id}", model.PrintedName, model.Price, model.Id);
var element = _snackStorage.GetElement(new SnackSearchModel var element = _snackStorage.GetElement(new PrintedSearchModel
{ {
SnackName = model.SnackName PrintedName = model.PrintedName
}); });
if (element != null && element.Id != model.Id) if (element != null && element.Id != model.Id)
{ {

View File

@ -0,0 +1,17 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Extensions.Logging" Version="8.0.0" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\TypographyContracts\TypographyContracts.csproj" />
</ItemGroup>
</Project>

View File

@ -3,9 +3,9 @@ using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using SnackBarDataModels.Models; using TypographyDataModels.Models;
namespace SnackBarContracts.BindingModels namespace TypographyContracts.BindingModels
{ {
public class ComponentBindingModel : IComponentModel public class ComponentBindingModel : IComponentModel
{ {

View File

@ -3,15 +3,15 @@ using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using SnackBarDataModels.Enums; using TypographyDataModels.Enums;
using SnackBarDataModels.Models; using TypographyDataModels.Models;
namespace SnackBarContracts.BindingModels namespace TypographyContracts.BindingModels
{ {
public class OrderBindingModel : IOrderModel public class OrderBindingModel : IOrderModel
{ {
public int Id { get; set; } public int Id { get; set; }
public int SnackId { get; set; } public int PrintedId { get; set; }
public int Count { get; set; } public int Count { get; set; }
public double Sum { get; set; } public double Sum { get; set; }
public OrderStatus Status { get; set; } = OrderStatus.Неизвестен; public OrderStatus Status { get; set; } = OrderStatus.Неизвестен;

View File

@ -0,0 +1,17 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using TypographyDataModels.Models;
namespace TypographyContracts.BindingModels
{
public class PrintedBindingModel : IPrintedModel
{
public int Id { get; set; }
public string PrintedName { get; set; } = string.Empty;
public double Price { get; set; }
public Dictionary<int, (IComponentModel, int)> PrintedComponents { get; set; } = new();
}
}

View File

@ -3,12 +3,12 @@ using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using SnackBarContracts.BindingModels; using TypographyContracts.BindingModels;
using SnackBarContracts.SearchModels; using TypographyContracts.SearchModels;
using SnackBarContracts.ViewModels; using TypographyContracts.ViewModels;
namespace SnackBarContracts.BusinessLogicsContracts namespace TypographyContracts.BusinessLogicsContracts
{ {
public interface IComponentLogic public interface IComponentLogic
{ {

View File

@ -3,12 +3,12 @@ using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using SnackBarContracts.BindingModels; using TypographyContracts.BindingModels;
using SnackBarContracts.SearchModels; using TypographyContracts.SearchModels;
using SnackBarContracts.ViewModels; using TypographyContracts.ViewModels;
namespace SnackBarContracts.BusinessLogicsContracts namespace TypographyContracts.BusinessLogicsContracts
{ {
public interface IOrderLogic public interface IOrderLogic
{ {

View File

@ -0,0 +1,20 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using TypographyContracts.BindingModels;
using TypographyContracts.SearchModels;
using TypographyContracts.ViewModels;
namespace TypographyContracts.BusinessLogicsContracts
{
public interface IPrintedLogic
{
List<PrintedViewModel>? ReadList(PrintedSearchModel? model);
PrintedViewModel? ReadElement(PrintedSearchModel model);
bool Create(PrintedBindingModel model);
bool Update(PrintedBindingModel model);
bool Delete(PrintedBindingModel model);
}
}

View File

@ -4,7 +4,7 @@ using System.Linq;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
namespace SnackBarContracts.SearchModels namespace TypographyContracts.SearchModels
{ {
public class ComponentSearchModel public class ComponentSearchModel
{ {

View File

@ -4,7 +4,7 @@ using System.Linq;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
namespace SnackBarContracts.SearchModels namespace TypographyContracts.SearchModels
{ {
public class OrderSearchModel public class OrderSearchModel
{ {

View File

@ -4,11 +4,11 @@ using System.Linq;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
namespace SnackBarContracts.SearchModels namespace TypographyContracts.SearchModels
{ {
public class SnackSearchModel public class PrintedSearchModel
{ {
public int? Id { get; set; } public int? Id { get; set; }
public string? SnackName { get; set; } public string? PrintedName { get; set; }
} }
} }

View File

@ -1,13 +1,13 @@
using SnackBarContracts.BindingModels; using TypographyContracts.BindingModels;
using SnackBarContracts.SearchModels; using TypographyContracts.SearchModels;
using SnackBarContracts.ViewModels; using TypographyContracts.ViewModels;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
namespace SnackBarContracts.StoragesContracts namespace TypographyContracts.StoragesContracts
{ {
public interface IComponentStorage public interface IComponentStorage
{ {

View File

@ -1,13 +1,13 @@
using SnackBarContracts.BindingModels; using TypographyContracts.BindingModels;
using SnackBarContracts.SearchModels; using TypographyContracts.SearchModels;
using SnackBarContracts.ViewModels; using TypographyContracts.ViewModels;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
namespace SnackBarContracts.StoragesContracts namespace TypographyContracts.StoragesContracts
{ {
public interface IOrderStorage public interface IOrderStorage
{ {

View File

@ -0,0 +1,21 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using TypographyContracts.BindingModels;
using TypographyContracts.SearchModels;
using TypographyContracts.ViewModels;
namespace TypographyContracts.StoragesContracts
{
public interface IPrintedStorage
{
List<PrintedViewModel> GetFullList();
List<PrintedViewModel> GetFilteredList(PrintedSearchModel model);
PrintedViewModel? GetElement(PrintedSearchModel model);
PrintedViewModel? Insert(PrintedBindingModel model);
PrintedViewModel? Update(PrintedBindingModel model);
PrintedViewModel? Delete(PrintedBindingModel model);
}
}

View File

@ -1,4 +1,4 @@
<Project Sdk="Microsoft.NET.Sdk"> <Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup> <PropertyGroup>
<TargetFramework>net6.0</TargetFramework> <TargetFramework>net6.0</TargetFramework>
@ -7,7 +7,7 @@
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<ProjectReference Include="..\SnackBarDataModels\SnackBarDataModels.csproj" /> <ProjectReference Include="..\TypographyDataModels\TypographyDataModels.csproj" />
</ItemGroup> </ItemGroup>
</Project> </Project>

View File

@ -3,10 +3,10 @@ using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using SnackBarDataModels.Models; using TypographyDataModels.Models;
using System.ComponentModel; using System.ComponentModel;
namespace SnackBarContracts.ViewModels namespace TypographyContracts.ViewModels
{ {
public class ComponentViewModel : IComponentModel public class ComponentViewModel : IComponentModel
{ {

View File

@ -3,20 +3,20 @@ using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using SnackBarDataModels.Enums; using TypographyDataModels.Enums;
using SnackBarDataModels.Models; using TypographyDataModels.Models;
using System.ComponentModel; using System.ComponentModel;
namespace SnackBarContracts.ViewModels namespace TypographyContracts.ViewModels
{ {
public class OrderViewModel : IOrderModel public class OrderViewModel : IOrderModel
{ {
[DisplayName("Номер")] [DisplayName("Номер")]
public int Id { get; set; } public int Id { get; set; }
public int SnackId { get; set; } public int PrintedId { get; set; }
[DisplayName("Изделие")] [DisplayName("Изделие")]
public string SnackName { get; set; } = string.Empty; public string PrintedName { get; set; } = string.Empty;
[DisplayName("Количество")] [DisplayName("Количество")]
public int Count { get; set; } public int Count { get; set; }
[DisplayName("Сумма")] [DisplayName("Сумма")]

View File

@ -3,19 +3,19 @@ using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using SnackBarDataModels.Models; using TypographyDataModels.Models;
using System.ComponentModel; using System.ComponentModel;
namespace SnackBarContracts.ViewModels namespace TypographyContracts.ViewModels
{ {
public class SnackViewModel : ISnackModel public class PrintedViewModel : IPrintedModel
{ {
public int Id { get; set; } public int Id { get; set; }
[DisplayName("Название изделия")] [DisplayName("Название изделия")]
public string SnackName { get; set; } = string.Empty; public string PrintedName { get; set; } = string.Empty;
[DisplayName("Цена")] [DisplayName("Цена")]
public double Price { get; set; } public double Price { get; set; }
public Dictionary<int, (IComponentModel, int)> SnackComponents { get; set; } = new(); public Dictionary<int, (IComponentModel, int)> PrintedComponents { get; set; } = new();
} }
} }

View File

@ -4,7 +4,7 @@ using System.Linq;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
namespace SnackBarDataModels.Models namespace TypographyDataModels.Models
{ {
public interface IComponentModel : IId public interface IComponentModel : IId
{ {

View File

@ -4,7 +4,7 @@ using System.Linq;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
namespace SnackBarDataModels namespace TypographyDataModels
{ {
public interface IId public interface IId
{ {

View File

@ -4,11 +4,11 @@ using System.Linq;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
namespace SnackBarDataModels.Enums namespace TypographyDataModels.Enums
{ {
public interface IOrderModel : IId public interface IOrderModel : IId
{ {
int SnackId { get; } int PrintedId { get; }
int Count { get; } int Count { get; }
double Sum { get; } double Sum { get; }
OrderStatus Status { get; } OrderStatus Status { get; }

View File

@ -0,0 +1,16 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace TypographyDataModels.Models
{
public interface IPrintedModel : IId
{
string PrintedName { get; }
double Price { get; }
Dictionary<int, (IComponentModel, int)> PrintedComponents { get; }
}
}

View File

@ -1,4 +1,4 @@
namespace SnackBarDataModels.Enums namespace TypographyDataModels.Enums
{ {
public enum OrderStatus public enum OrderStatus
{ {

View File

@ -3,11 +3,11 @@ using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using SnackBarContracts.BindingModels; using TypographyContracts.BindingModels;
using SnackBarContracts.ViewModels; using TypographyContracts.ViewModels;
using SnackBarDataModels.Models; using TypographyDataModels.Models;
namespace SnackBarListImplement.Models namespace TypographyListImplement.Models
{ {
public class Component : IComponentModel public class Component : IComponentModel
{ {

View File

@ -3,14 +3,14 @@ using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using SnackBarContracts.BindingModels; using TypographyContracts.BindingModels;
using SnackBarContracts.SearchModels; using TypographyContracts.SearchModels;
using SnackBarContracts.StoragesContracts; using TypographyContracts.StoragesContracts;
using SnackBarContracts.ViewModels; using TypographyContracts.ViewModels;
using SnackBarListImplement.Models; using TypographyListImplement.Models;
namespace SnackBarListImplement.Implements namespace TypographyListImplement.Implements
{ {
public class ComponentStorage : IComponentStorage public class ComponentStorage : IComponentStorage
{ {

View File

@ -3,21 +3,21 @@ using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using SnackBarListImplement.Models; using TypographyListImplement.Models;
namespace SnackBarListImplement namespace TypographyListImplement
{ {
public class DataListSingleton public class DataListSingleton
{ {
private static DataListSingleton? _instance; private static DataListSingleton? _instance;
public List<Component> Components { get; set; } public List<Component> Components { get; set; }
public List<Order> Orders { get; set; } public List<Order> Orders { get; set; }
public List<Snack> Snacks { get; set; } public List<Printed> Printeds { get; set; }
private DataListSingleton() private DataListSingleton()
{ {
Components = new List<Component>(); Components = new List<Component>();
Orders = new List<Order>(); Orders = new List<Order>();
Snacks = new List<Snack>(); Printeds = new List<Printed>();
} }
public static DataListSingleton GetInstance() public static DataListSingleton GetInstance()
{ {

View File

@ -3,16 +3,16 @@ using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using SnackBarContracts.BindingModels; using TypographyContracts.BindingModels;
using SnackBarContracts.ViewModels; using TypographyContracts.ViewModels;
using SnackBarDataModels.Enums; using TypographyDataModels.Enums;
using SnackBarDataModels.Models; using TypographyDataModels.Models;
namespace SnackBarListImplement.Models namespace TypographyListImplement.Models
{ {
public class Order : IOrderModel public class Order : IOrderModel
{ {
public int SnackId { get; private set; } public int PrintedId { get; private set; }
public int Count { get; private set; } public int Count { get; private set; }
@ -35,7 +35,7 @@ namespace SnackBarListImplement.Models
return new Order return new Order
{ {
Id = model.Id, Id = model.Id,
SnackId = model.SnackId, PrintedId = model.PrintedId,
Count = model.Count, Count = model.Count,
Sum = model.Sum, Sum = model.Sum,
Status = model.Status, Status = model.Status,
@ -51,7 +51,7 @@ namespace SnackBarListImplement.Models
return; return;
} }
Id = model.Id; Id = model.Id;
SnackId = model.SnackId; PrintedId = model.PrintedId;
Count = model.Count; Count = model.Count;
Sum = model.Sum; Sum = model.Sum;
Status = model.Status; Status = model.Status;
@ -61,7 +61,7 @@ namespace SnackBarListImplement.Models
public OrderViewModel GetViewModel => new() public OrderViewModel GetViewModel => new()
{ {
SnackId = SnackId, PrintedId = PrintedId,
Count = Count, Count = Count,
Sum = Sum, Sum = Sum,
DateCreate = DateCreate, DateCreate = DateCreate,

View File

@ -3,13 +3,13 @@ using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using SnackBarContracts.BindingModels; using TypographyContracts.BindingModels;
using SnackBarContracts.SearchModels; using TypographyContracts.SearchModels;
using SnackBarContracts.StoragesContracts; using TypographyContracts.StoragesContracts;
using SnackBarContracts.ViewModels; using TypographyContracts.ViewModels;
using SnackBarListImplement.Models; using TypographyListImplement.Models;
namespace SnackBarListImplement.Implements namespace TypographyListImplement.Implements
{ {
public class OrderStorage : IOrderStorage public class OrderStorage : IOrderStorage
{ {
@ -25,7 +25,7 @@ namespace SnackBarListImplement.Implements
var result = new List<OrderViewModel>(); var result = new List<OrderViewModel>();
foreach (var order in _source.Orders) foreach (var order in _source.Orders)
{ {
result.Add(AddSnackName(order.GetViewModel)); result.Add(AddPrintedName(order.GetViewModel));
} }
return result; return result;
} }
@ -41,7 +41,7 @@ namespace SnackBarListImplement.Implements
{ {
if (order.Id == model.Id) if (order.Id == model.Id)
{ {
result.Add(AddSnackName(order.GetViewModel)); result.Add(AddPrintedName(order.GetViewModel));
} }
} }
return result; return result;
@ -57,7 +57,7 @@ namespace SnackBarListImplement.Implements
{ {
if (order.Id == model.Id) if (order.Id == model.Id)
{ {
return AddSnackName(order.GetViewModel); return AddPrintedName(order.GetViewModel);
} }
} }
return null; return null;
@ -79,7 +79,7 @@ namespace SnackBarListImplement.Implements
return null; return null;
} }
_source.Orders.Add(newOrder); _source.Orders.Add(newOrder);
return AddSnackName(newOrder.GetViewModel); return AddPrintedName(newOrder.GetViewModel);
} }
public OrderViewModel? Update(OrderBindingModel model) public OrderViewModel? Update(OrderBindingModel model)
@ -89,7 +89,7 @@ namespace SnackBarListImplement.Implements
if (order.Id == model.Id) if (order.Id == model.Id)
{ {
order.Update(model); order.Update(model);
return AddSnackName(order.GetViewModel); return AddPrintedName(order.GetViewModel);
} }
} }
return null; return null;
@ -103,18 +103,18 @@ namespace SnackBarListImplement.Implements
{ {
var element = _source.Orders[i]; var element = _source.Orders[i];
_source.Orders.RemoveAt(i); _source.Orders.RemoveAt(i);
return AddSnackName(element.GetViewModel); return AddPrintedName(element.GetViewModel);
} }
} }
return null; return null;
} }
private OrderViewModel AddSnackName(OrderViewModel model) private OrderViewModel AddPrintedName(OrderViewModel model)
{ {
var selectedSnack = _source.Snacks.Find(snack => snack.Id == model.SnackId); var selectedPrinted = _source.Printeds.Find(printed => printed.Id == model.PrintedId);
if (selectedSnack != null) if (selectedPrinted != null)
{ {
model.SnackName = selectedSnack.SnackName; model.PrintedName = selectedPrinted.PrintedName;
} }
return model; return model;
} }

View File

@ -0,0 +1,51 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using TypographyContracts.BindingModels;
using TypographyContracts.ViewModels;
using TypographyDataModels.Models;
namespace TypographyListImplement.Models
{
public class Printed : IPrintedModel
{
public int Id { get; private set; }
public string PrintedName { get; private set; } = string.Empty;
public double Price { get; private set; }
public Dictionary<int, (IComponentModel, int)> PrintedComponents { get; private set; } = new Dictionary<int, (IComponentModel, int)>();
public static Printed? Create(PrintedBindingModel? model)
{
if (model == null)
{
return null;
}
return new Printed()
{
Id = model.Id,
PrintedName = model.PrintedName,
Price = model.Price,
PrintedComponents = model.PrintedComponents
};
}
public void Update(PrintedBindingModel? model)
{
if (model == null)
{
return;
}
PrintedName = model.PrintedName;
Price = model.Price;
PrintedComponents = model.PrintedComponents;
}
public PrintedViewModel GetViewModel => new()
{
Id = Id,
PrintedName = PrintedName,
Price = Price,
PrintedComponents = PrintedComponents
};
}
}

View File

@ -0,0 +1,111 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.ConstrainedExecution;
using System.Text;
using System.Threading.Tasks;
using TypographyContracts.BindingModels;
using TypographyContracts.SearchModels;
using TypographyContracts.StoragesContracts;
using TypographyContracts.ViewModels;
using TypographyListImplement.Models;
namespace TypographyListImplement.Implements
{
public class PrintedStorage : IPrintedStorage
{
private readonly DataListSingleton _source;
public PrintedStorage()
{
_source = DataListSingleton.GetInstance();
}
public List<PrintedViewModel> GetFullList()
{
var result = new List<PrintedViewModel>();
foreach (var printed in _source.Printeds)
{
result.Add(printed.GetViewModel);
}
return result;
}
public List<PrintedViewModel> GetFilteredList(PrintedSearchModel model)
{
var result = new List<PrintedViewModel>();
if (string.IsNullOrEmpty(model.PrintedName))
{
return result;
}
foreach (var printed in _source.Printeds)
{
if (printed.PrintedName.Contains(model.PrintedName))
{
result.Add(printed.GetViewModel);
}
}
return result;
}
public PrintedViewModel? GetElement(PrintedSearchModel model)
{
if (string.IsNullOrEmpty(model.PrintedName) && !model.Id.HasValue)
{
return null;
}
foreach (var printed in _source.Printeds)
{
if ((!string.IsNullOrEmpty(model.PrintedName) && printed.PrintedName == model.PrintedName) || (model.Id.HasValue && printed.Id == model.Id))
{
return printed.GetViewModel;
}
}
return null;
}
public PrintedViewModel? Insert(PrintedBindingModel model)
{
model.Id = 1;
foreach (var printed in _source.Printeds)
{
if (model.Id <= printed.Id)
{
model.Id = printed.Id + 1;
}
}
var newPrinted = Printed.Create(model);
if (newPrinted == null)
{
return null;
}
_source.Printeds.Add(newPrinted);
return newPrinted.GetViewModel;
}
public PrintedViewModel? Update(PrintedBindingModel model)
{
foreach (var printed in _source.Printeds)
{
if (printed.Id == model.Id)
{
printed.Update(model);
return printed.GetViewModel;
}
}
return null;
}
public PrintedViewModel? Delete(PrintedBindingModel model)
{
for (int i = 0; i < _source.Printeds.Count; ++i)
{
if (_source.Printeds[i].Id == model.Id)
{
var element = _source.Printeds[i];
_source.Printeds.RemoveAt(i);
return element.GetViewModel;
}
}
return null;
}
}
}

View File

@ -7,8 +7,8 @@
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<ProjectReference Include="..\SnackBarContracts\SnackBarContracts.csproj" /> <ProjectReference Include="..\TypographyContracts\TypographyContracts.csproj" />
<ProjectReference Include="..\SnackBarDataModels\SnackBarDataModels.csproj" /> <ProjectReference Include="..\TypographyDataModels\TypographyDataModels.csproj" />
</ItemGroup> </ItemGroup>
</Project> </Project>

View File

@ -1,4 +1,4 @@
namespace SnackBarView namespace TypographyView
{ {
partial class FormComponent partial class FormComponent
{ {

View File

@ -1,11 +1,11 @@
using SnackBarContracts.BindingModels; using TypographyContracts.BindingModels;
using SnackBarContracts.BusinessLogicsContracts; using TypographyContracts.BusinessLogicsContracts;
using SnackBarContracts.SearchModels; using TypographyContracts.SearchModels;
using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging;
using System.Windows.Forms; using System.Windows.Forms;
namespace SnackBarView namespace TypographyView
{ {
public partial class FormComponent : Form public partial class FormComponent : Form
{ {

View File

@ -1,4 +1,4 @@
namespace SnackBarView namespace TypographyView
{ {
partial class FormComponents partial class FormComponents
{ {

View File

@ -7,12 +7,12 @@ using System.Linq;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using System.Windows.Forms; using System.Windows.Forms;
using SnackBarContracts.BindingModels; using TypographyContracts.BindingModels;
using SnackBarContracts.BusinessLogicsContracts; using TypographyContracts.BusinessLogicsContracts;
using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging;
using NLog.Extensions.Logging; using NLog.Extensions.Logging;
namespace SnackBarView namespace TypographyView
{ {
public partial class FormComponents : Form public partial class FormComponents : Form
{ {

View File

@ -1,4 +1,4 @@
namespace SnackBarView namespace TypographyView
{ {
partial class FormCreateOrder partial class FormCreateOrder
{ {
@ -28,24 +28,24 @@
/// </summary> /// </summary>
private void InitializeComponent() private void InitializeComponent()
{ {
labelSnack = new Label(); labelPrinted = new Label();
labelCount = new Label(); labelCount = new Label();
labelSum = new Label(); labelSum = new Label();
comboBoxSnack = new ComboBox(); comboBoxPrinted = new ComboBox();
textBoxCount = new TextBox(); textBoxCount = new TextBox();
textBoxSum = new TextBox(); textBoxSum = new TextBox();
buttonSave = new Button(); buttonSave = new Button();
buttonCancel = new Button(); buttonCancel = new Button();
SuspendLayout(); SuspendLayout();
// //
// labelSnack // labelPrinted
// //
labelSnack.AutoSize = true; labelPrinted.AutoSize = true;
labelSnack.Location = new Point(12, 22); labelPrinted.Location = new Point(12, 22);
labelSnack.Name = "labelSnack"; labelPrinted.Name = "labelPrinted";
labelSnack.Size = new Size(64, 20); labelPrinted.Size = new Size(71, 20);
labelSnack.TabIndex = 0; labelPrinted.TabIndex = 0;
labelSnack.Text = "Закуска:"; labelPrinted.Text = "Изделие:";
// //
// labelCount // labelCount
// //
@ -65,14 +65,14 @@
labelSum.TabIndex = 2; labelSum.TabIndex = 2;
labelSum.Text = "Сумма:"; labelSum.Text = "Сумма:";
// //
// comboBoxSnack // comboBoxPrinted
// //
comboBoxSnack.FormattingEnabled = true; comboBoxPrinted.FormattingEnabled = true;
comboBoxSnack.Location = new Point(111, 19); comboBoxPrinted.Location = new Point(111, 19);
comboBoxSnack.Name = "comboBoxSnack"; comboBoxPrinted.Name = "comboBoxPrinted";
comboBoxSnack.Size = new Size(238, 28); comboBoxPrinted.Size = new Size(238, 28);
comboBoxSnack.TabIndex = 3; comboBoxPrinted.TabIndex = 3;
comboBoxSnack.SelectedIndexChanged += ComboBoxSnack_SelectedIndexChanged; comboBoxPrinted.SelectedIndexChanged += ComboBoxPrinted_SelectedIndexChanged;
// //
// textBoxCount // textBoxCount
// //
@ -118,10 +118,10 @@
Controls.Add(buttonSave); Controls.Add(buttonSave);
Controls.Add(textBoxSum); Controls.Add(textBoxSum);
Controls.Add(textBoxCount); Controls.Add(textBoxCount);
Controls.Add(comboBoxSnack); Controls.Add(comboBoxPrinted);
Controls.Add(labelSum); Controls.Add(labelSum);
Controls.Add(labelCount); Controls.Add(labelCount);
Controls.Add(labelSnack); Controls.Add(labelPrinted);
Name = "FormCreateOrder"; Name = "FormCreateOrder";
Text = "Заказ"; Text = "Заказ";
Load += FormCreateOrder_Load; Load += FormCreateOrder_Load;
@ -131,10 +131,10 @@
#endregion #endregion
private Label labelSnack; private Label labelPrinted;
private Label labelCount; private Label labelCount;
private Label labelSum; private Label labelSum;
private ComboBox comboBoxSnack; private ComboBox comboBoxPrinted;
private TextBox textBoxCount; private TextBox textBoxCount;
private TextBox textBoxSum; private TextBox textBoxSum;
private Button buttonSave; private Button buttonSave;

View File

@ -1,22 +1,22 @@
using SnackBarContracts.BindingModels; using TypographyContracts.BindingModels;
using SnackBarContracts.BusinessLogicsContracts; using TypographyContracts.BusinessLogicsContracts;
using SnackBarContracts.SearchModels; using TypographyContracts.SearchModels;
using SnackBarContracts.ViewModels; using TypographyContracts.ViewModels;
using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging;
using Microsoft.VisualBasic.Logging; using Microsoft.VisualBasic.Logging;
using System.Windows.Forms; using System.Windows.Forms;
namespace SnackBarView namespace TypographyView
{ {
public partial class FormCreateOrder : Form public partial class FormCreateOrder : Form
{ {
private readonly ILogger _logger; private readonly ILogger _logger;
private readonly ISnackLogic _logicIC; private readonly IPrintedLogic _logicIC;
private readonly IOrderLogic _logicO; private readonly IOrderLogic _logicO;
public FormCreateOrder(ILogger<FormCreateOrder> logger, ISnackLogic logicIC, IOrderLogic logicO) public FormCreateOrder(ILogger<FormCreateOrder> logger, IPrintedLogic logicIC, IOrderLogic logicO)
{ {
InitializeComponent(); InitializeComponent();
_logger = logger; _logger = logger;
@ -26,33 +26,33 @@ namespace SnackBarView
private void FormCreateOrder_Load(object sender, EventArgs e) private void FormCreateOrder_Load(object sender, EventArgs e)
{ {
_logger.LogInformation("Loading snack for order"); _logger.LogInformation("Loading printed for order");
try try
{ {
var snackList = _logicIC.ReadList(null); var printedList = _logicIC.ReadList(null);
if (snackList != null) if (printedList != null)
{ {
comboBoxSnack.DisplayMember = "SnackName"; comboBoxPrinted.DisplayMember = "PrintedName";
comboBoxSnack.ValueMember = "Id"; comboBoxPrinted.ValueMember = "Id";
comboBoxSnack.DataSource = snackList; comboBoxPrinted.DataSource = printedList;
comboBoxSnack.SelectedItem = null; comboBoxPrinted.SelectedItem = null;
} }
} }
catch (Exception ex) catch (Exception ex)
{ {
_logger.LogError(ex, "Error during loading snack for order"); _logger.LogError(ex, "Error during loading printed for order");
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
} }
} }
private void CalcSum() private void CalcSum()
{ {
if (comboBoxSnack.SelectedValue != null && !string.IsNullOrEmpty(textBoxCount.Text)) if (comboBoxPrinted.SelectedValue != null && !string.IsNullOrEmpty(textBoxCount.Text))
{ {
try try
{ {
int id = Convert.ToInt32(comboBoxSnack.SelectedValue); int id = Convert.ToInt32(comboBoxPrinted.SelectedValue);
var product = _logicIC.ReadElement(new SnackSearchModel { Id = id }); var product = _logicIC.ReadElement(new PrintedSearchModel { Id = id });
int count = Convert.ToInt32(textBoxCount.Text); int count = Convert.ToInt32(textBoxCount.Text);
textBoxSum.Text = Math.Round(count * (product?.Price ?? 0), 2).ToString(); textBoxSum.Text = Math.Round(count * (product?.Price ?? 0), 2).ToString();
_logger.LogInformation("Calculation of order sum"); _logger.LogInformation("Calculation of order sum");
@ -70,7 +70,7 @@ namespace SnackBarView
CalcSum(); CalcSum();
} }
private void ComboBoxSnack_SelectedIndexChanged(object sender, EventArgs e) private void ComboBoxPrinted_SelectedIndexChanged(object sender, EventArgs e)
{ {
CalcSum(); CalcSum();
} }
@ -82,7 +82,7 @@ namespace SnackBarView
MessageBox.Show("Заполните поле Количество", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); MessageBox.Show("Заполните поле Количество", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
return; return;
} }
if (comboBoxSnack.SelectedValue == null) if (comboBoxPrinted.SelectedValue == null)
{ {
MessageBox.Show("Выберите закуску", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); MessageBox.Show("Выберите закуску", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
return; return;
@ -92,7 +92,7 @@ namespace SnackBarView
{ {
var operationResult = _logicO.CreateOrder(new OrderBindingModel var operationResult = _logicO.CreateOrder(new OrderBindingModel
{ {
SnackId = Convert.ToInt32(comboBoxSnack.SelectedValue), PrintedId = Convert.ToInt32(comboBoxPrinted.SelectedValue),
Count = Convert.ToInt32(textBoxCount.Text), Count = Convert.ToInt32(textBoxCount.Text),
Sum = Convert.ToDouble(textBoxSum.Text) Sum = Convert.ToDouble(textBoxSum.Text)
}); });

View File

@ -1,4 +1,4 @@
namespace SnackBarView namespace TypographyView
{ {
partial class FormMain partial class FormMain
{ {
@ -31,7 +31,7 @@
menuStrip = new MenuStrip(); menuStrip = new MenuStrip();
справочникиToolStripMenuItem = new ToolStripMenuItem(); справочникиToolStripMenuItem = new ToolStripMenuItem();
компонентыToolStripMenuItem = new ToolStripMenuItem(); компонентыToolStripMenuItem = new ToolStripMenuItem();
закускаToolStripMenuItem = new ToolStripMenuItem(); изделиеToolStripMenuItem = new ToolStripMenuItem();
dataGridView = new DataGridView(); dataGridView = new DataGridView();
buttonCreateOrder = new Button(); buttonCreateOrder = new Button();
buttonTakeOrderInWork = new Button(); buttonTakeOrderInWork = new Button();
@ -54,7 +54,7 @@
// //
// справочникиToolStripMenuItem // справочникиToolStripMenuItem
// //
справочникиToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { компонентыToolStripMenuItem, закускаToolStripMenuItem }); справочникиToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { компонентыToolStripMenuItem, изделиеToolStripMenuItem });
справочникиToolStripMenuItem.Name = "справочникиToolStripMenuItem"; справочникиToolStripMenuItem.Name = "справочникиToolStripMenuItem";
справочникиToolStripMenuItem.Size = new Size(117, 24); справочникиToolStripMenuItem.Size = new Size(117, 24);
справочникиToolStripMenuItem.Text = "Справочники"; справочникиToolStripMenuItem.Text = "Справочники";
@ -66,12 +66,12 @@
компонентыToolStripMenuItem.Text = "Компоненты"; компонентыToolStripMenuItem.Text = "Компоненты";
компонентыToolStripMenuItem.Click += КомпонентыToolStripMenuItem_Click; компонентыToolStripMenuItem.Click += КомпонентыToolStripMenuItem_Click;
// //
// закускаToolStripMenuItem // изделиеToolStripMenuItem
// //
закускаToolStripMenuItem.Name = "закускаToolStripMenuItem"; изделиеToolStripMenuItem.Name = "изделиеToolStripMenuItem";
закускаToolStripMenuItem.Size = new Size(224, 26); изделиеToolStripMenuItem.Size = new Size(224, 26);
закускаToolStripMenuItem.Text = "Закуска"; изделиеToolStripMenuItem.Text = "Изделие";
закускаToolStripMenuItem.Click += ЗакускаToolStripMenuItem_Click; изделиеToolStripMenuItem.Click += ЗакускаToolStripMenuItem_Click;
// //
// dataGridView // dataGridView
// //
@ -149,7 +149,7 @@
Controls.Add(menuStrip); Controls.Add(menuStrip);
MainMenuStrip = menuStrip; MainMenuStrip = menuStrip;
Name = "FormMain"; Name = "FormMain";
Text = "Закусочная"; Text = "Типография";
Load += FormMain_Load; Load += FormMain_Load;
menuStrip.ResumeLayout(false); menuStrip.ResumeLayout(false);
menuStrip.PerformLayout(); menuStrip.PerformLayout();
@ -169,6 +169,6 @@
private Button buttonIssuedOrder; private Button buttonIssuedOrder;
private Button buttonUpd; private Button buttonUpd;
private ToolStripMenuItem компонентыToolStripMenuItem; private ToolStripMenuItem компонентыToolStripMenuItem;
private ToolStripMenuItem закускаToolStripMenuItem; private ToolStripMenuItem изделиеToolStripMenuItem;
} }
} }

View File

@ -7,12 +7,12 @@ using System.Linq;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using System.Windows.Forms; using System.Windows.Forms;
using SnackBarContracts.BindingModels; using TypographyContracts.BindingModels;
using SnackBarContracts.BusinessLogicsContracts; using TypographyContracts.BusinessLogicsContracts;
using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging;
using SnackBarDataModels.Enums; using TypographyDataModels.Enums;
namespace SnackBarView namespace TypographyView
{ {
public partial class FormMain : Form public partial class FormMain : Form
{ {
@ -40,8 +40,8 @@ namespace SnackBarView
if (list != null) if (list != null)
{ {
dataGridView.DataSource = list; dataGridView.DataSource = list;
dataGridView.Columns["SnackId"].Visible = false; dataGridView.Columns["PrintedId"].Visible = false;
dataGridView.Columns["SnackName"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill; dataGridView.Columns["PrintedName"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
} }
_logger.LogInformation("Orders loading"); _logger.LogInformation("Orders loading");
} }
@ -63,8 +63,8 @@ namespace SnackBarView
private void ЗакускаToolStripMenuItem_Click(object sender, EventArgs e) private void ЗакускаToolStripMenuItem_Click(object sender, EventArgs e)
{ {
var service = Program.ServiceProvider?.GetService(typeof(FormSnacks)); var service = Program.ServiceProvider?.GetService(typeof(FormPrinteds));
if (service is FormSnacks form) if (service is FormPrinteds form)
{ {
form.ShowDialog(); form.ShowDialog();
} }
@ -159,7 +159,7 @@ namespace SnackBarView
return new OrderBindingModel return new OrderBindingModel
{ {
Id = id, Id = id,
SnackId = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["SnackId"].Value), PrintedId = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["PrintedId"].Value),
Status = Enum.Parse<OrderStatus>(dataGridView.SelectedRows[0].Cells["Status"].Value.ToString()), Status = Enum.Parse<OrderStatus>(dataGridView.SelectedRows[0].Cells["Status"].Value.ToString()),
Count = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Count"].Value), Count = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Count"].Value),
Sum = double.Parse(dataGridView.SelectedRows[0].Cells["Sum"].Value.ToString()), Sum = double.Parse(dataGridView.SelectedRows[0].Cells["Sum"].Value.ToString()),

View File

@ -1,6 +1,6 @@
namespace SnackBarView namespace TypographyView
{ {
partial class FormSnack partial class FormPrinted
{ {
/// <summary> /// <summary>
/// Required designer variable. /// Required designer variable.
@ -50,35 +50,33 @@
// labelName // labelName
// //
labelName.AutoSize = true; labelName.AutoSize = true;
labelName.Location = new Point(10, 7); labelName.Location = new Point(11, 9);
labelName.Name = "labelName"; labelName.Name = "labelName";
labelName.Size = new Size(62, 15); labelName.Size = new Size(80, 20);
labelName.TabIndex = 0; labelName.TabIndex = 0;
labelName.Text = "Название:"; labelName.Text = "Название:";
// //
// labelPrice // labelPrice
// //
labelPrice.AutoSize = true; labelPrice.AutoSize = true;
labelPrice.Location = new Point(10, 42); labelPrice.Location = new Point(11, 56);
labelPrice.Name = "labelPrice"; labelPrice.Name = "labelPrice";
labelPrice.Size = new Size(70, 15); labelPrice.Size = new Size(86, 20);
labelPrice.TabIndex = 1; labelPrice.TabIndex = 1;
labelPrice.Text = "Стоимость:"; labelPrice.Text = "Стоимость:";
// //
// textBoxName // textBoxName
// //
textBoxName.Location = new Point(86, 4); textBoxName.Location = new Point(98, 5);
textBoxName.Margin = new Padding(3, 2, 3, 2);
textBoxName.Name = "textBoxName"; textBoxName.Name = "textBoxName";
textBoxName.Size = new Size(261, 23); textBoxName.Size = new Size(298, 27);
textBoxName.TabIndex = 2; textBoxName.TabIndex = 2;
// //
// textBoxPrice // textBoxPrice
// //
textBoxPrice.Location = new Point(86, 40); textBoxPrice.Location = new Point(98, 53);
textBoxPrice.Margin = new Padding(3, 2, 3, 2);
textBoxPrice.Name = "textBoxPrice"; textBoxPrice.Name = "textBoxPrice";
textBoxPrice.Size = new Size(167, 23); textBoxPrice.Size = new Size(190, 27);
textBoxPrice.TabIndex = 3; textBoxPrice.TabIndex = 3;
// //
// groupBoxComponents // groupBoxComponents
@ -88,21 +86,18 @@
groupBoxComponents.Controls.Add(buttonEdit); groupBoxComponents.Controls.Add(buttonEdit);
groupBoxComponents.Controls.Add(buttonAdd); groupBoxComponents.Controls.Add(buttonAdd);
groupBoxComponents.Controls.Add(dataGridView); groupBoxComponents.Controls.Add(dataGridView);
groupBoxComponents.Location = new Point(10, 64); groupBoxComponents.Location = new Point(11, 85);
groupBoxComponents.Margin = new Padding(3, 2, 3, 2);
groupBoxComponents.Name = "groupBoxComponents"; groupBoxComponents.Name = "groupBoxComponents";
groupBoxComponents.Padding = new Padding(3, 2, 3, 2); groupBoxComponents.Size = new Size(776, 351);
groupBoxComponents.Size = new Size(679, 263);
groupBoxComponents.TabIndex = 4; groupBoxComponents.TabIndex = 4;
groupBoxComponents.TabStop = false; groupBoxComponents.TabStop = false;
groupBoxComponents.Text = "Компоненты"; groupBoxComponents.Text = "Компоненты";
// //
// buttonUpd // buttonUpd
// //
buttonUpd.Location = new Point(544, 154); buttonUpd.Location = new Point(622, 205);
buttonUpd.Margin = new Padding(3, 2, 3, 2);
buttonUpd.Name = "buttonUpd"; buttonUpd.Name = "buttonUpd";
buttonUpd.Size = new Size(103, 27); buttonUpd.Size = new Size(118, 36);
buttonUpd.TabIndex = 4; buttonUpd.TabIndex = 4;
buttonUpd.Text = "Обновить"; buttonUpd.Text = "Обновить";
buttonUpd.UseVisualStyleBackColor = true; buttonUpd.UseVisualStyleBackColor = true;
@ -110,10 +105,9 @@
// //
// buttonDel // buttonDel
// //
buttonDel.Location = new Point(544, 113); buttonDel.Location = new Point(622, 151);
buttonDel.Margin = new Padding(3, 2, 3, 2);
buttonDel.Name = "buttonDel"; buttonDel.Name = "buttonDel";
buttonDel.Size = new Size(103, 27); buttonDel.Size = new Size(118, 36);
buttonDel.TabIndex = 3; buttonDel.TabIndex = 3;
buttonDel.Text = "Удалить"; buttonDel.Text = "Удалить";
buttonDel.UseVisualStyleBackColor = true; buttonDel.UseVisualStyleBackColor = true;
@ -121,10 +115,9 @@
// //
// buttonEdit // buttonEdit
// //
buttonEdit.Location = new Point(544, 74); buttonEdit.Location = new Point(622, 99);
buttonEdit.Margin = new Padding(3, 2, 3, 2);
buttonEdit.Name = "buttonEdit"; buttonEdit.Name = "buttonEdit";
buttonEdit.Size = new Size(103, 27); buttonEdit.Size = new Size(118, 36);
buttonEdit.TabIndex = 2; buttonEdit.TabIndex = 2;
buttonEdit.Text = "Изменить"; buttonEdit.Text = "Изменить";
buttonEdit.UseVisualStyleBackColor = true; buttonEdit.UseVisualStyleBackColor = true;
@ -132,10 +125,9 @@
// //
// buttonAdd // buttonAdd
// //
buttonAdd.Location = new Point(544, 31); buttonAdd.Location = new Point(622, 41);
buttonAdd.Margin = new Padding(3, 2, 3, 2);
buttonAdd.Name = "buttonAdd"; buttonAdd.Name = "buttonAdd";
buttonAdd.Size = new Size(103, 27); buttonAdd.Size = new Size(118, 36);
buttonAdd.TabIndex = 1; buttonAdd.TabIndex = 1;
buttonAdd.Text = "Добавить"; buttonAdd.Text = "Добавить";
buttonAdd.UseVisualStyleBackColor = true; buttonAdd.UseVisualStyleBackColor = true;
@ -148,13 +140,12 @@
dataGridView.BackgroundColor = SystemColors.ControlLightLight; dataGridView.BackgroundColor = SystemColors.ControlLightLight;
dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize; dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
dataGridView.Columns.AddRange(new DataGridViewColumn[] { Columnid, ColumnName, ColumnCount }); dataGridView.Columns.AddRange(new DataGridViewColumn[] { Columnid, ColumnName, ColumnCount });
dataGridView.Location = new Point(5, 20); dataGridView.Location = new Point(6, 27);
dataGridView.Margin = new Padding(3, 2, 3, 2);
dataGridView.Name = "dataGridView"; dataGridView.Name = "dataGridView";
dataGridView.ReadOnly = true; dataGridView.ReadOnly = true;
dataGridView.RowHeadersWidth = 51; dataGridView.RowHeadersWidth = 51;
dataGridView.RowTemplate.Height = 29; dataGridView.RowTemplate.Height = 29;
dataGridView.Size = new Size(497, 239); dataGridView.Size = new Size(568, 319);
dataGridView.TabIndex = 0; dataGridView.TabIndex = 0;
// //
// Columnid // Columnid
@ -183,10 +174,9 @@
// //
// buttonSave // buttonSave
// //
buttonSave.Location = new Point(478, 332); buttonSave.Location = new Point(546, 443);
buttonSave.Margin = new Padding(3, 2, 3, 2);
buttonSave.Name = "buttonSave"; buttonSave.Name = "buttonSave";
buttonSave.Size = new Size(103, 27); buttonSave.Size = new Size(118, 36);
buttonSave.TabIndex = 5; buttonSave.TabIndex = 5;
buttonSave.Text = "Сохранить"; buttonSave.Text = "Сохранить";
buttonSave.UseVisualStyleBackColor = true; buttonSave.UseVisualStyleBackColor = true;
@ -194,20 +184,19 @@
// //
// buttonCancel // buttonCancel
// //
buttonCancel.Location = new Point(586, 332); buttonCancel.Location = new Point(670, 443);
buttonCancel.Margin = new Padding(3, 2, 3, 2);
buttonCancel.Name = "buttonCancel"; buttonCancel.Name = "buttonCancel";
buttonCancel.Size = new Size(103, 27); buttonCancel.Size = new Size(118, 36);
buttonCancel.TabIndex = 6; buttonCancel.TabIndex = 6;
buttonCancel.Text = "Отмена"; buttonCancel.Text = "Отмена";
buttonCancel.UseVisualStyleBackColor = true; buttonCancel.UseVisualStyleBackColor = true;
buttonCancel.Click += ButtonCancel_Click; buttonCancel.Click += ButtonCancel_Click;
// //
// FormSnack // FormPrinted
// //
AutoScaleDimensions = new SizeF(7F, 15F); AutoScaleDimensions = new SizeF(8F, 20F);
AutoScaleMode = AutoScaleMode.Font; AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(700, 368); ClientSize = new Size(800, 491);
Controls.Add(buttonCancel); Controls.Add(buttonCancel);
Controls.Add(buttonSave); Controls.Add(buttonSave);
Controls.Add(groupBoxComponents); Controls.Add(groupBoxComponents);
@ -215,10 +204,9 @@
Controls.Add(textBoxName); Controls.Add(textBoxName);
Controls.Add(labelPrice); Controls.Add(labelPrice);
Controls.Add(labelName); Controls.Add(labelName);
Margin = new Padding(3, 2, 3, 2); Name = "FormPrinted";
Name = "FormSnack"; Text = "Изделия";
Text = "Закуски"; Load += FormPrinted_Load;
Load += FormSnack_Load;
groupBoxComponents.ResumeLayout(false); groupBoxComponents.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)dataGridView).EndInit(); ((System.ComponentModel.ISupportInitialize)dataGridView).EndInit();
ResumeLayout(false); ResumeLayout(false);

View File

@ -7,55 +7,55 @@ using System.Linq;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using System.Windows.Forms; using System.Windows.Forms;
using SnackBarContracts.BindingModels; using TypographyContracts.BindingModels;
using SnackBarContracts.BusinessLogicsContracts; using TypographyContracts.BusinessLogicsContracts;
using SnackBarContracts.SearchModels; using TypographyContracts.SearchModels;
using SnackBarDataModels.Models; using TypographyDataModels.Models;
using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging;
using Microsoft.VisualBasic.Logging; using Microsoft.VisualBasic.Logging;
using NLog.Extensions.Logging; using NLog.Extensions.Logging;
namespace SnackBarView namespace TypographyView
{ {
public partial class FormSnack : Form public partial class FormPrinted : Form
{ {
private readonly ILogger _logger; private readonly ILogger _logger;
private readonly ISnackLogic _logic; private readonly IPrintedLogic _logic;
private int? _id; private int? _id;
private Dictionary<int, (IComponentModel, int)> _snackComponents; private Dictionary<int, (IComponentModel, int)> _printedComponents;
public int Id { set { _id = value; } } public int Id { set { _id = value; } }
public FormSnack(ILogger<FormSnack> logger, ISnackLogic logic) public FormPrinted(ILogger<FormPrinted> logger, IPrintedLogic logic)
{ {
InitializeComponent(); InitializeComponent();
_logger = logger; _logger = logger;
_logic = logic; _logic = logic;
_snackComponents = new Dictionary<int, (IComponentModel, int)>(); _printedComponents = new Dictionary<int, (IComponentModel, int)>();
} }
private void FormSnack_Load(object sender, EventArgs e) private void FormPrinted_Load(object sender, EventArgs e)
{ {
if (_id.HasValue) if (_id.HasValue)
{ {
_logger.LogInformation("Snack loading"); _logger.LogInformation("Printed loading");
try try
{ {
var view = _logic.ReadElement(new SnackSearchModel { Id = _id.Value }); var view = _logic.ReadElement(new PrintedSearchModel { Id = _id.Value });
if (view != null) if (view != null)
{ {
textBoxName.Text = view.SnackName; textBoxName.Text = view.PrintedName;
textBoxPrice.Text = view.Price.ToString(); textBoxPrice.Text = view.Price.ToString();
_snackComponents = view.SnackComponents ?? new Dictionary<int, (IComponentModel, int)>(); _printedComponents = view.PrintedComponents ?? new Dictionary<int, (IComponentModel, int)>();
LoadData(); LoadData();
} }
} }
catch (Exception ex) catch (Exception ex)
{ {
_logger.LogError(ex, "Snack loading error"); _logger.LogError(ex, "Printed loading error");
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
} }
} }
@ -63,15 +63,15 @@ namespace SnackBarView
private void LoadData() private void LoadData()
{ {
_logger.LogInformation("Snack components loading"); _logger.LogInformation("Printed components loading");
try try
{ {
if (_snackComponents != null) if (_printedComponents != null)
{ {
dataGridView.Rows.Clear(); dataGridView.Rows.Clear();
foreach (var snackC in _snackComponents) foreach (var printedC in _printedComponents)
{ {
dataGridView.Rows.Add(new object[] { snackC.Key, snackC.Value.Item1.ComponentName, snackC.Value.Item2 }); dataGridView.Rows.Add(new object[] { printedC.Key, printedC.Value.Item1.ComponentName, printedC.Value.Item2 });
} }
textBoxPrice.Text = CalcPrice().ToString(); textBoxPrice.Text = CalcPrice().ToString();
} }
@ -85,8 +85,8 @@ namespace SnackBarView
private void ButtonAdd_Click(object sender, EventArgs e) private void ButtonAdd_Click(object sender, EventArgs e)
{ {
var service = Program.ServiceProvider?.GetService(typeof(FormSnackComponent)); var service = Program.ServiceProvider?.GetService(typeof(FormPrintedComponent));
if (service is FormSnackComponent form) if (service is FormPrintedComponent form)
{ {
if (form.ShowDialog() == DialogResult.OK) if (form.ShowDialog() == DialogResult.OK)
{ {
@ -95,13 +95,13 @@ namespace SnackBarView
return; return;
} }
_logger.LogInformation("Adding new component: {ComponentName} - {Count}", form.ComponentModel.ComponentName, form.Count); _logger.LogInformation("Adding new component: {ComponentName} - {Count}", form.ComponentModel.ComponentName, form.Count);
if (_snackComponents.ContainsKey(form.Id)) if (_printedComponents.ContainsKey(form.Id))
{ {
_snackComponents[form.Id] = (form.ComponentModel, form.Count); _printedComponents[form.Id] = (form.ComponentModel, form.Count);
} }
else else
{ {
_snackComponents.Add(form.Id, (form.ComponentModel, form.Count)); _printedComponents.Add(form.Id, (form.ComponentModel, form.Count));
} }
LoadData(); LoadData();
} }
@ -112,12 +112,12 @@ namespace SnackBarView
{ {
if (dataGridView.SelectedRows.Count == 1) if (dataGridView.SelectedRows.Count == 1)
{ {
var service = Program.ServiceProvider?.GetService(typeof(FormSnackComponent)); var service = Program.ServiceProvider?.GetService(typeof(FormPrintedComponent));
if (service is FormSnackComponent form) if (service is FormPrintedComponent form)
{ {
int id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells[0].Value); int id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells[0].Value);
form.Id = id; form.Id = id;
form.Count = _snackComponents[id].Item2; form.Count = _printedComponents[id].Item2;
if (form.ShowDialog() == DialogResult.OK) if (form.ShowDialog() == DialogResult.OK)
{ {
if (form.ComponentModel == null) if (form.ComponentModel == null)
@ -125,7 +125,7 @@ namespace SnackBarView
return; return;
} }
_logger.LogInformation("Component editing: {ComponentName} - {Count}", form.ComponentModel.ComponentName, form.Count); _logger.LogInformation("Component editing: {ComponentName} - {Count}", form.ComponentModel.ComponentName, form.Count);
_snackComponents[form.Id] = (form.ComponentModel, form.Count); _printedComponents[form.Id] = (form.ComponentModel, form.Count);
LoadData(); LoadData();
} }
} }
@ -142,7 +142,7 @@ namespace SnackBarView
{ {
_logger.LogInformation("Deletion of component: {ComponentName} - {Count}", dataGridView.SelectedRows[0].Cells[1].Value, _logger.LogInformation("Deletion of component: {ComponentName} - {Count}", dataGridView.SelectedRows[0].Cells[1].Value,
dataGridView.SelectedRows[0].Cells[2].Value); dataGridView.SelectedRows[0].Cells[2].Value);
_snackComponents?.Remove(Convert.ToInt32(dataGridView.SelectedRows[0].Cells[0].Value)); _printedComponents?.Remove(Convert.ToInt32(dataGridView.SelectedRows[0].Cells[0].Value));
} }
catch (Exception ex) catch (Exception ex)
{ {
@ -170,20 +170,20 @@ namespace SnackBarView
MessageBox.Show("Заполните цену", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); MessageBox.Show("Заполните цену", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
return; return;
} }
if (_snackComponents == null || _snackComponents.Count == 0) if (_printedComponents == null || _printedComponents.Count == 0)
{ {
MessageBox.Show("Заполните компоненты", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); MessageBox.Show("Заполните компоненты", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
return; return;
} }
_logger.LogInformation("Snack saving"); _logger.LogInformation("Printed saving");
try try
{ {
var model = new SnackBindingModel var model = new PrintedBindingModel
{ {
Id = _id ?? 0, Id = _id ?? 0,
SnackName = textBoxName.Text, PrintedName = textBoxName.Text,
Price = Convert.ToDouble(textBoxPrice.Text), Price = Convert.ToDouble(textBoxPrice.Text),
SnackComponents = _snackComponents PrintedComponents = _printedComponents
}; };
var operationResult = _id.HasValue ? _logic.Update(model) : _logic.Create(model); var operationResult = _id.HasValue ? _logic.Update(model) : _logic.Create(model);
if (!operationResult) if (!operationResult)
@ -196,7 +196,7 @@ namespace SnackBarView
} }
catch (Exception ex) catch (Exception ex)
{ {
_logger.LogError(ex, "Snack saving error"); _logger.LogError(ex, "Printed saving error");
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
} }
} }
@ -210,7 +210,7 @@ namespace SnackBarView
private double CalcPrice() private double CalcPrice()
{ {
double price = 0; double price = 0;
foreach (var elem in _snackComponents) foreach (var elem in _printedComponents)
{ {
price += ((elem.Value.Item1?.Cost ?? 0) * elem.Value.Item2); price += ((elem.Value.Item1?.Cost ?? 0) * elem.Value.Item2);
} }

View File

@ -1,6 +1,6 @@
namespace SnackBarView namespace TypographyView
{ {
partial class FormSnackComponent partial class FormPrintedComponent
{ {
/// <summary> /// <summary>
/// Required designer variable. /// Required designer variable.
@ -89,7 +89,7 @@
buttonCancel.UseVisualStyleBackColor = true; buttonCancel.UseVisualStyleBackColor = true;
buttonCancel.Click += ButtonCancel_Click; buttonCancel.Click += ButtonCancel_Click;
// //
// FormSnackComponent // FormPrintedComponent
// //
AutoScaleDimensions = new SizeF(8F, 20F); AutoScaleDimensions = new SizeF(8F, 20F);
AutoScaleMode = AutoScaleMode.Font; AutoScaleMode = AutoScaleMode.Font;
@ -100,8 +100,8 @@
Controls.Add(comboBoxComponent); Controls.Add(comboBoxComponent);
Controls.Add(labelCount); Controls.Add(labelCount);
Controls.Add(labelComponent); Controls.Add(labelComponent);
Name = "FormSnackComponent"; Name = "FormPrintedComponent";
Text = "Компонент закуски"; Text = "Компонент изделия";
ResumeLayout(false); ResumeLayout(false);
PerformLayout(); PerformLayout();
} }

View File

@ -7,13 +7,13 @@ using System.Linq;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using System.Windows.Forms; using System.Windows.Forms;
using SnackBarContracts.BusinessLogicsContracts; using TypographyContracts.BusinessLogicsContracts;
using SnackBarContracts.ViewModels; using TypographyContracts.ViewModels;
using SnackBarDataModels.Models; using TypographyDataModels.Models;
namespace SnackBarView namespace TypographyView
{ {
public partial class FormSnackComponent : Form public partial class FormPrintedComponent : Form
{ {
private readonly List<ComponentViewModel>? _list; private readonly List<ComponentViewModel>? _list;
public int Id public int Id
@ -51,7 +51,7 @@ namespace SnackBarView
set { textBoxCount.Text = value.ToString(); } set { textBoxCount.Text = value.ToString(); }
} }
public FormSnackComponent(IComponentLogic logic) public FormPrintedComponent(IComponentLogic logic)
{ {
InitializeComponent(); InitializeComponent();
_list = logic.ReadList(null); _list = logic.ReadList(null);

View File

@ -1,6 +1,6 @@
namespace SnackBarView namespace TypographyView
{ {
partial class FormSnacks partial class FormPrinteds
{ {
/// <summary> /// <summary>
/// Required designer variable. /// Required designer variable.
@ -87,7 +87,7 @@
buttonUpd.UseVisualStyleBackColor = true; buttonUpd.UseVisualStyleBackColor = true;
buttonUpd.Click += ButtonUpd_Click; buttonUpd.Click += ButtonUpd_Click;
// //
// FormSnacks // FormPrinteds
// //
AutoScaleDimensions = new SizeF(8F, 20F); AutoScaleDimensions = new SizeF(8F, 20F);
AutoScaleMode = AutoScaleMode.Font; AutoScaleMode = AutoScaleMode.Font;
@ -97,9 +97,9 @@
Controls.Add(buttonEdit); Controls.Add(buttonEdit);
Controls.Add(buttonAdd); Controls.Add(buttonAdd);
Controls.Add(dataGridView); Controls.Add(dataGridView);
Name = "FormSnacks"; Name = "FormPrinteds";
Text = "Закуски"; Text = "Изделия";
Load += FormSnacks_Load; Load += FormPrinteds_Load;
((System.ComponentModel.ISupportInitialize)dataGridView).EndInit(); ((System.ComponentModel.ISupportInitialize)dataGridView).EndInit();
ResumeLayout(false); ResumeLayout(false);
} }

View File

@ -7,26 +7,26 @@ using System.Linq;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using System.Windows.Forms; using System.Windows.Forms;
using SnackBarContracts.BindingModels; using TypographyContracts.BindingModels;
using SnackBarContracts.BusinessLogicsContracts; using TypographyContracts.BusinessLogicsContracts;
using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging;
namespace SnackBarView namespace TypographyView
{ {
public partial class FormSnacks : Form public partial class FormPrinteds : Form
{ {
private readonly ILogger _logger; private readonly ILogger _logger;
private readonly ISnackLogic _logic; private readonly IPrintedLogic _logic;
public FormSnacks(ILogger<FormSnacks> logger, ISnackLogic logic) public FormPrinteds(ILogger<FormPrinteds> logger, IPrintedLogic logic)
{ {
InitializeComponent(); InitializeComponent();
_logger = logger; _logger = logger;
_logic = logic; _logic = logic;
} }
private void FormSnacks_Load(object sender, EventArgs e) private void FormPrinteds_Load(object sender, EventArgs e)
{ {
LoadData(); LoadData();
} }
@ -40,8 +40,8 @@ namespace SnackBarView
{ {
dataGridView.DataSource = list; dataGridView.DataSource = list;
dataGridView.Columns["Id"].Visible = false; dataGridView.Columns["Id"].Visible = false;
dataGridView.Columns["SnackName"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill; dataGridView.Columns["PrintedName"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
dataGridView.Columns["SnackComponents"].Visible = false; dataGridView.Columns["PrintedComponents"].Visible = false;
} }
_logger.LogInformation("Ice creams loading"); _logger.LogInformation("Ice creams loading");
} }
@ -54,8 +54,8 @@ namespace SnackBarView
private void ButtonAdd_Click(object sender, EventArgs e) private void ButtonAdd_Click(object sender, EventArgs e)
{ {
var service = Program.ServiceProvider?.GetService(typeof(FormSnack)); var service = Program.ServiceProvider?.GetService(typeof(FormPrinted));
if (service is FormSnack form) if (service is FormPrinted form)
{ {
if (form.ShowDialog() == DialogResult.OK) if (form.ShowDialog() == DialogResult.OK)
{ {
@ -68,8 +68,8 @@ namespace SnackBarView
{ {
if (dataGridView.SelectedRows.Count == 1) if (dataGridView.SelectedRows.Count == 1)
{ {
var service = Program.ServiceProvider?.GetService(typeof(FormSnack)); var service = Program.ServiceProvider?.GetService(typeof(FormPrinted));
if (service is FormSnack form) if (service is FormPrinted form)
{ {
form.Id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value); form.Id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
if (form.ShowDialog() == DialogResult.OK) if (form.ShowDialog() == DialogResult.OK)
@ -90,7 +90,7 @@ namespace SnackBarView
_logger.LogInformation("Deletion of ice cream"); _logger.LogInformation("Deletion of ice cream");
try try
{ {
if (!_logic.Delete(new SnackBindingModel { Id = id })) if (!_logic.Delete(new PrintedBindingModel { Id = id }))
{ {
throw new Exception("Ошибка при удалении. Дополнительная информация в логах."); throw new Exception("Ошибка при удалении. Дополнительная информация в логах.");
} }

View File

@ -1,12 +1,12 @@
using SnackBarBusinessLogic.BusinessLogics; using TypographyBusinessLogic.BusinessLogics;
using SnackBarContracts.BusinessLogicsContracts; using TypographyContracts.BusinessLogicsContracts;
using SnackBarContracts.StoragesContracts; using TypographyContracts.StoragesContracts;
using SnackBarListImplement.Implements; using TypographyListImplement.Implements;
using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging;
using NLog.Extensions.Logging; using NLog.Extensions.Logging;
namespace SnackBarView namespace TypographyView
{ {
internal static class Program internal static class Program
{ {
@ -35,19 +35,19 @@ namespace SnackBarView
}); });
services.AddTransient<IComponentStorage, ComponentStorage>(); services.AddTransient<IComponentStorage, ComponentStorage>();
services.AddTransient<IOrderStorage, OrderStorage>(); services.AddTransient<IOrderStorage, OrderStorage>();
services.AddTransient<ISnackStorage, SnackStorage>(); services.AddTransient<IPrintedStorage, PrintedStorage>();
services.AddTransient<IComponentLogic, ComponentLogic>(); services.AddTransient<IComponentLogic, ComponentLogic>();
services.AddTransient<IOrderLogic, OrderLogic>(); services.AddTransient<IOrderLogic, OrderLogic>();
services.AddTransient<ISnackLogic, SnackLogic>(); services.AddTransient<IPrintedLogic, PrintedLogic>();
services.AddTransient<FormMain>(); services.AddTransient<FormMain>();
services.AddTransient<FormComponent>(); services.AddTransient<FormComponent>();
services.AddTransient<FormComponents>(); services.AddTransient<FormComponents>();
services.AddTransient<FormCreateOrder>(); services.AddTransient<FormCreateOrder>();
services.AddTransient<FormSnack>(); services.AddTransient<FormPrinted>();
services.AddTransient<FormSnackComponent>(); services.AddTransient<FormPrintedComponent>();
services.AddTransient<FormSnacks>(); services.AddTransient<FormPrinteds>();
} }
} }
} }

View File

@ -8,7 +8,7 @@
// </auto-generated> // </auto-generated>
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
namespace SnackBarView.Properties { namespace TypographyView.Properties {
using System; using System;
@ -39,7 +39,7 @@ namespace SnackBarView.Properties {
internal static global::System.Resources.ResourceManager ResourceManager { internal static global::System.Resources.ResourceManager ResourceManager {
get { get {
if (object.ReferenceEquals(resourceMan, null)) { if (object.ReferenceEquals(resourceMan, null)) {
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("SnackBarView.Properties.Resources", typeof(Resources).Assembly); global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("TypographyView.Properties.Resources", typeof(Resources).Assembly);
resourceMan = temp; resourceMan = temp;
} }
return resourceMan; return resourceMan;

View File

@ -9,17 +9,14 @@
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="NLog" Version="5.2.8" />
<PackageReference Include="NLog.Extensions.Logging" Version="5.3.8" /> <PackageReference Include="NLog.Extensions.Logging" Version="5.3.8" />
<PackageReference Include="NLog.Schema" Version="5.2.8" />
<PackageReference Include="NLog.Web.AspNetCore" Version="5.3.8" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ProjectReference Include="..\SnackBarBusinessLogic\SnackBarBusinessLogic.csproj" /> <ProjectReference Include="..\TypographyBusinessLogic\TypographyBusinessLogic.csproj" />
<ProjectReference Include="..\SnackBarContracts\SnackBarContracts.csproj" /> <ProjectReference Include="..\TypographyContracts\TypographyContracts.csproj" />
<ProjectReference Include="..\SnackBarDataModels\SnackBarDataModels.csproj" /> <ProjectReference Include="..\TypographyDataModels\TypographyDataModels.csproj" />
<ProjectReference Include="..\SnackBarListImplement\SnackBarListImplement.csproj" /> <ProjectReference Include="..\TypographyListImplement\TypographyListImplement.csproj" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>

View File

@ -3,15 +3,15 @@ Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17 # Visual Studio Version 17
VisualStudioVersion = 17.8.34525.116 VisualStudioVersion = 17.8.34525.116
MinimumVisualStudioVersion = 10.0.40219.1 MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SnackBarView", "SnackBarView.csproj", "{F33DFCDC-9D11-44B7-9A5B-794E500A2B7B}" Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TypographyView", "TypographyView.csproj", "{F33DFCDC-9D11-44B7-9A5B-794E500A2B7B}"
EndProject EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SnackBarListImplement", "..\SnackBarListImplement\SnackBarListImplement.csproj", "{9D223B95-71A3-4914-9532-A4D8B31288FD}" Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TypographyListImplement", "..\TypographyListImplement\TypographyListImplement.csproj", "{9D223B95-71A3-4914-9532-A4D8B31288FD}"
EndProject EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SnackBarDataModels", "..\SnackBarDataModels\SnackBarDataModels.csproj", "{11F46ADA-6833-42AD-BF19-78A7826BC741}" Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TypographyDataModels", "..\TypographyDataModels\TypographyDataModels.csproj", "{11F46ADA-6833-42AD-BF19-78A7826BC741}"
EndProject EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SnackBarContracts", "..\SnackBarContracts\SnackBarContracts.csproj", "{E8B5103A-3CAB-4C14-9DC8-6FFF40CA0D34}" Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TypographyContracts", "..\TypographyContracts\TypographyContracts.csproj", "{E8B5103A-3CAB-4C14-9DC8-6FFF40CA0D34}"
EndProject EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SnackBarBusinessLogic", "..\SnackBarBusinessLogic\SnackBarBusinessLogic.csproj", "{1057A33D-538D-4E7F-862B-1FF8E9E021A0}" Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TypographyBusinessLogic", "..\TypographyBusinessLogic\TypographyBusinessLogic.csproj", "{1057A33D-538D-4E7F-862B-1FF8E9E021A0}"
EndProject EndProject
Global Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution GlobalSection(SolutionConfigurationPlatforms) = preSolution