diff --git a/ConfectionaryBusinessLogic/ConfectioneryBusinessLogic.csproj b/ConfectionaryBusinessLogic/EkzamenBusinessLogic.csproj
similarity index 79%
rename from ConfectionaryBusinessLogic/ConfectioneryBusinessLogic.csproj
rename to ConfectionaryBusinessLogic/EkzamenBusinessLogic.csproj
index 7aee55c..5b4bd62 100644
--- a/ConfectionaryBusinessLogic/ConfectioneryBusinessLogic.csproj
+++ b/ConfectionaryBusinessLogic/EkzamenBusinessLogic.csproj
@@ -11,7 +11,7 @@
-
+
diff --git a/ConfectionaryBusinessLogic/GroupLogic.cs b/ConfectionaryBusinessLogic/GroupLogic.cs
new file mode 100644
index 0000000..42173ff
--- /dev/null
+++ b/ConfectionaryBusinessLogic/GroupLogic.cs
@@ -0,0 +1,56 @@
+using EkzamenContracts.BindingModels;
+using EkzamenContracts.BusinessLogicsContracts;
+using EkzamenContracts.SearchModels;
+using EkzamenContracts.StoragesContract;
+using EkzamenContracts.ViewModels;
+using Microsoft.Extensions.Logging;
+
+namespace EkzamenBusinessLogic
+{
+ public class GroupLogic : IGroupLogic
+ {
+ private readonly ILogger _logger;
+ private readonly IGroupStorage _orderStorage;
+
+ public GroupLogic(ILogger logger, IGroupStorage orderStorage)
+ {
+ _logger = logger;
+ _orderStorage = orderStorage;
+ }
+
+ public bool CreateGroup(GroupBindingModel model)
+ {
+ CheckModel(model);
+ if (_orderStorage.Insert(model) == null)
+ {
+ _logger.LogWarning("Insert operation failed");
+ return false;
+ }
+ return true;
+ }
+
+ public List? ReadList(GroupSearchModel? model)
+ {
+ _logger.LogInformation("ReadList. OrderName.Id:{ Id} ", model?.Id);
+ var list = (model == null) ? _orderStorage.GetFullList() :
+ _orderStorage.GetFilteredList(model);
+ if (list == null)
+ {
+ _logger.LogWarning("ReadList return null list");
+ return null;
+ }
+ _logger.LogInformation("ReadList. Count:{Count}", list.Count);
+ return list;
+ }
+
+ private bool CheckModel(GroupBindingModel model)
+ {
+ if (model == null)
+ {
+ throw new ArgumentNullException(nameof(model));
+ }
+
+ return true;
+ }
+ }
+}
diff --git a/ConfectionaryBusinessLogic/OrderLogic.cs b/ConfectionaryBusinessLogic/OrderLogic.cs
deleted file mode 100644
index 1471185..0000000
--- a/ConfectionaryBusinessLogic/OrderLogic.cs
+++ /dev/null
@@ -1,114 +0,0 @@
-using ConfectioneryContracts.BindingModels;
-using ConfectioneryContracts.BusinessLogicsContracts;
-using ConfectioneryContracts.SearchModels;
-using ConfectioneryContracts.StoragesContract;
-using ConfectioneryContracts.ViewModels;
-using ConfectioneryDataModels.Enums;
-using Microsoft.Extensions.Logging;
-
-namespace ConfectioneryBusinessLogic.BusinessLogics
-{
- public class OrderLogic : IOrderLogic
- {
- private readonly ILogger _logger;
- private readonly IOrderStorage _orderStorage;
-
- public OrderLogic(ILogger logger, IOrderStorage orderStorage)
- {
- _logger = logger;
- _orderStorage = orderStorage;
- }
-
- public bool CreateOrder(OrderBindingModel model)
- {
- CheckModel(model);
- if (model.Status != OrderStatus.Неизвестен)
- {
- throw new ArgumentException(
- $"Статус заказа должен быть {OrderStatus.Неизвестен}", nameof(model));
- }
- model.Status = OrderStatus.Принят;
- model.DateCreate = DateTime.Now;
- if (_orderStorage.Insert(model) == null)
- {
- _logger.LogWarning("Insert operation failed");
- return false;
- }
- return true;
- }
-
- public bool TakeOrderInWork(OrderBindingModel model) => SetOrderStatus(model, OrderStatus.Выполняется);
- public bool DeliveryOrder(OrderBindingModel model) => SetOrderStatus(model, OrderStatus.Выдан);
- public bool FinishOrder(OrderBindingModel model)
- {
- model.DateImplement = DateTime.Now;
- return SetOrderStatus(model, OrderStatus.Готов);
- }
-
- public List? ReadList(OrderSearchModel? model)
- {
- _logger.LogInformation("ReadList. OrderName.Id:{ Id} ", model?.Id);
- var list = (model == null) ? _orderStorage.GetFullList() :
- _orderStorage.GetFilteredList(model);
- if (list == null)
- {
- _logger.LogWarning("ReadList return null list");
- return null;
- }
- _logger.LogInformation("ReadList. Count:{Count}", list.Count);
- return list;
- }
-
- private bool CheckModel(OrderBindingModel model)
- {
- if (model == null)
- {
- throw new ArgumentNullException(nameof(model));
- }
- if (model.Count <= 0)
- {
- throw new ArgumentException("Количество изделий в заказе должно быть больше 0", nameof(model.Count));
- }
- if (model.Sum <= 0)
- {
- throw new ArgumentException("Суммарная стоимость заказа должна быть больше 0", nameof(model.Sum));
- }
- if (model.DateCreate > model.DateImplement)
- {
- throw new ArgumentException("Время создания заказа не может быть больше времени его выполнения", nameof(model.DateImplement));
- }
- return true;
- }
-
- private bool SetOrderStatus(OrderBindingModel model, OrderStatus orderStatus)
- {
- // Находим статус заказа по его айди
- var vmodel = _orderStorage.GetElement(new() { Id = model.Id });
- if (vmodel == null)
- {
- throw new ArgumentNullException(nameof(model));
- }
- if ((int)vmodel.Status + 1 != (int)orderStatus)
- {
- throw new ArgumentException($"Попытка перевести заказ не в следующий статус: " +
- $"Текущий статус: {vmodel.Status} \n" +
- $"Планируемый статус: {orderStatus} \n" +
- $"Доступный статус: {(OrderStatus)((int)vmodel.Status + 1)}",
- nameof(vmodel));
- }
- model.Status = orderStatus;
- model.DateCreate = vmodel.DateCreate;
- if (model.DateImplement == null)
- model.DateImplement = vmodel.DateImplement;
- model.PastryId = vmodel.PastryId;
- model.Sum = vmodel.Sum;
- model.Count= vmodel.Count;
- if (_orderStorage.Update(model) == null)
- {
- _logger.LogWarning("Update operation failed");
- return false;
- }
- return true;
- }
- }
-}
diff --git a/ConfectionaryBusinessLogic/PastryLogic.cs b/ConfectionaryBusinessLogic/PastryLogic.cs
deleted file mode 100644
index 042d5c9..0000000
--- a/ConfectionaryBusinessLogic/PastryLogic.cs
+++ /dev/null
@@ -1,112 +0,0 @@
-using ConfectioneryContracts.BindingModels;
-using ConfectioneryContracts.BusinessLogicsContracts;
-using ConfectioneryContracts.SearchModels;
-using ConfectioneryContracts.StoragesContract;
-using ConfectioneryContracts.ViewModels;
-using Microsoft.Extensions.Logging;
-
-namespace ConfectioneryBusinessLogic.BusinessLogics
-{
- public class PastryLogic : IPastryLogic
- {
- private readonly ILogger _logger;
- private readonly IPastryStorage _pastryStorage;
- public PastryLogic(ILogger logger, IPastryStorage pastryStorage)
- {
- _logger = logger;
- _pastryStorage = pastryStorage;
- }
- public List? ReadList(PastrySearchModel? model)
- {
- _logger.LogInformation("ReadList. PastryName:{PastryName}.Id:{ Id} ",
- model?.PastryName, model?.Id);
- var list = (model == null) ? _pastryStorage.GetFullList() :
- _pastryStorage.GetFilteredList(model);
- if (list == null)
- {
- _logger.LogWarning("ReadList return null list");
- return null;
- }
- _logger.LogInformation("ReadList. Count:{Count}", list.Count);
- return list;
- }
- public PastryViewModel? ReadElement(PastrySearchModel model)
- {
- if (model == null)
- {
- throw new ArgumentNullException(nameof(model));
- }
- _logger.LogInformation("ReadElement. PastryName:{PastryName}.Id:{ Id}",
- model.PastryName, model.Id);
- var element = _pastryStorage.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(PastryBindingModel model)
- {
- CheckModel(model);
- if (_pastryStorage.Insert(model) == null)
- {
- _logger.LogWarning("Insert operation failed");
- return false;
- }
- return true;
- }
- public bool Update(PastryBindingModel model)
- {
- CheckModel(model);
- if (_pastryStorage.Update(model) == null)
- {
- _logger.LogWarning("Update operation failed");
- return false;
- }
- return true;
- }
- public bool Delete(PastryBindingModel model)
- {
- CheckModel(model, false);
- _logger.LogInformation("Delete. Id:{Id}", model.Id);
- if (_pastryStorage.Delete(model) == null)
- {
- _logger.LogWarning("Delete operation failed");
- return false;
- }
- return true;
- }
- private void CheckModel(PastryBindingModel model, bool withParams = true)
- {
- if (model == null)
- {
- throw new ArgumentNullException(nameof(model));
- }
- if (!withParams)
- {
- return;
- }
- if (string.IsNullOrEmpty(model.PastryName))
- {
- throw new ArgumentNullException("Нет названия кондитерского изделия",
- nameof(model.PastryName));
- }
- if (model.Price <= 0)
- {
- throw new ArgumentNullException("Цена кондитерского изделия должна быть больше 0", nameof(model.Price));
- }
- _logger.LogInformation("Pastry. PastryName:{PastryName}.Cost:{ Cost}. Id: { Id}",
- model.PastryName, model.Price, model.Id);
- var element = _pastryStorage.GetElement(new PastrySearchModel
- {
- PastryName = model.PastryName
- });
- if (element != null && element.Id != model.Id)
- {
- throw new InvalidOperationException("Кондитерское изделие с таким названием уже есть");
- }
- }
- }
-}
diff --git a/ConfectionaryBusinessLogic/ComponentLogic.cs b/ConfectionaryBusinessLogic/StudentLogic.cs
similarity index 53%
rename from ConfectionaryBusinessLogic/ComponentLogic.cs
rename to ConfectionaryBusinessLogic/StudentLogic.cs
index 27e25ab..1d8b44a 100644
--- a/ConfectionaryBusinessLogic/ComponentLogic.cs
+++ b/ConfectionaryBusinessLogic/StudentLogic.cs
@@ -1,25 +1,25 @@
-using ConfectioneryContracts.BindingModels;
-using ConfectioneryContracts.BusinessLogicsContracts;
-using ConfectioneryContracts.SearchModels;
-using ConfectioneryContracts.StoragesContract;
-using ConfectioneryContracts.ViewModels;
+using EkzamenContracts.BindingModels;
+using EkzamenContracts.BusinessLogicsContracts;
+using EkzamenContracts.SearchModels;
+using EkzamenContracts.StoragesContract;
+using EkzamenContracts.ViewModels;
using Microsoft.Extensions.Logging;
-namespace ConfectioneryBusinessLogic.BusinessLogics
+namespace EkzamenBusinessLogic
{
- public class ComponentLogic : IComponentLogic
+ public class StudentLogic : IStudentLogic
{
private readonly ILogger _logger;
- private readonly IComponentStorage _componentStorage;
- public ComponentLogic(ILogger logger, IComponentStorage componentStorage)
+ private readonly IStudentStorage _componentStorage;
+ public StudentLogic(ILogger logger, IStudentStorage componentStorage)
{
_logger = logger;
_componentStorage = componentStorage;
}
- public List? ReadList(ComponentSearchModel? model)
+ public List? ReadList(StudentSearchModel? model)
{
_logger.LogInformation("ReadList. ComponentName:{ComponentName}.Id:{ Id} ",
- model?.ComponentName, model?.Id);
+ model?.CreatedDateFrom, model?.Id);
var list = (model == null) ? _componentStorage.GetFullList() :
_componentStorage.GetFilteredList(model);
if (list == null)
@@ -30,14 +30,14 @@ namespace ConfectioneryBusinessLogic.BusinessLogics
_logger.LogInformation("ReadList. Count:{Count}", list.Count);
return list;
}
- public ComponentViewModel? ReadElement(ComponentSearchModel model)
+ public StudentViewModel? ReadElement(StudentSearchModel model)
{
if (model == null)
{
throw new ArgumentNullException(nameof(model));
}
_logger.LogInformation("ReadElement. ComponentName:{ComponentName}.Id:{ Id}",
- model.ComponentName, model.Id);
+ model.CreatedDateFrom, model.Id);
var element = _componentStorage.GetElement(model);
if (element == null)
{
@@ -47,7 +47,7 @@ namespace ConfectioneryBusinessLogic.BusinessLogics
_logger.LogInformation("ReadElement find. Id:{Id}", element.Id);
return element;
}
- public bool Create(ComponentBindingModel model)
+ public bool Create(StudentBindingModel model)
{
CheckModel(model);
if (_componentStorage.Insert(model) == null)
@@ -57,7 +57,7 @@ namespace ConfectioneryBusinessLogic.BusinessLogics
}
return true;
}
- public bool Update(ComponentBindingModel model)
+ public bool Update(StudentBindingModel model)
{
CheckModel(model);
if (_componentStorage.Update(model) == null)
@@ -67,7 +67,7 @@ namespace ConfectioneryBusinessLogic.BusinessLogics
}
return true;
}
- public bool Delete(ComponentBindingModel model)
+ public bool Delete(StudentBindingModel model)
{
CheckModel(model, false);
_logger.LogInformation("Delete. Id:{Id}", model.Id);
@@ -78,36 +78,19 @@ namespace ConfectioneryBusinessLogic.BusinessLogics
}
return true;
}
- private void CheckModel(ComponentBindingModel model, bool withParams =
- true)
+
+ private void CheckModel(StudentBindingModel model, bool withParams =
+ true)
{
if (model == null)
{
throw new ArgumentNullException(nameof(model));
}
+
if (!withParams)
{
return;
}
- if (string.IsNullOrEmpty(model.ComponentName))
- {
- throw new ArgumentNullException("Нет названия компонента",
- nameof(model.ComponentName));
- }
- if (model.Cost <= 0)
- {
- throw new ArgumentNullException("Цена компонента должна быть больше 0", nameof(model.Cost));
- }
- _logger.LogInformation("Component. ComponentName:{ComponentName}.Cost:{ Cost}. Id: { Id}",
- model.ComponentName, model.Cost, model.Id);
- var element = _componentStorage.GetElement(new ComponentSearchModel
- {
- ComponentName = model.ComponentName
- });
- if (element != null && element.Id != model.Id)
- {
- throw new InvalidOperationException("Компонент с таким названием уже есть");
- }
}
}
}
\ No newline at end of file
diff --git a/ConfectionaryListImplement/Component.cs b/ConfectionaryListImplement/Component.cs
deleted file mode 100644
index 008ac97..0000000
--- a/ConfectionaryListImplement/Component.cs
+++ /dev/null
@@ -1,41 +0,0 @@
-using ConfectioneryContracts.BindingModels;
-using ConfectioneryContracts.ViewModels;
-using ConfectioneryDataModels.Models;
-
-namespace ConfectioneryListImplement.Models
-{
- public class Component : IComponentModel
- {
- public int Id { get; private set; }
- public string ComponentName { get; private set; } = string.Empty;
- public double Cost { get; set; }
- public static Component? Create(ComponentBindingModel? model)
- {
- if (model == null)
- {
- return null;
- }
- return new Component()
- {
- Id = model.Id,
- ComponentName = model.ComponentName,
- Cost = model.Cost
- };
- }
- public void Update(ComponentBindingModel? model)
- {
- if (model == null)
- {
- return;
- }
- ComponentName = model.ComponentName;
- Cost = model.Cost;
- }
- public ComponentViewModel GetViewModel => new()
- {
- Id = Id,
- ComponentName = ComponentName,
- Cost = Cost
- };
- }
-}
\ No newline at end of file
diff --git a/ConfectionaryListImplement/ComponentStorage.cs b/ConfectionaryListImplement/ComponentStorage.cs
deleted file mode 100644
index fe845ab..0000000
--- a/ConfectionaryListImplement/ComponentStorage.cs
+++ /dev/null
@@ -1,102 +0,0 @@
-using ConfectioneryContracts.BindingModels;
-using ConfectioneryContracts.SearchModels;
-using ConfectioneryContracts.StoragesContract;
-using ConfectioneryContracts.ViewModels;
-using ConfectioneryListImplement.Models;
-
-namespace ConfectioneryListImplement.Implements
-{
- public class ComponentStorage : IComponentStorage
- {
- private readonly DataListSingleton _source;
- public ComponentStorage()
- {
- _source = DataListSingleton.GetInstance();
- }
- public List GetFullList()
- {
- var result = new List();
- foreach (var component in _source.Components)
- {
- result.Add(component.GetViewModel);
- }
- return result;
- }
- public List GetFilteredList(ComponentSearchModel model)
- {
- var result = new List();
- if (string.IsNullOrEmpty(model.ComponentName))
- {
- return result;
- }
- foreach (var component in _source.Components)
- {
- if (component.ComponentName.Contains(model.ComponentName))
- {
- result.Add(component.GetViewModel);
- }
- }
- return result;
- }
- public ComponentViewModel? GetElement(ComponentSearchModel model)
- {
- if (string.IsNullOrEmpty(model.ComponentName) && !model.Id.HasValue)
- {
- return null;
- }
- foreach (var component in _source.Components)
- {
- if ((!string.IsNullOrEmpty(model.ComponentName) &&
- component.ComponentName == model.ComponentName) ||
- (model.Id.HasValue && component.Id == model.Id))
- {
- return component.GetViewModel;
- }
- }
- return null;
- }
- public ComponentViewModel? Insert(ComponentBindingModel model)
- {
- model.Id = 1;
- foreach (var component in _source.Components)
- {
- if (model.Id <= component.Id)
- {
- model.Id = component.Id + 1;
- }
- }
- var newComponent = Component.Create(model);
- if (newComponent == null)
- {
- return null;
- }
- _source.Components.Add(newComponent);
- return newComponent.GetViewModel;
- }
- public ComponentViewModel? Update(ComponentBindingModel model)
- {
- foreach (var component in _source.Components)
- {
- if (component.Id == model.Id)
- {
- component.Update(model);
- return component.GetViewModel;
- }
- }
- return null;
- }
- public ComponentViewModel? Delete(ComponentBindingModel model)
- {
- for (int i = 0; i < _source.Components.Count; ++i)
- {
- if (_source.Components[i].Id == model.Id)
- {
- var element = _source.Components[i];
- _source.Components.RemoveAt(i);
- return element.GetViewModel;
- }
- }
- return null;
- }
- }
-}
\ No newline at end of file
diff --git a/ConfectionaryListImplement/DataListSingleton.cs b/ConfectionaryListImplement/DataListSingleton.cs
index 24ae616..efcc2c6 100644
--- a/ConfectionaryListImplement/DataListSingleton.cs
+++ b/ConfectionaryListImplement/DataListSingleton.cs
@@ -1,18 +1,16 @@
-using ConfectioneryListImplement.Models;
+using EkzamenListImplement;
namespace ConfectioneryListImplement
{
public class DataListSingleton
{
private static DataListSingleton? _instance;
- public List Components { get; set; }
- public List Orders { get; set; }
- public List Pastry { get; set; }
+ public List Students { get; set; }
+ public List Groups { get; set; }
private DataListSingleton()
{
- Components = new List();
- Orders = new List();
- Pastry = new List();
+ Students = new List();
+ Groups = new ();
}
public static DataListSingleton GetInstance()
{
diff --git a/ConfectionaryListImplement/ConfectioneryListImplement.csproj b/ConfectionaryListImplement/EkzamenListImplement.csproj
similarity index 56%
rename from ConfectionaryListImplement/ConfectioneryListImplement.csproj
rename to ConfectionaryListImplement/EkzamenListImplement.csproj
index 41b6c3e..441ca24 100644
--- a/ConfectionaryListImplement/ConfectioneryListImplement.csproj
+++ b/ConfectionaryListImplement/EkzamenListImplement.csproj
@@ -7,8 +7,8 @@
-
-
+
+
diff --git a/ConfectionaryListImplement/Group.cs b/ConfectionaryListImplement/Group.cs
new file mode 100644
index 0000000..e5bb917
--- /dev/null
+++ b/ConfectionaryListImplement/Group.cs
@@ -0,0 +1,46 @@
+using EkzamenContracts.BindingModels;
+using EkzamenContracts.ViewModels;
+using EkzamenDataModels;
+
+namespace EkzamenListImplement
+{
+ public class Group : IGroupModel
+ {
+ public int Id { get; private set; }
+
+ public static Group? Create(GroupBindingModel? model)
+ {
+ if (model == null)
+ {
+ return null;
+ }
+ return new Group()
+ {
+ Name = model.Name,
+ Direction = model.Direction,
+ Created = model.Created,
+ Id = model.Id,
+ };
+ }
+ public void Update(GroupBindingModel? model)
+ {
+ if (model == null)
+ {
+ return;
+ }
+ Direction = model.Direction;
+ Id = model.Id;
+ }
+ public GroupViewModel GetViewModel => new()
+ {
+ Name = Name,
+ Direction = Direction,
+ Created = Created,
+ Id = Id,
+ };
+
+ public string Name { get; set; }
+ public string Direction { get; set; }
+ public DateTime Created { get; set; }
+ }
+}
diff --git a/ConfectionaryListImplement/GroupStorage.cs b/ConfectionaryListImplement/GroupStorage.cs
new file mode 100644
index 0000000..f897621
--- /dev/null
+++ b/ConfectionaryListImplement/GroupStorage.cs
@@ -0,0 +1,73 @@
+using ConfectioneryListImplement;
+using EkzamenContracts.BindingModels;
+using EkzamenContracts.SearchModels;
+using EkzamenContracts.StoragesContract;
+using EkzamenContracts.ViewModels;
+
+namespace EkzamenListImplement
+{
+ public class GroupStorage : IGroupStorage
+ {
+ private readonly DataListSingleton _source;
+ public GroupStorage()
+ {
+ _source = DataListSingleton.GetInstance();
+ }
+
+ public GroupViewModel? Delete(GroupBindingModel model)
+ {
+ var group = _source.Groups.FirstOrDefault(x => x.Id == model.Id);
+ if (group != null)
+ {
+ _source.Groups.Remove(group);
+ }
+ return group?.GetViewModel;
+ }
+
+ public GroupViewModel? GetElement(GroupSearchModel model)
+ {
+ if (!model.Id.HasValue)
+ {
+ return null;
+ }
+
+ return _source.Groups.FirstOrDefault(x => x.Id == model.Id)?.GetViewModel;
+ }
+
+ public List GetFilteredList(GroupSearchModel model)
+ {
+ var result = new List();
+ if (!model.Id.HasValue)
+ {
+ return result;
+ }
+
+ return new() { GetElement(model) };
+ }
+
+ public List GetFullList()
+ {
+ return _source.Groups.Select(x => x.GetViewModel).ToList();
+ }
+
+ public GroupViewModel? Insert(GroupBindingModel model)
+ {
+ model.Id = _source.Groups.Max(x => x.Id);
+ var newOrder = Group.Create(model);
+ if (newOrder == null)
+ {
+ return null;
+ }
+ _source.Groups.Add(newOrder);
+ return newOrder.GetViewModel;
+ }
+
+ public GroupViewModel? Update(GroupBindingModel model)
+ {
+ var group = _source.Groups.FirstOrDefault(x => x.Id == model.Id);
+ group?.Update(model);
+ return group?.GetViewModel;
+ return null;
+ }
+ }
+}
diff --git a/ConfectionaryListImplement/Order.cs b/ConfectionaryListImplement/Order.cs
deleted file mode 100644
index a6e154f..0000000
--- a/ConfectionaryListImplement/Order.cs
+++ /dev/null
@@ -1,66 +0,0 @@
-using ConfectioneryContracts.BindingModels;
-using ConfectioneryContracts.ViewModels;
-using ConfectioneryDataModels.Enums;
-using ConfectioneryDataModels.Models;
-
-namespace ConfectioneryListImplement.Models
-{
- public class Order : IOrderModel
- {
- public int Id { get; private set; }
-
- public int PastryId { get; private set; }
-
- public int Count { get; private set; }
-
- public double Sum { get; private set; }
-
- public OrderStatus Status { get; private set; }
-
- public DateTime DateCreate { get; private set; }
-
- public DateTime? DateImplement { get; private set; }
-
- public static Order? Create(OrderBindingModel? model)
- {
- if (model == null)
- {
- return null;
- }
- return new Order()
- {
- PastryId = model.PastryId,
- Count = model.Count,
- Sum = model.Sum,
- Status = model.Status,
- DateCreate = model.DateCreate,
- DateImplement = model.DateImplement,
- Id = model.Id,
- };
- }
- public void Update(OrderBindingModel? model)
- {
- if (model == null)
- {
- return;
- }
- PastryId = model.PastryId;
- Count = model.Count;
- Sum = model.Sum;
- Status = model.Status;
- DateCreate = model.DateCreate;
- DateImplement = model.DateImplement;
- Id = model.Id;
- }
- public OrderViewModel GetViewModel => new()
- {
- PastryId = PastryId,
- Count = Count,
- Sum = Sum,
- Status = Status,
- DateCreate = DateCreate,
- DateImplement = DateImplement,
- Id = Id,
- };
- }
-}
diff --git a/ConfectionaryListImplement/OrderStorage.cs b/ConfectionaryListImplement/OrderStorage.cs
deleted file mode 100644
index d6a964e..0000000
--- a/ConfectionaryListImplement/OrderStorage.cs
+++ /dev/null
@@ -1,120 +0,0 @@
-using ConfectioneryContracts.BindingModels;
-using ConfectioneryContracts.SearchModels;
-using ConfectioneryContracts.StoragesContract;
-using ConfectioneryContracts.ViewModels;
-using ConfectioneryListImplement.Models;
-
-namespace ConfectioneryListImplement
-{
- public class OrderStorage : IOrderStorage
- {
- private readonly DataListSingleton _source;
- public OrderStorage()
- {
- _source = DataListSingleton.GetInstance();
- }
-
- public OrderViewModel? Delete(OrderBindingModel model)
- {
- for (int i = 0; i < _source.Orders.Count; ++i)
- {
- if (_source.Orders[i].Id == model.Id)
- {
- var element = _source.Orders[i];
- _source.Orders.RemoveAt(i);
- return element.GetViewModel;
- }
- }
- return null;
- }
-
- public OrderViewModel? GetElement(OrderSearchModel model)
- {
- if (!model.Id.HasValue)
- {
- return null;
- }
- foreach (var order in _source.Orders)
- {
- if (model.Id.HasValue && order.Id == model.Id)
- {
- return GetViewModel(order);
- }
- }
- return null;
- }
-
- public List GetFilteredList(OrderSearchModel model)
- {
- var result = new List();
- if (!model.Id.HasValue)
- {
- return result;
- }
- foreach (var order in _source.Orders)
- {
- if (order.Id == model.Id)
- {
- return new() { GetViewModel(order) };
- }
- }
- return new();
- }
-
- public List GetFullList()
- {
- var result = new List();
- foreach (var order in _source.Orders)
- {
- result.Add(GetViewModel(order));
- }
- return result;
- }
-
- public OrderViewModel? Insert(OrderBindingModel model)
- {
- model.Id = 1;
- foreach (var order in _source.Orders)
- {
- if (model.Id <= order.Id)
- {
- model.Id = order.Id + 1;
- }
- }
- var newOrder = Order.Create(model);
- if (newOrder == null)
- {
- return null;
- }
- _source.Orders.Add(newOrder);
- return newOrder.GetViewModel;
- }
-
- public OrderViewModel? Update(OrderBindingModel model)
- {
- foreach (var order in _source.Orders)
- {
- if (order.Id == model.Id)
- {
- order.Update(model);
- return order.GetViewModel;
- }
- }
- return null;
- }
-
- private OrderViewModel GetViewModel(Order model)
- {
- var res = model.GetViewModel;
- foreach (var pastry in _source.Pastry)
- {
- if (pastry.Id == model.PastryId)
- {
- res.PastryName = pastry.PastryName;
- break;
- }
- }
- return res;
- }
- }
-}
diff --git a/ConfectionaryListImplement/Pastry.cs b/ConfectionaryListImplement/Pastry.cs
deleted file mode 100644
index 28c593b..0000000
--- a/ConfectionaryListImplement/Pastry.cs
+++ /dev/null
@@ -1,49 +0,0 @@
-using ConfectioneryContracts.BindingModels;
-using ConfectioneryContracts.ViewModels;
-using ConfectioneryDataModels.Models;
-
-namespace ConfectioneryListImplement.Models
-{
- public class Pastry : IPastryModel
- {
- public int Id { get; private set; }
- public string PastryName { get; private set; } = string.Empty;
- public double Price { get; private set; }
- public Dictionary PastryComponents
- {
- get;
- private set;
- } = new Dictionary();
- public static Pastry? Create(PastryBindingModel? model)
- {
- if (model == null)
- {
- return null;
- }
- return new Pastry()
- {
- Id = model.Id,
- PastryName = model.PastryName,
- Price = model.Price,
- PastryComponents = model.PastryComponents
- };
- }
- public void Update(PastryBindingModel? model)
- {
- if (model == null)
- {
- return;
- }
- PastryName = model.PastryName;
- Price = model.Price;
- PastryComponents = model.PastryComponents;
- }
- public PastryViewModel GetViewModel => new()
- {
- Id = Id,
- PastryName = PastryName,
- Price = Price,
- PastryComponents = PastryComponents
- };
- }
-}
\ No newline at end of file
diff --git a/ConfectionaryListImplement/PastryStorage.cs b/ConfectionaryListImplement/PastryStorage.cs
deleted file mode 100644
index 0fab514..0000000
--- a/ConfectionaryListImplement/PastryStorage.cs
+++ /dev/null
@@ -1,108 +0,0 @@
-using ConfectioneryContracts.BindingModels;
-using ConfectioneryContracts.SearchModels;
-using ConfectioneryContracts.StoragesContract;
-using ConfectioneryContracts.ViewModels;
-using ConfectioneryListImplement.Models;
-
-namespace ConfectioneryListImplement
-{
- public class PastryStorage : IPastryStorage
- {
- private readonly DataListSingleton _source;
- public PastryStorage()
- {
- _source = DataListSingleton.GetInstance();
- }
-
- public PastryViewModel? Delete(PastryBindingModel model)
- {
- for (int i = 0; i < _source.Pastry.Count; ++i)
- {
- if (_source.Pastry[i].Id == model.Id)
- {
- var element = _source.Pastry[i];
- _source.Pastry.RemoveAt(i);
- return element.GetViewModel;
- }
- }
- return null;
- }
-
- public PastryViewModel? GetElement(PastrySearchModel model)
- {
- if (string.IsNullOrEmpty(model.PastryName) && !model.Id.HasValue)
- {
- return null;
- }
- foreach (var pastry in _source.Pastry)
- {
- if ((!string.IsNullOrEmpty(model.PastryName) &&
- pastry.PastryName == model.PastryName) ||
- (model.Id.HasValue && pastry.Id == model.Id))
- {
- return pastry.GetViewModel;
- }
- }
- return null;
- }
-
- public List GetFilteredList(PastrySearchModel model)
- {
- var result = new List();
- if (string.IsNullOrEmpty(model.PastryName))
- {
- return result;
- }
- foreach (var pastry in _source.Pastry)
- {
- if (pastry.PastryName.Contains(model.PastryName ?? string.Empty))
- {
- result.Add(pastry.GetViewModel);
- }
- }
- return result;
- }
-
- public List GetFullList()
- {
- var result = new List();
- foreach (var pastry in _source.Pastry)
- {
- result.Add(pastry.GetViewModel);
- }
- return result;
- }
-
- public PastryViewModel? Insert(PastryBindingModel model)
- {
- model.Id = 1;
- foreach (var pastry in _source.Pastry)
- {
- if (model.Id <= pastry.Id)
- {
- model.Id = pastry.Id + 1;
- }
- }
- var newPastry = Pastry.Create(model);
- if (newPastry == null)
- {
- return null;
- }
- _source.Pastry.Add(newPastry);
- return newPastry.GetViewModel;
- }
-
- public PastryViewModel? Update(PastryBindingModel model)
- {
- foreach (var pastry in _source.Pastry)
- {
- if (pastry.Id == model.Id)
- {
- pastry.Update(model);
- return pastry.GetViewModel;
- }
- }
- return null;
- }
- }
-}
diff --git a/ConfectionaryListImplement/Student.cs b/ConfectionaryListImplement/Student.cs
new file mode 100644
index 0000000..9daed65
--- /dev/null
+++ b/ConfectionaryListImplement/Student.cs
@@ -0,0 +1,53 @@
+using EkzamenContracts.BindingModels;
+using EkzamenContracts.ViewModels;
+using EkzamenDataModels;
+
+namespace EkzamenListImplement
+{
+ public class Student : IStudentModel
+ {
+ public int Id { get; private set; }
+ public static Student? Create(StudentBindingModel? model)
+ {
+ if (model == null)
+ {
+ return null;
+ }
+ return new Student()
+ {
+ Id = model.Id,
+ fio = model.fio,
+ DateEnrollment = model.DateEnrollment,
+ GroupId = model.GroupId,
+ PassMark = model.PassMark,
+ RecordBookId = model.RecordBookId,
+ };
+ }
+ public void Update(StudentBindingModel? model)
+ {
+ if (model == null)
+ {
+ return;
+ }
+
+ fio = model.fio;
+
+ }
+ public StudentViewModel GetViewModel => new()
+ {
+ Id = Id,
+ fio = fio,
+ DateEnrollment = DateEnrollment,
+ GroupId = GroupId,
+ PassMark = PassMark,
+ RecordBookId = RecordBookId,
+
+ };
+
+ public string fio { get; set; } = string.Empty;
+ public int GroupId { get; set; }
+ public int RecordBookId { get; set; }
+ public int PassMark { get; set; }
+ public DateTime DateEnrollment { get; set; }
+ }
+}
\ No newline at end of file
diff --git a/ConfectionaryListImplement/StudentStorage.cs b/ConfectionaryListImplement/StudentStorage.cs
new file mode 100644
index 0000000..31e1934
--- /dev/null
+++ b/ConfectionaryListImplement/StudentStorage.cs
@@ -0,0 +1,64 @@
+using ConfectioneryListImplement;
+using EkzamenContracts.BindingModels;
+using EkzamenContracts.SearchModels;
+using EkzamenContracts.StoragesContract;
+using EkzamenContracts.ViewModels;
+
+namespace EkzamenListImplement
+{
+ public class StudentStorage : IStudentStorage
+ {
+ private readonly DataListSingleton _source = DataListSingleton.GetInstance();
+
+ public List GetFullList()
+ {
+ return _source.Students.Select(x => x.GetViewModel).ToList();
+ }
+ public List GetFilteredList(StudentSearchModel model)
+ {
+ var result = new List();
+ if (model.CreatedDateFrom is null || model.CreatedDateTo is null)
+ {
+ return result;
+ }
+ return _source.Students.Where(x => model.CreatedDateFrom <= x.DateEnrollment && x.DateEnrollment <= model.CreatedDateTo).Select(x => x.GetViewModel).ToList();
+ }
+ public StudentViewModel? GetElement(StudentSearchModel model)
+ {
+ if (!model.Id.HasValue)
+ {
+ return null;
+ }
+ return _source.Students.FirstOrDefault(x => x.Id == model.Id)?.GetViewModel;
+ }
+ public StudentViewModel? Insert(StudentBindingModel model)
+ {
+ model.Id = _source.Students.Max(x => x.Id);
+ var newComponent = Student.Create(model);
+ if (newComponent == null)
+ {
+ return null;
+ }
+ _source.Students.Add(newComponent);
+ return newComponent.GetViewModel;
+ }
+ public StudentViewModel? Update(StudentBindingModel model)
+ {
+ var student = _source.Students.FirstOrDefault(x => x.Id == model.Id);
+ if (student != null)
+ {
+ student.Update(model);
+ }
+ return student?.GetViewModel;
+ }
+ public StudentViewModel? Delete(StudentBindingModel model)
+ {
+ var student = _source.Students.FirstOrDefault(x => x.Id == model.Id);
+ if (student != null)
+ {
+ _source.Students.Remove(student);
+ }
+ return student?.GetViewModel;
+ }
+ }
+}
\ No newline at end of file
diff --git a/Confectionery/ConfectioneryView.csproj b/Confectionery/EkzamenView.csproj
similarity index 65%
rename from Confectionery/ConfectioneryView.csproj
rename to Confectionery/EkzamenView.csproj
index eaec16f..2f94a42 100644
--- a/Confectionery/ConfectioneryView.csproj
+++ b/Confectionery/EkzamenView.csproj
@@ -18,11 +18,10 @@
-
-
-
-
-
+
+
+
+
\ No newline at end of file
diff --git a/Confectionery/FormComponent.Designer.cs b/Confectionery/FormComponent.Designer.cs
deleted file mode 100644
index 5d51eab..0000000
--- a/Confectionery/FormComponent.Designer.cs
+++ /dev/null
@@ -1,118 +0,0 @@
-namespace ConfectioneryView
-{
- partial class FormComponent
- {
- ///
- /// Required designer variable.
- ///
- private System.ComponentModel.IContainer components = null;
-
- ///
- /// Clean up any resources being used.
- ///
- /// true if managed resources should be disposed; otherwise, false.
- protected override void Dispose(bool disposing)
- {
- if (disposing && (components != null))
- {
- components.Dispose();
- }
- base.Dispose(disposing);
- }
-
- #region Windows Form Designer generated code
-
- ///
- /// Required method for Designer support - do not modify
- /// the contents of this method with the code editor.
- ///
- private void InitializeComponent()
- {
- this.label1 = new System.Windows.Forms.Label();
- this.label2 = new System.Windows.Forms.Label();
- this.textBoxName = new System.Windows.Forms.TextBox();
- this.textBoxCost = new System.Windows.Forms.TextBox();
- this.buttonCancel = new System.Windows.Forms.Button();
- this.buttonSave = new System.Windows.Forms.Button();
- this.SuspendLayout();
- //
- // label1
- //
- this.label1.AutoSize = true;
- this.label1.Location = new System.Drawing.Point(12, 9);
- this.label1.Name = "label1";
- this.label1.Size = new System.Drawing.Size(62, 15);
- this.label1.TabIndex = 0;
- this.label1.Text = "Название:";
- //
- // label2
- //
- this.label2.AutoSize = true;
- this.label2.Location = new System.Drawing.Point(36, 37);
- this.label2.Name = "label2";
- this.label2.Size = new System.Drawing.Size(38, 15);
- this.label2.TabIndex = 1;
- this.label2.Text = "Цена:";
- //
- // textBoxName
- //
- this.textBoxName.Location = new System.Drawing.Point(80, 6);
- this.textBoxName.Name = "textBoxName";
- this.textBoxName.Size = new System.Drawing.Size(292, 23);
- this.textBoxName.TabIndex = 2;
- //
- // textBoxCost
- //
- this.textBoxCost.Location = new System.Drawing.Point(80, 35);
- this.textBoxCost.Name = "textBoxCost";
- this.textBoxCost.Size = new System.Drawing.Size(149, 23);
- this.textBoxCost.TabIndex = 3;
- //
- // buttonCancel
- //
- this.buttonCancel.Location = new System.Drawing.Point(297, 73);
- this.buttonCancel.Name = "buttonCancel";
- this.buttonCancel.Size = new System.Drawing.Size(75, 23);
- this.buttonCancel.TabIndex = 4;
- this.buttonCancel.Text = "Отмена";
- this.buttonCancel.UseVisualStyleBackColor = true;
- this.buttonCancel.Click += new System.EventHandler(this.ButtonCancel_Click);
- //
- // buttonSave
- //
- this.buttonSave.Location = new System.Drawing.Point(216, 73);
- this.buttonSave.Name = "buttonSave";
- this.buttonSave.Size = new System.Drawing.Size(75, 23);
- this.buttonSave.TabIndex = 5;
- this.buttonSave.Text = "Сохранить";
- this.buttonSave.UseVisualStyleBackColor = true;
- this.buttonSave.Click += new System.EventHandler(this.ButtonSave_Click);
- //
- // FormComponent
- //
- this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
- this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
- this.ClientSize = new System.Drawing.Size(384, 108);
- this.Controls.Add(this.buttonSave);
- this.Controls.Add(this.buttonCancel);
- this.Controls.Add(this.textBoxCost);
- this.Controls.Add(this.textBoxName);
- this.Controls.Add(this.label2);
- this.Controls.Add(this.label1);
- this.Name = "FormComponent";
- this.Text = "Создание компонента";
- this.ResumeLayout(false);
- this.PerformLayout();
-
- }
-
- #endregion
-
- private Label label1;
- private Label label2;
- private TextBox textBoxName;
- private TextBox textBoxCost;
- private Button buttonCancel;
- private Button buttonSave;
- }
-}
\ No newline at end of file
diff --git a/Confectionery/FormComponent.cs b/Confectionery/FormComponent.cs
deleted file mode 100644
index 66747be..0000000
--- a/Confectionery/FormComponent.cs
+++ /dev/null
@@ -1,89 +0,0 @@
-using ConfectioneryContracts.BindingModels;
-using ConfectioneryContracts.BusinessLogicsContracts;
-using ConfectioneryContracts.SearchModels;
-using Microsoft.Extensions.Logging;
-
-namespace ConfectioneryView
-{
- public partial class FormComponent : Form
- {
- private readonly ILogger _logger;
- private readonly IComponentLogic _logic;
- private int? _id;
- public int Id { set { _id = value; } }
-
- public FormComponent(ILogger logger, IComponentLogic logic)
- {
- InitializeComponent();
- _logger = logger;
- _logic = logic;
- }
- private void FormComponent_Load(object sender, EventArgs e)
- {
- if (_id.HasValue)
- {
- try
- {
- _logger.LogInformation("Получение компонента");
- var view = _logic.ReadElement(new ComponentSearchModel
- {
- Id =
- _id.Value
- });
- if (view != null)
- {
- textBoxName.Text = view.ComponentName;
- textBoxCost.Text = view.Cost.ToString();
- }
- }
- catch (Exception ex)
- {
- _logger.LogError(ex, "Ошибка получения компонента");
- MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK,
- MessageBoxIcon.Error);
- }
- }
- }
- private void ButtonSave_Click(object sender, EventArgs e)
- {
- if (string.IsNullOrEmpty(textBoxName.Text))
- {
- MessageBox.Show("Заполните название", "Ошибка",
- MessageBoxButtons.OK, MessageBoxIcon.Error);
- return;
- }
- _logger.LogInformation("Сохранение компонента");
- try
- {
- var model = new ComponentBindingModel
- {
- Id = _id ?? 0,
- ComponentName = textBoxName.Text,
- Cost = Convert.ToDouble(textBoxCost.Text)
- };
- var operationResult = _id.HasValue ? _logic.Update(model) :
- _logic.Create(model);
- if (!operationResult)
- {
- throw new Exception("Ошибка при сохранении. Дополнительная информация в логах.");
- }
- MessageBox.Show("Сохранение прошло успешно", "Сообщение",
- MessageBoxButtons.OK, MessageBoxIcon.Information);
- DialogResult = DialogResult.OK;
- Close();
- }
- catch (Exception ex)
- {
- _logger.LogError(ex, "Ошибка сохранения компонента");
- MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK,
- MessageBoxIcon.Error);
- }
- }
- private void ButtonCancel_Click(object sender, EventArgs e)
- {
- DialogResult = DialogResult.Cancel;
- Close();
- }
- }
-}
-
diff --git a/Confectionery/FormComponent.resx b/Confectionery/FormComponent.resx
deleted file mode 100644
index f298a7b..0000000
--- a/Confectionery/FormComponent.resx
+++ /dev/null
@@ -1,60 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- text/microsoft-resx
-
-
- 2.0
-
-
- System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
-
-
- System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
-
-
\ No newline at end of file
diff --git a/Confectionery/FormComponents.Designer.cs b/Confectionery/FormComponents.Designer.cs
deleted file mode 100644
index 967f22a..0000000
--- a/Confectionery/FormComponents.Designer.cs
+++ /dev/null
@@ -1,121 +0,0 @@
-namespace ConfectioneryView
-{
- partial class FormComponents
- {
- ///
- /// Required designer variable.
- ///
- private System.ComponentModel.IContainer components = null;
-
- ///
- /// Clean up any resources being used.
- ///
- /// true if managed resources should be disposed; otherwise, false.
- protected override void Dispose(bool disposing)
- {
- if (disposing && (components != null))
- {
- components.Dispose();
- }
- base.Dispose(disposing);
- }
-
- #region Windows Form Designer generated code
-
- ///
- /// Required method for Designer support - do not modify
- /// the contents of this method with the code editor.
- ///
- private void InitializeComponent()
- {
- this.buttonRef = new System.Windows.Forms.Button();
- this.buttonDel = new System.Windows.Forms.Button();
- this.buttonUpd = new System.Windows.Forms.Button();
- this.buttonAdd = new System.Windows.Forms.Button();
- this.dataGridView = new System.Windows.Forms.DataGridView();
- ((System.ComponentModel.ISupportInitialize)(this.dataGridView)).BeginInit();
- this.SuspendLayout();
- //
- // buttonRef
- //
- this.buttonRef.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
- this.buttonRef.Location = new System.Drawing.Point(626, 202);
- this.buttonRef.Name = "buttonRef";
- this.buttonRef.Size = new System.Drawing.Size(90, 37);
- this.buttonRef.TabIndex = 9;
- this.buttonRef.Text = "Обновить";
- this.buttonRef.UseVisualStyleBackColor = true;
- this.buttonRef.Click += new System.EventHandler(this.ButtonRef_Click);
- //
- // buttonDel
- //
- this.buttonDel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
- this.buttonDel.Location = new System.Drawing.Point(626, 151);
- this.buttonDel.Name = "buttonDel";
- this.buttonDel.Size = new System.Drawing.Size(90, 33);
- this.buttonDel.TabIndex = 8;
- this.buttonDel.Text = "Удалить";
- this.buttonDel.UseVisualStyleBackColor = true;
- this.buttonDel.Click += new System.EventHandler(this.ButtonDel_Click);
- //
- // buttonUpd
- //
- this.buttonUpd.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
- this.buttonUpd.Location = new System.Drawing.Point(626, 102);
- this.buttonUpd.Name = "buttonUpd";
- this.buttonUpd.Size = new System.Drawing.Size(90, 34);
- this.buttonUpd.TabIndex = 7;
- this.buttonUpd.Text = "Изменить";
- this.buttonUpd.UseVisualStyleBackColor = true;
- this.buttonUpd.Click += new System.EventHandler(this.ButtonUpd_Click);
- //
- // buttonAdd
- //
- this.buttonAdd.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
- this.buttonAdd.Location = new System.Drawing.Point(626, 57);
- this.buttonAdd.Name = "buttonAdd";
- this.buttonAdd.Size = new System.Drawing.Size(90, 30);
- this.buttonAdd.TabIndex = 6;
- this.buttonAdd.Text = "Добавить";
- this.buttonAdd.UseVisualStyleBackColor = true;
- this.buttonAdd.Click += new System.EventHandler(this.ButtonAdd_Click);
- //
- // dataGridView
- //
- this.dataGridView.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
- | System.Windows.Forms.AnchorStyles.Left)
- | System.Windows.Forms.AnchorStyles.Right)));
- this.dataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
- this.dataGridView.Location = new System.Drawing.Point(12, 12);
- this.dataGridView.Name = "dataGridView";
- this.dataGridView.RowTemplate.Height = 25;
- this.dataGridView.Size = new System.Drawing.Size(553, 302);
- this.dataGridView.TabIndex = 5;
- //
- // FormComponents
- //
- this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
- this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
- this.ClientSize = new System.Drawing.Size(722, 319);
- this.Controls.Add(this.buttonRef);
- this.Controls.Add(this.buttonDel);
- this.Controls.Add(this.buttonUpd);
- this.Controls.Add(this.buttonAdd);
- this.Controls.Add(this.dataGridView);
- this.Name = "FormComponents";
- this.Text = "Редактирование компонентов";
- this.Load += new System.EventHandler(this.FormComponents_Load);
- ((System.ComponentModel.ISupportInitialize)(this.dataGridView)).EndInit();
- this.ResumeLayout(false);
-
- }
-
- #endregion
-
- private Button buttonRef;
- private Button buttonDel;
- private Button buttonUpd;
- private Button buttonAdd;
- private DataGridView dataGridView;
- }
-}
\ No newline at end of file
diff --git a/Confectionery/FormComponents.cs b/Confectionery/FormComponents.cs
deleted file mode 100644
index 2f20d12..0000000
--- a/Confectionery/FormComponents.cs
+++ /dev/null
@@ -1,104 +0,0 @@
-using ConfectioneryContracts.BindingModels;
-using ConfectioneryContracts.BusinessLogicsContracts;
-using Microsoft.Extensions.Logging;
-
-namespace ConfectioneryView
-{
- public partial class FormComponents : Form
- {
- private readonly ILogger _logger;
- private readonly IComponentLogic _logic;
- public FormComponents(ILogger logger, IComponentLogic logic)
- {
- InitializeComponent();
- _logger = logger;
- _logic = logic;
- }
- private void FormComponents_Load(object sender, EventArgs e)
- {
- LoadData();
- }
- private void LoadData()
- {
- try
- {
- var list = _logic.ReadList(null);
- if (list != null)
- {
- dataGridView.DataSource = list;
- dataGridView.Columns["Id"].Visible = false;
- dataGridView.Columns["ComponentName"].AutoSizeMode =
- DataGridViewAutoSizeColumnMode.Fill;
- }
- _logger.LogInformation("Загрузка компонентов");
- }
- catch (Exception ex)
- {
- _logger.LogError(ex, "Ошибка загрузки компонентов");
- MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK,
- MessageBoxIcon.Error);
- }
- }
- private void ButtonAdd_Click(object sender, EventArgs e)
- {
- var service =
- Program.ServiceProvider?.GetService(typeof(FormComponent));
- if (service is FormComponent form)
- {
- if (form.ShowDialog() == DialogResult.OK)
- {
- LoadData();
- }
- }
- }
- private void ButtonUpd_Click(object sender, EventArgs e)
- {
- if (dataGridView.SelectedRows.Count == 1)
- {
- var service = Program.ServiceProvider?.GetService(typeof(FormComponent));
- if (service is FormComponent form)
- {
- form.Id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
- if (form.ShowDialog() == DialogResult.OK)
- {
- LoadData();
- }
- }
- }
- }
- private void ButtonDel_Click(object sender, EventArgs e)
- {
- if (dataGridView.SelectedRows.Count == 1)
- {
- if (MessageBox.Show("Удалить запись?", "Вопрос",
- MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
- {
- int id =
- Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
- _logger.LogInformation("Удаление компонента");
- try
- {
- if (!_logic.Delete(new ComponentBindingModel
- {
- Id = id
- }))
- {
- throw new Exception("Ошибка при удалении. Дополнительная информация в логах.");
- }
- LoadData();
- }
- catch (Exception ex)
- {
- _logger.LogError(ex, "Ошибка удаления компонента");
- MessageBox.Show(ex.Message, "Ошибка",
- MessageBoxButtons.OK, MessageBoxIcon.Error);
- }
- }
- }
- }
- private void ButtonRef_Click(object sender, EventArgs e)
- {
- LoadData();
- }
- }
-}
diff --git a/Confectionery/FormComponents.resx b/Confectionery/FormComponents.resx
deleted file mode 100644
index f298a7b..0000000
--- a/Confectionery/FormComponents.resx
+++ /dev/null
@@ -1,60 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- text/microsoft-resx
-
-
- 2.0
-
-
- System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
-
-
- System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
-
-
\ No newline at end of file
diff --git a/Confectionery/FormCreateOrder.Designer.cs b/Confectionery/FormCreateOrder.Designer.cs
deleted file mode 100644
index ab9a95b..0000000
--- a/Confectionery/FormCreateOrder.Designer.cs
+++ /dev/null
@@ -1,147 +0,0 @@
-namespace ConfectioneryView
-{
- partial class FormCreateOrder
- {
- ///
- /// Required designer variable.
- ///
- private System.ComponentModel.IContainer components = null;
-
- ///
- /// Clean up any resources being used.
- ///
- /// true if managed resources should be disposed; otherwise, false.
- protected override void Dispose(bool disposing)
- {
- if (disposing && (components != null))
- {
- components.Dispose();
- }
- base.Dispose(disposing);
- }
-
- #region Windows Form Designer generated code
-
- ///
- /// Required method for Designer support - do not modify
- /// the contents of this method with the code editor.
- ///
- private void InitializeComponent()
- {
- this.label1 = new System.Windows.Forms.Label();
- this.label2 = new System.Windows.Forms.Label();
- this.label3 = new System.Windows.Forms.Label();
- this.buttonCancel = new System.Windows.Forms.Button();
- this.buttonSave = new System.Windows.Forms.Button();
- this.comboBoxPastry = new System.Windows.Forms.ComboBox();
- this.textBoxCount = new System.Windows.Forms.NumericUpDown();
- this.textBoxSum = new System.Windows.Forms.TextBox();
- ((System.ComponentModel.ISupportInitialize)(this.textBoxCount)).BeginInit();
- this.SuspendLayout();
- //
- // label1
- //
- this.label1.AutoSize = true;
- this.label1.Location = new System.Drawing.Point(12, 9);
- this.label1.Name = "label1";
- this.label1.Size = new System.Drawing.Size(56, 15);
- this.label1.TabIndex = 0;
- this.label1.Text = "Изделие:";
- //
- // label2
- //
- this.label2.AutoSize = true;
- this.label2.Location = new System.Drawing.Point(12, 40);
- this.label2.Name = "label2";
- this.label2.Size = new System.Drawing.Size(75, 15);
- this.label2.TabIndex = 1;
- this.label2.Text = "Количество:";
- //
- // label3
- //
- this.label3.AutoSize = true;
- this.label3.Location = new System.Drawing.Point(12, 68);
- this.label3.Name = "label3";
- this.label3.Size = new System.Drawing.Size(48, 15);
- this.label3.TabIndex = 2;
- this.label3.Text = "Сумма:";
- //
- // buttonCancel
- //
- this.buttonCancel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
- this.buttonCancel.Location = new System.Drawing.Point(221, 109);
- this.buttonCancel.Name = "buttonCancel";
- this.buttonCancel.Size = new System.Drawing.Size(95, 23);
- this.buttonCancel.TabIndex = 3;
- this.buttonCancel.Text = "Отмена";
- this.buttonCancel.UseVisualStyleBackColor = true;
- this.buttonCancel.Click += new System.EventHandler(this.ButtonCancel_Click);
- //
- // buttonSave
- //
- this.buttonSave.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
- this.buttonSave.Location = new System.Drawing.Point(141, 109);
- this.buttonSave.Name = "buttonSave";
- this.buttonSave.Size = new System.Drawing.Size(77, 23);
- this.buttonSave.TabIndex = 4;
- this.buttonSave.Text = "Сохранить";
- this.buttonSave.UseVisualStyleBackColor = true;
- this.buttonSave.Click += new System.EventHandler(this.ButtonSave_Click);
- //
- // comboBoxPastry
- //
- this.comboBoxPastry.FormattingEnabled = true;
- this.comboBoxPastry.Location = new System.Drawing.Point(101, 9);
- this.comboBoxPastry.Name = "comboBoxPastry";
- this.comboBoxPastry.Size = new System.Drawing.Size(214, 23);
- this.comboBoxPastry.TabIndex = 5;
- this.comboBoxPastry.SelectedIndexChanged += new System.EventHandler(this.ComboBoxPastry_SelectedIndexChanged);
- //
- // textBoxCount
- //
- this.textBoxCount.Location = new System.Drawing.Point(101, 38);
- this.textBoxCount.Name = "textBoxCount";
- this.textBoxCount.Size = new System.Drawing.Size(214, 23);
- this.textBoxCount.TabIndex = 6;
- this.textBoxCount.ValueChanged += new System.EventHandler(this.TextBoxCount_TextChanged);
- //
- // textBoxSum
- //
- this.textBoxSum.Location = new System.Drawing.Point(101, 65);
- this.textBoxSum.Name = "textBoxSum";
- this.textBoxSum.Size = new System.Drawing.Size(214, 23);
- this.textBoxSum.TabIndex = 7;
- //
- // FormCreateOrder
- //
- this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
- this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
- this.ClientSize = new System.Drawing.Size(327, 144);
- this.Controls.Add(this.textBoxSum);
- this.Controls.Add(this.textBoxCount);
- this.Controls.Add(this.comboBoxPastry);
- this.Controls.Add(this.buttonSave);
- this.Controls.Add(this.buttonCancel);
- this.Controls.Add(this.label3);
- this.Controls.Add(this.label2);
- this.Controls.Add(this.label1);
- this.Name = "FormCreateOrder";
- this.Text = "Создание заказа";
- ((System.ComponentModel.ISupportInitialize)(this.textBoxCount)).EndInit();
- this.ResumeLayout(false);
- this.PerformLayout();
-
- }
-
- #endregion
-
- private Label label1;
- private Label label2;
- private Label label3;
- private Button buttonCancel;
- private Button buttonSave;
- private ComboBox comboBoxPastry;
- private NumericUpDown textBoxCount;
- private TextBox textBoxSum;
- }
-}
\ No newline at end of file
diff --git a/Confectionery/FormCreateOrder.cs b/Confectionery/FormCreateOrder.cs
deleted file mode 100644
index 703c7b2..0000000
--- a/Confectionery/FormCreateOrder.cs
+++ /dev/null
@@ -1,117 +0,0 @@
-using ConfectioneryContracts.BindingModels;
-using ConfectioneryContracts.BusinessLogicsContracts;
-using ConfectioneryContracts.SearchModels;
-using ConfectioneryContracts.ViewModels;
-using Microsoft.Extensions.Logging;
-
-
-namespace ConfectioneryView
-{
- public partial class FormCreateOrder : Form
- {
- private readonly ILogger _logger;
- private readonly IPastryLogic _logicP;
- private readonly IOrderLogic _logicO;
- private readonly List? _list;
-
- public FormCreateOrder(ILogger logger, IPastryLogic logicP, IOrderLogic logicO)
- {
- InitializeComponent();
- _logger = logger;
- _logicP = logicP;
- _logicO = logicO;
- _list = logicP.ReadList(null);
- if (_list != null)
- {
- comboBoxPastry.DisplayMember = "PastryName";
- comboBoxPastry.ValueMember = "Id";
- comboBoxPastry.DataSource = _list;
- comboBoxPastry.SelectedItem = null;
- }
- }
- private void FormCreateOrder_Load(object sender, EventArgs e)
- {
- _logger.LogInformation("Загрузка изделий для заказа");
- foreach (var el in _logicP.ReadList(null) ?? new())
- {
- comboBoxPastry.Items.Add(el.PastryName);
- }
- }
- private void CalcSum()
- {
- if (comboBoxPastry.SelectedValue != null && !string.IsNullOrEmpty(textBoxCount.Text))
- {
- try
- {
- int id = Convert.ToInt32(comboBoxPastry.SelectedValue);
- var pastry = _logicP.ReadElement(new()
- {
- Id = id
- });
- int count = Convert.ToInt32(textBoxCount.Value);
- textBoxSum.Text = Math.Round(count * (pastry?.Price ?? 0), 2).ToString();
- _logger.LogInformation("Расчет суммы заказа");
- }
- catch (Exception ex)
- {
- _logger.LogError(ex, "Ошибка расчета суммы заказа");
- MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK,
- MessageBoxIcon.Error);
- }
- }
- }
- private void TextBoxCount_TextChanged(object sender, EventArgs e)
- {
- CalcSum();
- }
- private void ComboBoxPastry_SelectedIndexChanged(object sender, EventArgs e)
- {
- CalcSum();
- }
- private void ButtonSave_Click(object sender, EventArgs e)
- {
- if (string.IsNullOrEmpty(textBoxCount.Text))
- {
- MessageBox.Show("Заполните поле Количество", "Ошибка",
- MessageBoxButtons.OK, MessageBoxIcon.Error);
- return;
- }
- if (comboBoxPastry.SelectedValue == null)
- {
- MessageBox.Show("Выберите изделие", "Ошибка",
- MessageBoxButtons.OK, MessageBoxIcon.Error);
- return;
- }
- _logger.LogInformation("Создание заказа");
- try
- {
- var operationResult = _logicO.CreateOrder(new OrderBindingModel
- {
- PastryId = Convert.ToInt32(comboBoxPastry.SelectedValue),
- Count = Convert.ToInt32(textBoxCount.Text),
- Sum = Convert.ToDouble(textBoxSum.Text)
- });
- if (!operationResult)
- {
- throw new Exception("Ошибка при создании заказа. Дополнительная информация в логах.");
- }
- MessageBox.Show("Сохранение прошло успешно", "Сообщение",
- MessageBoxButtons.OK, MessageBoxIcon.Information);
- DialogResult = DialogResult.OK;
- Close();
- }
- catch (Exception ex)
- {
- _logger.LogError(ex, "Ошибка создания заказа");
- MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK,
- MessageBoxIcon.Error);
- }
- }
- private void ButtonCancel_Click(object sender, EventArgs e)
- {
- DialogResult = DialogResult.Cancel;
- Close();
- }
- }
-}
-
diff --git a/Confectionery/FormCreateOrder.resx b/Confectionery/FormCreateOrder.resx
deleted file mode 100644
index f298a7b..0000000
--- a/Confectionery/FormCreateOrder.resx
+++ /dev/null
@@ -1,60 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- text/microsoft-resx
-
-
- 2.0
-
-
- System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
-
-
- System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
-
-
\ No newline at end of file
diff --git a/Confectionery/FormMain.Designer.cs b/Confectionery/FormMain.Designer.cs
deleted file mode 100644
index c90ca46..0000000
--- a/Confectionery/FormMain.Designer.cs
+++ /dev/null
@@ -1,182 +0,0 @@
-namespace ConfectioneryView
-{
- partial class FormMain
- {
- ///
- /// Required designer variable.
- ///
- private System.ComponentModel.IContainer components = null;
-
- ///
- /// Clean up any resources being used.
- ///
- /// true if managed resources should be disposed; otherwise, false.
- protected override void Dispose(bool disposing)
- {
- if (disposing && (components != null))
- {
- components.Dispose();
- }
- base.Dispose(disposing);
- }
-
- #region Windows Form Designer generated code
-
- ///
- /// Required method for Designer support - do not modify
- /// the contents of this method with the code editor.
- ///
- private void InitializeComponent()
- {
- this.menuStrip1 = new System.Windows.Forms.MenuStrip();
- this.справочникиToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
- this.pastryToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
- this.componentToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
- this.dataGridView = new System.Windows.Forms.DataGridView();
- this.buttonCreateOrder = new System.Windows.Forms.Button();
- this.buttonTakeOrderInWork = new System.Windows.Forms.Button();
- this.button2 = new System.Windows.Forms.Button();
- this.button3 = new System.Windows.Forms.Button();
- this.button4 = new System.Windows.Forms.Button();
- this.menuStrip1.SuspendLayout();
- ((System.ComponentModel.ISupportInitialize)(this.dataGridView)).BeginInit();
- this.SuspendLayout();
- //
- // menuStrip1
- //
- this.menuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
- this.справочникиToolStripMenuItem});
- this.menuStrip1.Location = new System.Drawing.Point(0, 0);
- this.menuStrip1.Name = "menuStrip1";
- this.menuStrip1.Size = new System.Drawing.Size(783, 24);
- this.menuStrip1.TabIndex = 0;
- this.menuStrip1.Text = "menuStrip1";
- //
- // справочникиToolStripMenuItem
- //
- this.справочникиToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
- this.pastryToolStripMenuItem,
- this.componentToolStripMenuItem});
- this.справочникиToolStripMenuItem.Name = "справочникиToolStripMenuItem";
- this.справочникиToolStripMenuItem.Size = new System.Drawing.Size(94, 20);
- this.справочникиToolStripMenuItem.Text = "Справочники";
- //
- // pastryToolStripMenuItem
- //
- this.pastryToolStripMenuItem.Name = "pastryToolStripMenuItem";
- this.pastryToolStripMenuItem.Size = new System.Drawing.Size(145, 22);
- this.pastryToolStripMenuItem.Text = "Изделия";
- this.pastryToolStripMenuItem.Click += new System.EventHandler(this.PastryToolStripMenuItem_Click);
- //
- // componentToolStripMenuItem
- //
- this.componentToolStripMenuItem.Name = "componentToolStripMenuItem";
- this.componentToolStripMenuItem.Size = new System.Drawing.Size(145, 22);
- this.componentToolStripMenuItem.Text = "Компоненты";
- this.componentToolStripMenuItem.Click += new System.EventHandler(this.ComponentsToolStripMenuItem_Click);
- //
- // dataGridView
- //
- this.dataGridView.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
- | System.Windows.Forms.AnchorStyles.Left)
- | System.Windows.Forms.AnchorStyles.Right)));
- this.dataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
- this.dataGridView.Location = new System.Drawing.Point(12, 27);
- this.dataGridView.Name = "dataGridView";
- this.dataGridView.RowTemplate.Height = 25;
- this.dataGridView.Size = new System.Drawing.Size(606, 341);
- this.dataGridView.TabIndex = 1;
- //
- // buttonCreateOrder
- //
- this.buttonCreateOrder.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
- this.buttonCreateOrder.Location = new System.Drawing.Point(624, 39);
- this.buttonCreateOrder.Name = "buttonCreateOrder";
- this.buttonCreateOrder.Size = new System.Drawing.Size(147, 32);
- this.buttonCreateOrder.TabIndex = 2;
- this.buttonCreateOrder.Text = "Создать заказ";
- this.buttonCreateOrder.UseVisualStyleBackColor = true;
- this.buttonCreateOrder.Click += new System.EventHandler(this.ButtonCreateOrder_Click);
- //
- // buttonTakeOrderInWork
- //
- this.buttonTakeOrderInWork.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
- this.buttonTakeOrderInWork.Location = new System.Drawing.Point(624, 98);
- this.buttonTakeOrderInWork.Name = "buttonTakeOrderInWork";
- this.buttonTakeOrderInWork.Size = new System.Drawing.Size(147, 32);
- this.buttonTakeOrderInWork.TabIndex = 3;
- this.buttonTakeOrderInWork.Text = "Отдать на выполнение";
- this.buttonTakeOrderInWork.UseVisualStyleBackColor = true;
- this.buttonTakeOrderInWork.Click += new System.EventHandler(this.ButtonTakeOrderInWork_Click);
- //
- // button2
- //
- this.button2.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
- this.button2.Location = new System.Drawing.Point(624, 157);
- this.button2.Name = "button2";
- this.button2.Size = new System.Drawing.Size(147, 32);
- this.button2.TabIndex = 4;
- this.button2.Text = "Заказ готов";
- this.button2.UseVisualStyleBackColor = true;
- this.button2.Click += new System.EventHandler(this.ButtonOrderReady_Click);
- //
- // button3
- //
- this.button3.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
- this.button3.Location = new System.Drawing.Point(624, 215);
- this.button3.Name = "button3";
- this.button3.Size = new System.Drawing.Size(147, 32);
- this.button3.TabIndex = 5;
- this.button3.Text = "Заказ выдан";
- this.button3.UseVisualStyleBackColor = true;
- this.button3.Click += new System.EventHandler(this.ButtonIssuedOrder_Click);
- //
- // button4
- //
- this.button4.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
- this.button4.Location = new System.Drawing.Point(624, 274);
- this.button4.Name = "button4";
- this.button4.Size = new System.Drawing.Size(147, 32);
- this.button4.TabIndex = 6;
- this.button4.Text = "Обновить список";
- this.button4.UseVisualStyleBackColor = true;
- this.button4.Click += new System.EventHandler(this.ButtonRef_Click);
- //
- // FormMain
- //
- this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
- this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
- this.ClientSize = new System.Drawing.Size(783, 380);
- this.Controls.Add(this.button4);
- this.Controls.Add(this.button3);
- this.Controls.Add(this.button2);
- this.Controls.Add(this.buttonTakeOrderInWork);
- this.Controls.Add(this.buttonCreateOrder);
- this.Controls.Add(this.dataGridView);
- this.Controls.Add(this.menuStrip1);
- this.MainMenuStrip = this.menuStrip1;
- this.Name = "FormMain";
- this.Text = "Кондитерская";
- this.Load += new System.EventHandler(this.FormMain_Load);
- this.menuStrip1.ResumeLayout(false);
- this.menuStrip1.PerformLayout();
- ((System.ComponentModel.ISupportInitialize)(this.dataGridView)).EndInit();
- this.ResumeLayout(false);
- this.PerformLayout();
-
- }
-
- #endregion
-
- private MenuStrip menuStrip1;
- private ToolStripMenuItem справочникиToolStripMenuItem;
- private DataGridView dataGridView;
- private Button buttonCreateOrder;
- private Button buttonTakeOrderInWork;
- private Button button2;
- private Button button3;
- private Button button4;
- private ToolStripMenuItem pastryToolStripMenuItem;
- private ToolStripMenuItem componentToolStripMenuItem;
- }
-}
\ No newline at end of file
diff --git a/Confectionery/FormMain.cs b/Confectionery/FormMain.cs
deleted file mode 100644
index 190621c..0000000
--- a/Confectionery/FormMain.cs
+++ /dev/null
@@ -1,157 +0,0 @@
-using ConfectioneryBusinessLogic.BusinessLogics;
-using ConfectioneryContracts.BindingModels;
-using ConfectioneryContracts.BusinessLogicsContracts;
-using ConfectioneryDataModels.Enums;
-using Microsoft.Extensions.Logging;
-using System.Windows.Forms;
-
-namespace ConfectioneryView
-{
- public partial class FormMain : Form
- {
- private readonly ILogger _logger;
- private readonly IOrderLogic _orderLogic;
- public FormMain(ILogger logger, IOrderLogic orderLogic)
- {
- InitializeComponent();
- _logger = logger;
- _orderLogic = orderLogic;
- }
- private void FormMain_Load(object sender, EventArgs e)
- {
- LoadData();
- }
- private void LoadData()
- {
- try
- {
- var list = _orderLogic.ReadList(null);
- if (list != null)
- {
- dataGridView.DataSource = list;
- dataGridView.Columns["Id"].HeaderText = " ";
- dataGridView.Columns["PastryId"].Visible = false;
- dataGridView.Columns["PastryName"].AutoSizeMode =
- DataGridViewAutoSizeColumnMode.Fill;
- }
- _logger.LogInformation(" ");
- }
- catch (Exception ex)
- {
- _logger.LogError(ex, " ");
- MessageBox.Show(ex.Message, "", MessageBoxButtons.OK,
- MessageBoxIcon.Error);
- }
- }
- private void ComponentsToolStripMenuItem_Click(object sender, EventArgs
- e)
- {
- var service = Program.ServiceProvider?.GetService(typeof(FormComponents));
- if (service is FormComponents form)
- {
- form.ShowDialog();
- }
- }
- private void PastryToolStripMenuItem_Click(object sender, EventArgs e)
- {
- var service = Program.ServiceProvider?.GetService(typeof(FormViewPastry));
- if (service is FormViewPastry form)
- {
- form.ShowDialog();
- }
- }
-
- private void ButtonCreateOrder_Click(object sender, EventArgs e)
- {
- var service =
- Program.ServiceProvider?.GetService(typeof(FormCreateOrder));
- if (service is FormCreateOrder form)
- {
- form.ShowDialog();
- LoadData();
- }
- }
-
- private void ButtonTakeOrderInWork_Click(object sender, EventArgs e)
- {
- if (dataGridView.SelectedRows.Count == 1)
- {
- int id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
- _logger.LogInformation(" No{id}. ' '", id);
- try
- {
- var operationResult = _orderLogic.TakeOrderInWork(new OrderBindingModel{ Id = id });
- if (!operationResult)
- {
- throw new Exception(" . .");
- }
- LoadData();
- }
- catch (Exception ex)
- {
- _logger.LogError(ex, " ");
- MessageBox.Show(ex.Message, "", MessageBoxButtons.OK,
- MessageBoxIcon.Error);
- }
- }
- }
- private void ButtonOrderReady_Click(object sender, EventArgs e)
- {
- if (dataGridView.SelectedRows.Count == 1)
- {
- int id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
- OrderStatus orderStatus = (OrderStatus)dataGridView.SelectedRows[0].Cells["Status"].Value;
- _logger.LogInformation(" No{id}. ''", id);
- try
- {
- var operationResult = _orderLogic.FinishOrder(new OrderBindingModel
- {
- Id = id,
- Status = orderStatus
- });
- if (!operationResult)
- {
- throw new Exception(" . .");
- }
- LoadData();
- }
- catch (Exception ex)
- {
- _logger.LogError(ex, " ");
- MessageBox.Show(ex.Message, "", MessageBoxButtons.OK, MessageBoxIcon.Error);
- }
- }
- }
- private void ButtonIssuedOrder_Click(object sender, EventArgs e)
- {
- if (dataGridView.SelectedRows.Count == 1)
- {
- int id =
- Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
- _logger.LogInformation(" No{id}. ''", id);
- try
- {
- var operationResult = _orderLogic.DeliveryOrder(new
- OrderBindingModel
- { Id = id });
- if (!operationResult)
- {
- throw new Exception(" . .");
- }
- _logger.LogInformation(" No{id} ", id);
- LoadData();
- }
- catch (Exception ex)
- {
- _logger.LogError(ex, " ");
- MessageBox.Show(ex.Message, "", MessageBoxButtons.OK,
- MessageBoxIcon.Error);
- }
- }
- }
- private void ButtonRef_Click(object sender, EventArgs e)
- {
- LoadData();
- }
- }
-}
\ No newline at end of file
diff --git a/Confectionery/FormMain.resx b/Confectionery/FormMain.resx
deleted file mode 100644
index 938108a..0000000
--- a/Confectionery/FormMain.resx
+++ /dev/null
@@ -1,63 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- text/microsoft-resx
-
-
- 2.0
-
-
- System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
-
-
- System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
-
-
- 17, 17
-
-
\ No newline at end of file
diff --git a/Confectionery/FormPastry.Designer.cs b/Confectionery/FormPastry.Designer.cs
deleted file mode 100644
index 1c6ecaf..0000000
--- a/Confectionery/FormPastry.Designer.cs
+++ /dev/null
@@ -1,236 +0,0 @@
-namespace ConfectioneryView
-{
- partial class FormPastry
- {
- ///
- /// Required designer variable.
- ///
- private System.ComponentModel.IContainer components = null;
-
- ///
- /// Clean up any resources being used.
- ///
- /// true if managed resources should be disposed; otherwise, false.
- protected override void Dispose(bool disposing)
- {
- if (disposing && (components != null))
- {
- components.Dispose();
- }
- base.Dispose(disposing);
- }
-
- #region Windows Form Designer generated code
-
- ///
- /// Required method for Designer support - do not modify
- /// the contents of this method with the code editor.
- ///
- private void InitializeComponent()
- {
- this.label1 = new System.Windows.Forms.Label();
- this.label2 = new System.Windows.Forms.Label();
- this.groupBox1 = new System.Windows.Forms.GroupBox();
- this.buttonRef = new System.Windows.Forms.Button();
- this.buttonDel = new System.Windows.Forms.Button();
- this.buttonUpd = new System.Windows.Forms.Button();
- this.buttonAdd = new System.Windows.Forms.Button();
- this.dataGridView = new System.Windows.Forms.DataGridView();
- this.id = new System.Windows.Forms.DataGridViewTextBoxColumn();
- this.Component = new System.Windows.Forms.DataGridViewTextBoxColumn();
- this.Count = new System.Windows.Forms.DataGridViewTextBoxColumn();
- this.textBoxName = new System.Windows.Forms.TextBox();
- this.textBoxPrice = new System.Windows.Forms.TextBox();
- this.buttonCancel = new System.Windows.Forms.Button();
- this.buttonSave = new System.Windows.Forms.Button();
- this.groupBox1.SuspendLayout();
- ((System.ComponentModel.ISupportInitialize)(this.dataGridView)).BeginInit();
- this.SuspendLayout();
- //
- // label1
- //
- this.label1.AutoSize = true;
- this.label1.Location = new System.Drawing.Point(12, 9);
- this.label1.Name = "label1";
- this.label1.Size = new System.Drawing.Size(62, 15);
- this.label1.TabIndex = 0;
- this.label1.Text = "Название:";
- //
- // label2
- //
- this.label2.AutoSize = true;
- this.label2.Location = new System.Drawing.Point(12, 40);
- this.label2.Name = "label2";
- this.label2.Size = new System.Drawing.Size(70, 15);
- this.label2.TabIndex = 1;
- this.label2.Text = "Стоимость:";
- //
- // groupBox1
- //
- this.groupBox1.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink;
- this.groupBox1.Controls.Add(this.buttonRef);
- this.groupBox1.Controls.Add(this.buttonDel);
- this.groupBox1.Controls.Add(this.buttonUpd);
- this.groupBox1.Controls.Add(this.buttonAdd);
- this.groupBox1.Controls.Add(this.dataGridView);
- this.groupBox1.Location = new System.Drawing.Point(12, 67);
- this.groupBox1.Name = "groupBox1";
- this.groupBox1.RightToLeft = System.Windows.Forms.RightToLeft.No;
- this.groupBox1.Size = new System.Drawing.Size(776, 330);
- this.groupBox1.TabIndex = 2;
- this.groupBox1.TabStop = false;
- this.groupBox1.Text = "Компоненты:";
- //
- // buttonRef
- //
- this.buttonRef.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
- this.buttonRef.Location = new System.Drawing.Point(680, 207);
- this.buttonRef.Name = "buttonRef";
- this.buttonRef.Size = new System.Drawing.Size(90, 37);
- this.buttonRef.TabIndex = 4;
- this.buttonRef.Text = "Обновить";
- this.buttonRef.UseVisualStyleBackColor = true;
- this.buttonRef.Click += new System.EventHandler(this.ButtonRef_Click);
- //
- // buttonDel
- //
- this.buttonDel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
- this.buttonDel.Location = new System.Drawing.Point(680, 158);
- this.buttonDel.Name = "buttonDel";
- this.buttonDel.Size = new System.Drawing.Size(90, 33);
- this.buttonDel.TabIndex = 3;
- this.buttonDel.Text = "Удалить";
- this.buttonDel.UseVisualStyleBackColor = true;
- this.buttonDel.Click += new System.EventHandler(this.ButtonDel_Click);
- //
- // buttonUpd
- //
- this.buttonUpd.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
- this.buttonUpd.Location = new System.Drawing.Point(680, 108);
- this.buttonUpd.Name = "buttonUpd";
- this.buttonUpd.Size = new System.Drawing.Size(90, 34);
- this.buttonUpd.TabIndex = 2;
- this.buttonUpd.Text = "Изменить";
- this.buttonUpd.UseVisualStyleBackColor = true;
- this.buttonUpd.Click += new System.EventHandler(this.ButtonUpd_Click);
- //
- // buttonAdd
- //
- this.buttonAdd.Location = new System.Drawing.Point(680, 62);
- this.buttonAdd.Name = "buttonAdd";
- this.buttonAdd.Size = new System.Drawing.Size(90, 30);
- this.buttonAdd.TabIndex = 1;
- this.buttonAdd.Text = "Добавить";
- this.buttonAdd.UseVisualStyleBackColor = true;
- this.buttonAdd.Click += new System.EventHandler(this.ButtonAdd_Click);
- //
- // dataGridView
- //
- this.dataGridView.AutoSizeColumnsMode = System.Windows.Forms.DataGridViewAutoSizeColumnsMode.ColumnHeader;
- this.dataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
- this.dataGridView.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] {
- this.id,
- this.Component,
- this.Count});
- this.dataGridView.Location = new System.Drawing.Point(7, 22);
- this.dataGridView.Name = "dataGridView";
- this.dataGridView.RowTemplate.Height = 25;
- this.dataGridView.Size = new System.Drawing.Size(571, 302);
- this.dataGridView.TabIndex = 0;
- //
- // id
- //
- this.id.HeaderText = "id";
- this.id.Name = "id";
- this.id.Visible = false;
- //
- // Component
- //
- this.Component.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill;
- this.Component.FillWeight = 1000F;
- this.Component.HeaderText = "Компонент";
- this.Component.Name = "Component";
- //
- // Count
- //
- this.Count.HeaderText = "Количество";
- this.Count.Name = "Count";
- this.Count.Width = 97;
- //
- // textBoxName
- //
- this.textBoxName.Location = new System.Drawing.Point(89, 9);
- this.textBoxName.Name = "textBoxName";
- this.textBoxName.Size = new System.Drawing.Size(170, 23);
- this.textBoxName.TabIndex = 3;
- //
- // textBoxPrice
- //
- this.textBoxPrice.Location = new System.Drawing.Point(89, 38);
- this.textBoxPrice.Name = "textBoxPrice";
- this.textBoxPrice.Size = new System.Drawing.Size(120, 23);
- this.textBoxPrice.TabIndex = 4;
- //
- // buttonCancel
- //
- this.buttonCancel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
- this.buttonCancel.Location = new System.Drawing.Point(692, 403);
- this.buttonCancel.Name = "buttonCancel";
- this.buttonCancel.Size = new System.Drawing.Size(90, 35);
- this.buttonCancel.TabIndex = 5;
- this.buttonCancel.Text = "Отмена";
- this.buttonCancel.UseVisualStyleBackColor = true;
- this.buttonCancel.Click += new System.EventHandler(this.ButtonCancel_Click);
- //
- // buttonSave
- //
- this.buttonSave.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
- this.buttonSave.Location = new System.Drawing.Point(596, 403);
- this.buttonSave.Name = "buttonSave";
- this.buttonSave.Size = new System.Drawing.Size(90, 35);
- this.buttonSave.TabIndex = 6;
- this.buttonSave.Text = "Сохранить";
- this.buttonSave.UseVisualStyleBackColor = true;
- this.buttonSave.Click += new System.EventHandler(this.ButtonSave_Click);
- //
- // FormPastry
- //
- this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
- this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
- this.ClientSize = new System.Drawing.Size(800, 450);
- this.Controls.Add(this.buttonSave);
- this.Controls.Add(this.buttonCancel);
- this.Controls.Add(this.textBoxPrice);
- this.Controls.Add(this.textBoxName);
- this.Controls.Add(this.groupBox1);
- this.Controls.Add(this.label2);
- this.Controls.Add(this.label1);
- this.Name = "FormPastry";
- this.Text = "Кондитерское изделие";
- this.Load += new System.EventHandler(this.FormPastry_Load);
- this.groupBox1.ResumeLayout(false);
- ((System.ComponentModel.ISupportInitialize)(this.dataGridView)).EndInit();
- this.ResumeLayout(false);
- this.PerformLayout();
-
- }
-
- #endregion
-
- private Label label1;
- private Label label2;
- private GroupBox groupBox1;
- private TextBox textBoxName;
- private TextBox textBoxPrice;
- private Button buttonRef;
- private Button buttonDel;
- private Button buttonUpd;
- private Button buttonAdd;
- private DataGridView dataGridView;
- private DataGridViewTextBoxColumn id;
- private DataGridViewTextBoxColumn Component;
- private DataGridViewTextBoxColumn Count;
- private Button buttonCancel;
- private Button buttonSave;
- }
-}
\ No newline at end of file
diff --git a/Confectionery/FormPastry.cs b/Confectionery/FormPastry.cs
deleted file mode 100644
index e3e7bfd..0000000
--- a/Confectionery/FormPastry.cs
+++ /dev/null
@@ -1,213 +0,0 @@
-using ConfectioneryContracts.BindingModels;
-using ConfectioneryContracts.BusinessLogicsContracts;
-using ConfectioneryContracts.SearchModels;
-using ConfectioneryDataModels.Models;
-using Microsoft.Extensions.Logging;
-
-namespace ConfectioneryView
-{
- public partial class FormPastry : Form
- {
- private readonly ILogger _logger;
- private readonly IPastryLogic _logic;
- private int? _id;
- private Dictionary _pastryComponents;
- public int Id { set { _id = value; } }
- public FormPastry(ILogger logger, IPastryLogic logic)
- {
- InitializeComponent();
- _logger = logger;
- _logic = logic;
- _pastryComponents = new Dictionary();
- }
- private void FormPastry_Load(object sender, EventArgs e)
- {
- if (_id.HasValue)
- {
- _logger.LogInformation("Загрузка изделия");
- try
- {
- var view = _logic.ReadElement(new PastrySearchModel
- {
- Id = _id.Value
- });
- if (view != null)
- {
- textBoxName.Text = view.PastryName;
- textBoxPrice.Text = view.Price.ToString();
- _pastryComponents = view.PastryComponents ?? new
- Dictionary();
- LoadData();
- }
- }
- catch (Exception ex)
- {
- _logger.LogError(ex, "Ошибка загрузки изделия");
- MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK,
- MessageBoxIcon.Error);
- }
- }
- }
- private void LoadData()
- {
- _logger.LogInformation("Загрузка компонент изделия");
- try
- {
- if (_pastryComponents != null)
- {
- dataGridView.Rows.Clear();
- foreach (var pc in _pastryComponents)
- {
- dataGridView.Rows.Add(new object[] { pc.Key, pc.Value.Item1.ComponentName, pc.Value.Item2 });
- }
- textBoxPrice.Text = CalcPrice().ToString();
- }
- }
- catch (Exception ex)
- {
- _logger.LogError(ex, "Ошибка загрузки компонент изделия");
- MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK,
- MessageBoxIcon.Error);
- }
- }
- private void ButtonAdd_Click(object sender, EventArgs e)
- {
- var service =
- Program.ServiceProvider?.GetService(typeof(FormPastryComponent));
- if (service is FormPastryComponent form)
- {
- if (form.ShowDialog() == DialogResult.OK)
- {
- if (form.ComponentModel == null)
- {
- return;
- }
- _logger.LogInformation("Добавление нового компонента: { ComponentName}- { Count}",
- form.ComponentModel.ComponentName, form.Count);
- if (_pastryComponents.ContainsKey(form.Id))
- {
- _pastryComponents[form.Id] = (form.ComponentModel,
- form.Count);
- }
- else
- {
- _pastryComponents.Add(form.Id, (form.ComponentModel,
- form.Count));
- }
- LoadData();
- }
- }
- }
- private void ButtonUpd_Click(object sender, EventArgs e)
- {
- if (dataGridView.SelectedRows.Count == 1)
- {
- var service = Program.ServiceProvider?.GetService(typeof(FormPastryComponent));
- if (service is FormPastryComponent form)
- {
- int id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells[0].Value);
- form.Id = id;
- form.Count = _pastryComponents[id].Item2;
- if (form.ShowDialog() == DialogResult.OK)
- {
- if (form.ComponentModel == null)
- {
- return;
- }
- _logger.LogInformation("Изменение компонента: { ComponentName} - { Count} ",
- form.ComponentModel.ComponentName, form.Count);
- _pastryComponents[id] = (form.ComponentModel, form.Count);
- LoadData();
- }
- }
- }
- }
- private void ButtonDel_Click(object sender, EventArgs e)
- {
- if (dataGridView.SelectedRows.Count == 1)
- {
- if (MessageBox.Show("Удалить запись?", "Вопрос",
- MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
- {
- try
- {
- _logger.LogInformation("Удаление компонента: { ComponentName}- { Count}",
- dataGridView.SelectedRows[0].Cells[1].Value);
- _pastryComponents?.Remove(Convert.ToInt32(dataGridView.SelectedRows[0].Cells[0].Value));
- }
- catch (Exception ex)
- {
- MessageBox.Show(ex.Message, "Ошибка",
- MessageBoxButtons.OK, MessageBoxIcon.Error);
- }
- LoadData();
- }
- }
- }
- private void ButtonRef_Click(object sender, EventArgs e)
- {
- LoadData();
- }
- private void ButtonSave_Click(object sender, EventArgs e)
- {
- if (string.IsNullOrEmpty(textBoxName.Text))
- {
- MessageBox.Show("Заполните название", "Ошибка",
- MessageBoxButtons.OK, MessageBoxIcon.Error);
- return;
- }
- if (string.IsNullOrEmpty(textBoxPrice.Text))
- {
- MessageBox.Show("Заполните цену", "Ошибка", MessageBoxButtons.OK,
- MessageBoxIcon.Error);
- return;
- }
- if (_pastryComponents == null || _pastryComponents.Count == 0)
- {
- MessageBox.Show("Заполните компоненты", "Ошибка",
- MessageBoxButtons.OK, MessageBoxIcon.Error);
- return;
- }
- _logger.LogInformation("Сохранение изделия");
- try
- {
- var model = new PastryBindingModel
- {
- Id = _id ?? 0,
- PastryName = textBoxName.Text,
- Price = Convert.ToDouble(textBoxPrice.Text),
- PastryComponents = _pastryComponents
- };
- var operationResult = _id.HasValue ? _logic.Update(model) :
- _logic.Create(model);
- if (!operationResult)
- {
- throw new Exception("Ошибка при сохранении. Дополнительная информация в логах.");
- }
- MessageBox.Show("Сохранение прошло успешно", "Сообщение",
- MessageBoxButtons.OK, MessageBoxIcon.Information);
- DialogResult = DialogResult.OK;
- Close();
- }
- catch (Exception ex)
- {
- _logger.LogError(ex, "Ошибка сохранения изделия");
- MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
- }
- }
- private void ButtonCancel_Click(object sender, EventArgs e)
- {
- DialogResult = DialogResult.Cancel;
- Close();
- }
- private double CalcPrice()
- {
- double price = 0;
- foreach (var elem in _pastryComponents)
- {
- price += ((elem.Value.Item1?.Cost ?? 0) * elem.Value.Item2);
- }
- return Math.Round(price * 1.1, 2);
- }
- }
-}
diff --git a/Confectionery/FormPastry.resx b/Confectionery/FormPastry.resx
deleted file mode 100644
index 1bfa2bf..0000000
--- a/Confectionery/FormPastry.resx
+++ /dev/null
@@ -1,69 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- text/microsoft-resx
-
-
- 2.0
-
-
- System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
-
-
- System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
-
-
- True
-
-
- True
-
-
- True
-
-
\ No newline at end of file
diff --git a/Confectionery/FormPastryComponent.Designer.cs b/Confectionery/FormPastryComponent.Designer.cs
deleted file mode 100644
index 3a39e37..0000000
--- a/Confectionery/FormPastryComponent.Designer.cs
+++ /dev/null
@@ -1,119 +0,0 @@
-namespace ConfectioneryView
-{
- partial class FormPastryComponent
- {
- ///
- /// Required designer variable.
- ///
- private System.ComponentModel.IContainer components = null;
-
- ///
- /// Clean up any resources being used.
- ///
- /// true if managed resources should be disposed; otherwise, false.
- protected override void Dispose(bool disposing)
- {
- if (disposing && (components != null))
- {
- components.Dispose();
- }
- base.Dispose(disposing);
- }
-
- #region Windows Form Designer generated code
-
- ///
- /// Required method for Designer support - do not modify
- /// the contents of this method with the code editor.
- ///
- private void InitializeComponent()
- {
- this.label1 = new System.Windows.Forms.Label();
- this.label2 = new System.Windows.Forms.Label();
- this.comboBoxComponent = new System.Windows.Forms.ComboBox();
- this.ButtonCancel = new System.Windows.Forms.Button();
- this.ButtonSave = new System.Windows.Forms.Button();
- this.textBoxCount = new System.Windows.Forms.TextBox();
- this.SuspendLayout();
- //
- // label1
- //
- this.label1.AutoSize = true;
- this.label1.Location = new System.Drawing.Point(12, 9);
- this.label1.Name = "label1";
- this.label1.Size = new System.Drawing.Size(72, 15);
- this.label1.TabIndex = 0;
- this.label1.Text = "Компонент:";
- //
- // label2
- //
- this.label2.AutoSize = true;
- this.label2.Location = new System.Drawing.Point(12, 45);
- this.label2.Name = "label2";
- this.label2.Size = new System.Drawing.Size(75, 15);
- this.label2.TabIndex = 1;
- this.label2.Text = "Количество:";
- //
- // comboBoxComponent
- //
- this.comboBoxComponent.FormattingEnabled = true;
- this.comboBoxComponent.Location = new System.Drawing.Point(107, 9);
- this.comboBoxComponent.Name = "comboBoxComponent";
- this.comboBoxComponent.Size = new System.Drawing.Size(231, 23);
- this.comboBoxComponent.TabIndex = 2;
- //
- // ButtonCancel
- //
- this.ButtonCancel.Location = new System.Drawing.Point(234, 87);
- this.ButtonCancel.Name = "ButtonCancel";
- this.ButtonCancel.Size = new System.Drawing.Size(104, 23);
- this.ButtonCancel.TabIndex = 4;
- this.ButtonCancel.Text = "Отмена";
- this.ButtonCancel.UseVisualStyleBackColor = true;
- this.ButtonCancel.Click += new System.EventHandler(this.ButtonCancel_Click);
- //
- // ButtonSave
- //
- this.ButtonSave.Location = new System.Drawing.Point(133, 87);
- this.ButtonSave.Name = "ButtonSave";
- this.ButtonSave.Size = new System.Drawing.Size(95, 23);
- this.ButtonSave.TabIndex = 5;
- this.ButtonSave.Text = "Сохранить";
- this.ButtonSave.UseVisualStyleBackColor = true;
- this.ButtonSave.Click += new System.EventHandler(this.ButtonSave_Click);
- //
- // textBoxCount
- //
- this.textBoxCount.Location = new System.Drawing.Point(107, 43);
- this.textBoxCount.Name = "textBoxCount";
- this.textBoxCount.Size = new System.Drawing.Size(231, 23);
- this.textBoxCount.TabIndex = 3;
- //
- // FormPastryComponent
- //
- this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
- this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
- this.ClientSize = new System.Drawing.Size(350, 122);
- this.Controls.Add(this.ButtonSave);
- this.Controls.Add(this.ButtonCancel);
- this.Controls.Add(this.textBoxCount);
- this.Controls.Add(this.comboBoxComponent);
- this.Controls.Add(this.label2);
- this.Controls.Add(this.label1);
- this.Name = "FormPastryComponent";
- this.Text = "Компонент";
- this.ResumeLayout(false);
- this.PerformLayout();
-
- }
-
- #endregion
-
- private Label label1;
- private Label label2;
- private ComboBox comboBoxComponent;
- private Button ButtonCancel;
- private Button ButtonSave;
- private TextBox textBoxCount;
- }
-}
\ No newline at end of file
diff --git a/Confectionery/FormPastryComponent.cs b/Confectionery/FormPastryComponent.cs
deleted file mode 100644
index 11933f1..0000000
--- a/Confectionery/FormPastryComponent.cs
+++ /dev/null
@@ -1,79 +0,0 @@
-using ConfectioneryContracts.ViewModels;
-using ConfectioneryContracts.BusinessLogicsContracts;
-using ConfectioneryDataModels.Models;
-
-namespace ConfectioneryView
-{
- public partial class FormPastryComponent : Form
- {
- private readonly List? _list;
- public int Id
- {
- get
- {
- return Convert.ToInt32(comboBoxComponent.SelectedValue);
- }
- set
- {
- comboBoxComponent.SelectedValue = value;
- }
- }
- public IComponentModel? ComponentModel
- {
- get
- {
- if (_list == null)
- {
- return null;
- }
- foreach (var elem in _list)
- {
- if (elem.Id == Id)
- {
- return elem;
- }
- }
- return null;
- }
- }
- public int Count
- {
- get { return Convert.ToInt32(textBoxCount.Text); }
- set { textBoxCount.Text = value.ToString(); }
- }
- public FormPastryComponent(IComponentLogic logic)
- {
- InitializeComponent();
- _list = logic.ReadList(null);
- if (_list != null)
- {
- comboBoxComponent.DisplayMember = "ComponentName";
- comboBoxComponent.ValueMember = "Id";
- comboBoxComponent.DataSource = _list;
- comboBoxComponent.SelectedItem = null;
- }
- }
- private void ButtonSave_Click(object sender, EventArgs e)
- {
- if (string.IsNullOrEmpty(textBoxCount.Text))
- {
- MessageBox.Show("Заполните поле Количество", "Ошибка",
- MessageBoxButtons.OK, MessageBoxIcon.Error);
- return;
- }
- if (comboBoxComponent.SelectedValue == null)
- {
- MessageBox.Show("Выберите компонент", "Ошибка",
- MessageBoxButtons.OK, MessageBoxIcon.Error);
- return;
- }
- DialogResult = DialogResult.OK;
- Close();
- }
- private void ButtonCancel_Click(object sender, EventArgs e)
- {
- DialogResult = DialogResult.Cancel;
- Close();
- }
- }
-}
\ No newline at end of file
diff --git a/Confectionery/FormPastryComponent.resx b/Confectionery/FormPastryComponent.resx
deleted file mode 100644
index f298a7b..0000000
--- a/Confectionery/FormPastryComponent.resx
+++ /dev/null
@@ -1,60 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- text/microsoft-resx
-
-
- 2.0
-
-
- System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
-
-
- System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
-
-
\ No newline at end of file
diff --git a/Confectionery/FormViewPastry.Designer.cs b/Confectionery/FormViewPastry.Designer.cs
deleted file mode 100644
index 67d3480..0000000
--- a/Confectionery/FormViewPastry.Designer.cs
+++ /dev/null
@@ -1,121 +0,0 @@
-namespace ConfectioneryView
-{
- partial class FormViewPastry
- {
- ///
- /// Required designer variable.
- ///
- private System.ComponentModel.IContainer components = null;
-
- ///
- /// Clean up any resources being used.
- ///
- /// true if managed resources should be disposed; otherwise, false.
- protected override void Dispose(bool disposing)
- {
- if (disposing && (components != null))
- {
- components.Dispose();
- }
- base.Dispose(disposing);
- }
-
- #region Windows Form Designer generated code
-
- ///
- /// Required method for Designer support - do not modify
- /// the contents of this method with the code editor.
- ///
- private void InitializeComponent()
- {
- this.buttonRef = new System.Windows.Forms.Button();
- this.buttonDel = new System.Windows.Forms.Button();
- this.buttonUpd = new System.Windows.Forms.Button();
- this.buttonAdd = new System.Windows.Forms.Button();
- this.dataGridView = new System.Windows.Forms.DataGridView();
- ((System.ComponentModel.ISupportInitialize)(this.dataGridView)).BeginInit();
- this.SuspendLayout();
- //
- // buttonRef
- //
- this.buttonRef.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
- this.buttonRef.Location = new System.Drawing.Point(626, 202);
- this.buttonRef.Name = "buttonRef";
- this.buttonRef.Size = new System.Drawing.Size(90, 37);
- this.buttonRef.TabIndex = 9;
- this.buttonRef.Text = "Обновить";
- this.buttonRef.UseVisualStyleBackColor = true;
- this.buttonRef.Click += new System.EventHandler(this.ButtonRef_Click);
- //
- // buttonDel
- //
- this.buttonDel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
- this.buttonDel.Location = new System.Drawing.Point(626, 151);
- this.buttonDel.Name = "buttonDel";
- this.buttonDel.Size = new System.Drawing.Size(90, 33);
- this.buttonDel.TabIndex = 8;
- this.buttonDel.Text = "Удалить";
- this.buttonDel.UseVisualStyleBackColor = true;
- this.buttonDel.Click += new System.EventHandler(this.ButtonDel_Click);
- //
- // buttonUpd
- //
- this.buttonUpd.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
- this.buttonUpd.Location = new System.Drawing.Point(626, 102);
- this.buttonUpd.Name = "buttonUpd";
- this.buttonUpd.Size = new System.Drawing.Size(90, 34);
- this.buttonUpd.TabIndex = 7;
- this.buttonUpd.Text = "Изменить";
- this.buttonUpd.UseVisualStyleBackColor = true;
- this.buttonUpd.Click += new System.EventHandler(this.ButtonUpd_Click);
- //
- // buttonAdd
- //
- this.buttonAdd.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
- this.buttonAdd.Location = new System.Drawing.Point(626, 57);
- this.buttonAdd.Name = "buttonAdd";
- this.buttonAdd.Size = new System.Drawing.Size(90, 30);
- this.buttonAdd.TabIndex = 6;
- this.buttonAdd.Text = "Добавить";
- this.buttonAdd.UseVisualStyleBackColor = true;
- this.buttonAdd.Click += new System.EventHandler(this.ButtonAdd_Click);
- //
- // dataGridView
- //
- this.dataGridView.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
- | System.Windows.Forms.AnchorStyles.Left)
- | System.Windows.Forms.AnchorStyles.Right)));
- this.dataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
- this.dataGridView.Location = new System.Drawing.Point(12, 12);
- this.dataGridView.Name = "dataGridView";
- this.dataGridView.RowTemplate.Height = 25;
- this.dataGridView.Size = new System.Drawing.Size(553, 302);
- this.dataGridView.TabIndex = 5;
- //
- // FormViewPastry
- //
- this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
- this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
- this.ClientSize = new System.Drawing.Size(722, 319);
- this.Controls.Add(this.buttonRef);
- this.Controls.Add(this.buttonDel);
- this.Controls.Add(this.buttonUpd);
- this.Controls.Add(this.buttonAdd);
- this.Controls.Add(this.dataGridView);
- this.Name = "FormViewPastry";
- this.Text = "Редактирование изделий";
- this.Load += new System.EventHandler(this.FormViewPastry_Load);
- ((System.ComponentModel.ISupportInitialize)(this.dataGridView)).EndInit();
- this.ResumeLayout(false);
-
- }
-
- #endregion
-
- private Button buttonRef;
- private Button buttonDel;
- private Button buttonUpd;
- private Button buttonAdd;
- private DataGridView dataGridView;
- }
-}
\ No newline at end of file
diff --git a/Confectionery/FormViewPastry.cs b/Confectionery/FormViewPastry.cs
deleted file mode 100644
index cdcbec6..0000000
--- a/Confectionery/FormViewPastry.cs
+++ /dev/null
@@ -1,113 +0,0 @@
-using ConfectioneryContracts.BindingModels;
-using ConfectioneryContracts.BusinessLogicsContracts;
-using Microsoft.Extensions.Logging;
-using System;
-using System.Collections.Generic;
-using System.ComponentModel;
-using System.Data;
-using System.Drawing;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-using System.Windows.Forms;
-
-namespace ConfectioneryView
-{
- public partial class FormViewPastry : Form
- {
- private readonly ILogger _logger;
- private readonly IPastryLogic _logic;
- public FormViewPastry(ILogger logger, IPastryLogic logic)
- {
- InitializeComponent();
- _logger = logger;
- _logic = logic;
- }
- private void FormViewPastry_Load(object sender, EventArgs e)
- {
- LoadData();
- }
- private void LoadData()
- {
- try
- {
- var list = _logic.ReadList(null);
- if (list != null)
- {
- dataGridView.DataSource = list;
- dataGridView.Columns["Id"].Visible = false;
- dataGridView.Columns["PastryComponents"].Visible = false;
- dataGridView.Columns["PastryName"].AutoSizeMode =
- DataGridViewAutoSizeColumnMode.Fill;
- }
- _logger.LogInformation("Загрузка изделий");
- }
- catch (Exception ex)
- {
- _logger.LogError(ex, "Ошибка загрузки изделий");
- MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK,
- MessageBoxIcon.Error);
- }
- }
- private void ButtonAdd_Click(object sender, EventArgs e)
- {
- var service = Program.ServiceProvider?.GetService(typeof(FormPastry));
- if (service is FormPastry form)
- {
- if (form.ShowDialog() == DialogResult.OK)
- {
- LoadData();
- }
- }
- }
- private void ButtonUpd_Click(object sender, EventArgs e)
- {
- if (dataGridView.SelectedRows.Count == 1)
- {
- var service = Program.ServiceProvider?.GetService(typeof(FormPastry));
- if (service is FormPastry form)
- {
- form.Id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
- if (form.ShowDialog() == DialogResult.OK)
- {
- LoadData();
- }
- }
- }
- }
- private void ButtonDel_Click(object sender, EventArgs e)
- {
- if (dataGridView.SelectedRows.Count == 1)
- {
- if (MessageBox.Show("Удалить запись?", "Вопрос",
- MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
- {
- int id =
- Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
- _logger.LogInformation("Удаление изделия");
- try
- {
- if (!_logic.Delete(new PastryBindingModel
- {
- Id = id
- }))
- {
- throw new Exception("Ошибка при удалении. Дополнительная информация в логах.");
- }
- LoadData();
- }
- catch (Exception ex)
- {
- _logger.LogError(ex, "Ошибка удаления изделия");
- MessageBox.Show(ex.Message, "Ошибка",
- MessageBoxButtons.OK, MessageBoxIcon.Error);
- }
- }
- }
- }
- private void ButtonRef_Click(object sender, EventArgs e)
- {
- LoadData();
- }
- }
-}
diff --git a/Confectionery/FormViewPastry.resx b/Confectionery/FormViewPastry.resx
deleted file mode 100644
index f298a7b..0000000
--- a/Confectionery/FormViewPastry.resx
+++ /dev/null
@@ -1,60 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- text/microsoft-resx
-
-
- 2.0
-
-
- System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
-
-
- System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
-
-
\ No newline at end of file
diff --git a/Confectionery/Program.cs b/Confectionery/Program.cs
index 0ccb4c2..24a4e0b 100644
--- a/Confectionery/Program.cs
+++ b/Confectionery/Program.cs
@@ -1,14 +1,12 @@
-using ConfectioneryDatabaseImplement.Implements;
-using ConfectioneryDatabaseImplement;
-using ConfectioneryBusinessLogic.BusinessLogics;
-using ConfectioneryContracts.BusinessLogicsContracts;
-using ConfectioneryContracts.StoragesContract;
+using EkzamenBusinessLogic;
+using EkzamenContracts.BusinessLogicsContracts;
+using EkzamenContracts.StoragesContract;
+using EkzamenListImplement;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using NLog.Extensions.Logging;
-
-namespace ConfectioneryView
+namespace EkzamenView
{
internal static class Program
{
@@ -26,7 +24,6 @@ namespace ConfectioneryView
var services = new ServiceCollection();
ConfigureServices(services);
_serviceProvider = services.BuildServiceProvider();
- Application.Run(_serviceProvider.GetRequiredService());
}
private static void ConfigureServices(ServiceCollection services)
{
@@ -35,19 +32,10 @@ namespace ConfectioneryView
option.SetMinimumLevel(LogLevel.Information);
option.AddNLog("nlog.config");
});
- services.AddTransient();
- services.AddTransient();
- services.AddTransient();
- services.AddTransient();
- services.AddTransient();
- services.AddTransient();
- services.AddTransient();
- services.AddTransient();
- services.AddTransient();
- services.AddTransient();
- services.AddTransient();
- services.AddTransient();
- services.AddTransient();
+ services.AddTransient();
+ services.AddTransient();
+ services.AddTransient();
+ services.AddTransient();
}
}
}
\ No newline at end of file
diff --git a/ConfectioneryContracts/BindingModels/ComponentBindingModel.cs b/ConfectioneryContracts/BindingModels/ComponentBindingModel.cs
deleted file mode 100644
index a52ea8b..0000000
--- a/ConfectioneryContracts/BindingModels/ComponentBindingModel.cs
+++ /dev/null
@@ -1,11 +0,0 @@
-using ConfectioneryDataModels.Models;
-
-namespace ConfectioneryContracts.BindingModels
-{
- public class ComponentBindingModel : IComponentModel
- {
- public int Id { get; set; }
- public string ComponentName { get; set; } = string.Empty;
- public double Cost { get; set; }
- }
-}
diff --git a/ConfectioneryContracts/BindingModels/GroupBindingModel.cs b/ConfectioneryContracts/BindingModels/GroupBindingModel.cs
new file mode 100644
index 0000000..31be1f4
--- /dev/null
+++ b/ConfectioneryContracts/BindingModels/GroupBindingModel.cs
@@ -0,0 +1,12 @@
+using EkzamenDataModels;
+
+namespace EkzamenContracts.BindingModels
+{
+ public class GroupBindingModel : IGroupModel
+ {
+ public int Id { get; set; }
+ public string Name { get; set; }
+ public string Direction { get; set; }
+ public DateTime Created { get; set; }
+ }
+}
diff --git a/ConfectioneryContracts/BindingModels/OrderBindingModel.cs b/ConfectioneryContracts/BindingModels/OrderBindingModel.cs
deleted file mode 100644
index 0e3ce64..0000000
--- a/ConfectioneryContracts/BindingModels/OrderBindingModel.cs
+++ /dev/null
@@ -1,16 +0,0 @@
-using ConfectioneryDataModels.Enums;
-using ConfectioneryDataModels.Models;
-
-namespace ConfectioneryContracts.BindingModels
-{
- public class OrderBindingModel : IOrderModel
- {
- public int Id { get; set; }
- public int PastryId { get; set; }
- public int Count { get; set; }
- public double Sum { get; set; }
- public OrderStatus Status { get; set; } = OrderStatus.Неизвестен;
- public DateTime DateCreate { get; set; } = DateTime.Now;
- public DateTime? DateImplement { get; set; }
- }
-}
diff --git a/ConfectioneryContracts/BindingModels/PastryBindingModel.cs b/ConfectioneryContracts/BindingModels/PastryBindingModel.cs
deleted file mode 100644
index 7266e1c..0000000
--- a/ConfectioneryContracts/BindingModels/PastryBindingModel.cs
+++ /dev/null
@@ -1,16 +0,0 @@
-using ConfectioneryDataModels.Models;
-
-namespace ConfectioneryContracts.BindingModels
-{
- public class PastryBindingModel : IPastryModel
- {
- public int Id { get; set; }
- public string PastryName { get; set; } = string.Empty;
- public double Price { get; set; }
- public Dictionary PastryComponents
- {
- get;
- set;
- } = new();
- }
-}
diff --git a/ConfectioneryContracts/BindingModels/StudentBindingModel.cs b/ConfectioneryContracts/BindingModels/StudentBindingModel.cs
new file mode 100644
index 0000000..389a7a8
--- /dev/null
+++ b/ConfectioneryContracts/BindingModels/StudentBindingModel.cs
@@ -0,0 +1,17 @@
+using EkzamenDataModels;
+
+namespace EkzamenContracts.BindingModels
+{
+ public class StudentBindingModel : IStudentModel
+ {
+ public string fio { get; set; }
+
+ public int GroupId { get; set; }
+ public int RecordBookId { get; set; }
+ public int PassMark { get; set; }
+
+ public DateTime DateEnrollment { get; set; }
+
+ public int Id { get; set; }
+ }
+}
diff --git a/ConfectioneryContracts/BusinessLogicsContracts/IComponentLogic.cs b/ConfectioneryContracts/BusinessLogicsContracts/IComponentLogic.cs
deleted file mode 100644
index 59b96cb..0000000
--- a/ConfectioneryContracts/BusinessLogicsContracts/IComponentLogic.cs
+++ /dev/null
@@ -1,15 +0,0 @@
-using ConfectioneryContracts.BindingModels;
-using ConfectioneryContracts.SearchModels;
-using ConfectioneryContracts.ViewModels;
-
-namespace ConfectioneryContracts.BusinessLogicsContracts
-{
- public interface IComponentLogic
- {
- List? ReadList(ComponentSearchModel? model);
- ComponentViewModel? ReadElement(ComponentSearchModel model);
- bool Create(ComponentBindingModel model);
- bool Update(ComponentBindingModel model);
- bool Delete(ComponentBindingModel model);
- }
-}
diff --git a/ConfectioneryContracts/BusinessLogicsContracts/IGroupLogic.cs b/ConfectioneryContracts/BusinessLogicsContracts/IGroupLogic.cs
new file mode 100644
index 0000000..0b3175c
--- /dev/null
+++ b/ConfectioneryContracts/BusinessLogicsContracts/IGroupLogic.cs
@@ -0,0 +1,12 @@
+using EkzamenContracts.BindingModels;
+using EkzamenContracts.SearchModels;
+using EkzamenContracts.ViewModels;
+
+namespace EkzamenContracts.BusinessLogicsContracts
+{
+ public interface IGroupLogic
+ {
+ List? ReadList(GroupSearchModel? model);
+ bool CreateGroup(GroupBindingModel model);
+ }
+}
diff --git a/ConfectioneryContracts/BusinessLogicsContracts/IOrderLogic.cs b/ConfectioneryContracts/BusinessLogicsContracts/IOrderLogic.cs
deleted file mode 100644
index 221258a..0000000
--- a/ConfectioneryContracts/BusinessLogicsContracts/IOrderLogic.cs
+++ /dev/null
@@ -1,15 +0,0 @@
-using ConfectioneryContracts.BindingModels;
-using ConfectioneryContracts.SearchModels;
-using ConfectioneryContracts.ViewModels;
-
-namespace ConfectioneryContracts.BusinessLogicsContracts
-{
- public interface IOrderLogic
- {
- List? ReadList(OrderSearchModel? model);
- bool CreateOrder(OrderBindingModel model);
- bool TakeOrderInWork(OrderBindingModel model);
- bool FinishOrder(OrderBindingModel model);
- bool DeliveryOrder(OrderBindingModel model);
- }
-}
diff --git a/ConfectioneryContracts/BusinessLogicsContracts/IPastryLogic.cs b/ConfectioneryContracts/BusinessLogicsContracts/IPastryLogic.cs
deleted file mode 100644
index e01ad56..0000000
--- a/ConfectioneryContracts/BusinessLogicsContracts/IPastryLogic.cs
+++ /dev/null
@@ -1,15 +0,0 @@
-using ConfectioneryContracts.BindingModels;
-using ConfectioneryContracts.SearchModels;
-using ConfectioneryContracts.ViewModels;
-
-namespace ConfectioneryContracts.BusinessLogicsContracts
-{
- public interface IPastryLogic
- {
- List? ReadList(PastrySearchModel? model);
- PastryViewModel? ReadElement(PastrySearchModel model);
- bool Create(PastryBindingModel model);
- bool Update(PastryBindingModel model);
- bool Delete(PastryBindingModel model);
- }
-}
diff --git a/ConfectioneryContracts/BusinessLogicsContracts/IStudentLogic.cs b/ConfectioneryContracts/BusinessLogicsContracts/IStudentLogic.cs
new file mode 100644
index 0000000..7c585e2
--- /dev/null
+++ b/ConfectioneryContracts/BusinessLogicsContracts/IStudentLogic.cs
@@ -0,0 +1,15 @@
+using EkzamenContracts.BindingModels;
+using EkzamenContracts.SearchModels;
+using EkzamenContracts.ViewModels;
+
+namespace EkzamenContracts.BusinessLogicsContracts
+{
+ public interface IStudentLogic
+ {
+ List? ReadList(StudentSearchModel? model);
+ StudentViewModel? ReadElement(StudentSearchModel model);
+ bool Create(StudentBindingModel model);
+ bool Update(StudentBindingModel model);
+ bool Delete(StudentBindingModel model);
+ }
+}
diff --git a/ConfectioneryContracts/ConfectioneryContracts.csproj b/ConfectioneryContracts/EkzamenContracts.csproj
similarity index 71%
rename from ConfectioneryContracts/ConfectioneryContracts.csproj
rename to ConfectioneryContracts/EkzamenContracts.csproj
index b0b970c..4844835 100644
--- a/ConfectioneryContracts/ConfectioneryContracts.csproj
+++ b/ConfectioneryContracts/EkzamenContracts.csproj
@@ -7,7 +7,7 @@
-
+
diff --git a/ConfectioneryContracts/SearchModels/ComponentSearchModel.cs b/ConfectioneryContracts/SearchModels/ComponentSearchModel.cs
deleted file mode 100644
index 2325c7f..0000000
--- a/ConfectioneryContracts/SearchModels/ComponentSearchModel.cs
+++ /dev/null
@@ -1,8 +0,0 @@
-namespace ConfectioneryContracts.SearchModels
-{
- public class ComponentSearchModel
- {
- public int? Id { get; set; }
- public string? ComponentName { get; set; }
- }
-}
diff --git a/ConfectioneryContracts/SearchModels/GroupSearchModel.cs b/ConfectioneryContracts/SearchModels/GroupSearchModel.cs
new file mode 100644
index 0000000..6062e8e
--- /dev/null
+++ b/ConfectioneryContracts/SearchModels/GroupSearchModel.cs
@@ -0,0 +1,8 @@
+namespace EkzamenContracts.SearchModels
+{
+ public class GroupSearchModel
+ {
+ public int? Id { get; set; }
+
+ }
+}
diff --git a/ConfectioneryContracts/SearchModels/OrderSearchModel.cs b/ConfectioneryContracts/SearchModels/OrderSearchModel.cs
deleted file mode 100644
index 6df7699..0000000
--- a/ConfectioneryContracts/SearchModels/OrderSearchModel.cs
+++ /dev/null
@@ -1,7 +0,0 @@
-namespace ConfectioneryContracts.SearchModels
-{
- public class OrderSearchModel
- {
- public int? Id { get; set; }
- }
-}
diff --git a/ConfectioneryContracts/SearchModels/PastrySearchModel.cs b/ConfectioneryContracts/SearchModels/PastrySearchModel.cs
deleted file mode 100644
index 542cf03..0000000
--- a/ConfectioneryContracts/SearchModels/PastrySearchModel.cs
+++ /dev/null
@@ -1,8 +0,0 @@
-namespace ConfectioneryContracts.SearchModels
-{
- public class PastrySearchModel
- {
- public int? Id { get; set; }
- public string? PastryName { get; set; }
- }
-}
diff --git a/ConfectioneryContracts/SearchModels/StudentSearchModel.cs b/ConfectioneryContracts/SearchModels/StudentSearchModel.cs
new file mode 100644
index 0000000..f0edb5b
--- /dev/null
+++ b/ConfectioneryContracts/SearchModels/StudentSearchModel.cs
@@ -0,0 +1,11 @@
+namespace EkzamenContracts.SearchModels
+{
+ public class StudentSearchModel
+ {
+ public int? Id { get; set; }
+ public DateTime? CreatedDateFrom { get; set; }
+ public DateTime? CreatedDateTo { get; set; }
+
+
+ }
+}
diff --git a/ConfectioneryContracts/StoragesContract/IComponentStorage.cs b/ConfectioneryContracts/StoragesContract/IComponentStorage.cs
deleted file mode 100644
index e1d0004..0000000
--- a/ConfectioneryContracts/StoragesContract/IComponentStorage.cs
+++ /dev/null
@@ -1,16 +0,0 @@
-using ConfectioneryContracts.BindingModels;
-using ConfectioneryContracts.SearchModels;
-using ConfectioneryContracts.ViewModels;
-
-namespace ConfectioneryContracts.StoragesContract
-{
- public interface IComponentStorage
- {
- List GetFullList();
- List GetFilteredList(ComponentSearchModel model);
- ComponentViewModel? GetElement(ComponentSearchModel model);
- ComponentViewModel? Insert(ComponentBindingModel model);
- ComponentViewModel? Update(ComponentBindingModel model);
- ComponentViewModel? Delete(ComponentBindingModel model);
- }
-}
diff --git a/ConfectioneryContracts/StoragesContract/IGroupStorage.cs b/ConfectioneryContracts/StoragesContract/IGroupStorage.cs
new file mode 100644
index 0000000..8396fe5
--- /dev/null
+++ b/ConfectioneryContracts/StoragesContract/IGroupStorage.cs
@@ -0,0 +1,16 @@
+using EkzamenContracts.BindingModels;
+using EkzamenContracts.SearchModels;
+using EkzamenContracts.ViewModels;
+
+namespace EkzamenContracts.StoragesContract
+{
+ public interface IGroupStorage
+ {
+ List GetFullList();
+ List GetFilteredList(GroupSearchModel model);
+ GroupViewModel? GetElement(GroupSearchModel model);
+ GroupViewModel? Insert(GroupBindingModel model);
+ GroupViewModel? Update(GroupBindingModel model);
+ GroupViewModel? Delete(GroupBindingModel model);
+ }
+}
diff --git a/ConfectioneryContracts/StoragesContract/IOrderStorage.cs b/ConfectioneryContracts/StoragesContract/IOrderStorage.cs
deleted file mode 100644
index 9d5bd2f..0000000
--- a/ConfectioneryContracts/StoragesContract/IOrderStorage.cs
+++ /dev/null
@@ -1,16 +0,0 @@
-using ConfectioneryContracts.BindingModels;
-using ConfectioneryContracts.SearchModels;
-using ConfectioneryContracts.ViewModels;
-
-namespace ConfectioneryContracts.StoragesContract
-{
- public interface IOrderStorage
- {
- List GetFullList();
- List GetFilteredList(OrderSearchModel model);
- OrderViewModel? GetElement(OrderSearchModel model);
- OrderViewModel? Insert(OrderBindingModel model);
- OrderViewModel? Update(OrderBindingModel model);
- OrderViewModel? Delete(OrderBindingModel model);
- }
-}
diff --git a/ConfectioneryContracts/StoragesContract/IPastryStorage.cs b/ConfectioneryContracts/StoragesContract/IPastryStorage.cs
deleted file mode 100644
index 710526c..0000000
--- a/ConfectioneryContracts/StoragesContract/IPastryStorage.cs
+++ /dev/null
@@ -1,16 +0,0 @@
-using ConfectioneryContracts.BindingModels;
-using ConfectioneryContracts.SearchModels;
-using ConfectioneryContracts.ViewModels;
-
-namespace ConfectioneryContracts.StoragesContract
-{
- public interface IPastryStorage
- {
- List GetFullList();
- List GetFilteredList(PastrySearchModel model);
- PastryViewModel? GetElement(PastrySearchModel model);
- PastryViewModel? Insert(PastryBindingModel model);
- PastryViewModel? Update(PastryBindingModel model);
- PastryViewModel? Delete(PastryBindingModel model);
- }
-}
diff --git a/ConfectioneryContracts/StoragesContract/IStudentStorage.cs b/ConfectioneryContracts/StoragesContract/IStudentStorage.cs
new file mode 100644
index 0000000..dd9b796
--- /dev/null
+++ b/ConfectioneryContracts/StoragesContract/IStudentStorage.cs
@@ -0,0 +1,16 @@
+using EkzamenContracts.BindingModels;
+using EkzamenContracts.SearchModels;
+using EkzamenContracts.ViewModels;
+
+namespace EkzamenContracts.StoragesContract
+{
+ public interface IStudentStorage
+ {
+ List GetFullList();
+ List GetFilteredList(StudentSearchModel model);
+ StudentViewModel? GetElement(StudentSearchModel model);
+ StudentViewModel? Insert(StudentBindingModel model);
+ StudentViewModel? Update(StudentBindingModel model);
+ StudentViewModel? Delete(StudentBindingModel model);
+ }
+}
diff --git a/ConfectioneryContracts/ViewModels/ComponentViewModel.cs b/ConfectioneryContracts/ViewModels/ComponentViewModel.cs
deleted file mode 100644
index 8706c51..0000000
--- a/ConfectioneryContracts/ViewModels/ComponentViewModel.cs
+++ /dev/null
@@ -1,21 +0,0 @@
-using ConfectioneryDataModels.Models;
-using System;
-using System.Collections.Generic;
-using System.ComponentModel;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-
-namespace ConfectioneryContracts.ViewModels
-{
- public class ComponentViewModel : IComponentModel
- {
- public int Id { get; set; }
-
- [DisplayName("Название компонента")]
- public string ComponentName { get; set; } = string.Empty;
-
- [DisplayName("Цена")]
- public double Cost { get; set; }
- }
-}
diff --git a/ConfectioneryContracts/ViewModels/GroupViewModel.cs b/ConfectioneryContracts/ViewModels/GroupViewModel.cs
new file mode 100644
index 0000000..507464a
--- /dev/null
+++ b/ConfectioneryContracts/ViewModels/GroupViewModel.cs
@@ -0,0 +1,19 @@
+using System.ComponentModel;
+using EkzamenDataModels;
+
+namespace EkzamenContracts.ViewModels
+{
+ public class GroupViewModel : IGroupModel
+ {
+ public int Id { get; set; }
+ [DisplayName("Название группы")]
+
+ public string Name { get; set; }
+ [DisplayName("Направление")]
+
+ public string Direction { get; set; }
+ [DisplayName("Дата создания")]
+
+ public DateTime Created { get; set; }
+ }
+}
diff --git a/ConfectioneryContracts/ViewModels/OrderViewModel.cs b/ConfectioneryContracts/ViewModels/OrderViewModel.cs
deleted file mode 100644
index 1afadd8..0000000
--- a/ConfectioneryContracts/ViewModels/OrderViewModel.cs
+++ /dev/null
@@ -1,36 +0,0 @@
-using ConfectioneryDataModels.Enums;
-using ConfectioneryDataModels.Models;
-using System;
-using System.Collections.Generic;
-using System.ComponentModel;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-
-namespace ConfectioneryContracts.ViewModels
-{
- public class OrderViewModel : IOrderModel
- {
- [DisplayName("Номер")]
- public int Id { get; set; }
- public int PastryId { get; set; }
-
- [DisplayName("Изделие")]
- public string PastryName { get; set; } = string.Empty;
-
- [DisplayName("Количество")]
- public int Count { get; set; }
-
- [DisplayName("Сумма")]
- public double Sum { get; set; }
-
- [DisplayName("Статус")]
- public OrderStatus Status { get; set; } = OrderStatus.Неизвестен;
-
- [DisplayName("Дата создания")]
- public DateTime DateCreate { get; set; } = DateTime.Now;
-
- [DisplayName("Дата выполнения")]
- public DateTime? DateImplement { get; set; }
- }
-}
diff --git a/ConfectioneryContracts/ViewModels/PastryViewModel.cs b/ConfectioneryContracts/ViewModels/PastryViewModel.cs
deleted file mode 100644
index 32831ba..0000000
--- a/ConfectioneryContracts/ViewModels/PastryViewModel.cs
+++ /dev/null
@@ -1,24 +0,0 @@
-using ConfectioneryDataModels.Models;
-using System;
-using System.Collections.Generic;
-using System.ComponentModel;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-
-namespace ConfectioneryContracts.ViewModels
-{
- public class PastryViewModel : IPastryModel
- {
- public int Id { get; set; }
- [DisplayName("Название изделия")]
- public string PastryName { get; set; } = string.Empty;
- [DisplayName("Цена")]
- public double Price { get; set; }
- public Dictionary PastryComponents
- {
- get;
- set;
- } = new();
- }
-}
diff --git a/ConfectioneryContracts/ViewModels/StudentViewModel.cs b/ConfectioneryContracts/ViewModels/StudentViewModel.cs
new file mode 100644
index 0000000..b6ee423
--- /dev/null
+++ b/ConfectioneryContracts/ViewModels/StudentViewModel.cs
@@ -0,0 +1,22 @@
+using System.ComponentModel;
+using EkzamenDataModels;
+
+namespace EkzamenContracts.ViewModels
+{
+ public class StudentViewModel : IStudentModel
+ {
+ public int Id { get; set; }
+ [DisplayName("ФИО")]
+ public string fio { get; set; }
+ public int GroupId { get; set; }
+ [DisplayName("Зачетная книжка")]
+
+ public int RecordBookId { get; set; }
+ [DisplayName("Проходной балл")]
+
+ public int PassMark { get; set; }
+ [DisplayName("Дата поступления")]
+
+ public DateTime DateEnrollment { get; set; }
+ }
+}
diff --git a/ConfectioneryDataModels/ConfectioneryDataModels.csproj b/ConfectioneryDataModels/EkzamenDataModels.csproj
similarity index 100%
rename from ConfectioneryDataModels/ConfectioneryDataModels.csproj
rename to ConfectioneryDataModels/EkzamenDataModels.csproj
diff --git a/ConfectioneryDataModels/IComponentModel.cs b/ConfectioneryDataModels/IComponentModel.cs
deleted file mode 100644
index 1981909..0000000
--- a/ConfectioneryDataModels/IComponentModel.cs
+++ /dev/null
@@ -1,8 +0,0 @@
-namespace ConfectioneryDataModels.Models
-{
- public interface IComponentModel : IId
- {
- string ComponentName { get; }
- double Cost { get; }
- }
-}
diff --git a/ConfectioneryDataModels/IGroupModel.cs b/ConfectioneryDataModels/IGroupModel.cs
new file mode 100644
index 0000000..d43fc18
--- /dev/null
+++ b/ConfectioneryDataModels/IGroupModel.cs
@@ -0,0 +1,11 @@
+
+
+namespace EkzamenDataModels
+{
+ public interface IGroupModel : IId
+ {
+ string Name { get; set; }
+ string Direction { get; set; }
+ DateTime Created { get; set; }
+ }
+}
diff --git a/ConfectioneryDataModels/IId.cs b/ConfectioneryDataModels/IId.cs
index 3f58c8a..1370a33 100644
--- a/ConfectioneryDataModels/IId.cs
+++ b/ConfectioneryDataModels/IId.cs
@@ -1,4 +1,4 @@
-namespace ConfectioneryDataModels
+namespace EkzamenDataModels
{
public interface IId
{
diff --git a/ConfectioneryDataModels/IOrderModel.cs b/ConfectioneryDataModels/IOrderModel.cs
deleted file mode 100644
index 01118fd..0000000
--- a/ConfectioneryDataModels/IOrderModel.cs
+++ /dev/null
@@ -1,14 +0,0 @@
-using ConfectioneryDataModels.Enums;
-
-namespace ConfectioneryDataModels.Models
-{
- public interface IOrderModel : IId
- {
- int PastryId { get; }
- int Count { get; }
- double Sum { get; }
- OrderStatus Status { get; }
- DateTime DateCreate { get; }
- DateTime? DateImplement { get; }
- }
-}
diff --git a/ConfectioneryDataModels/IPastryModel.cs b/ConfectioneryDataModels/IPastryModel.cs
deleted file mode 100644
index b13c2c5..0000000
--- a/ConfectioneryDataModels/IPastryModel.cs
+++ /dev/null
@@ -1,9 +0,0 @@
-namespace ConfectioneryDataModels.Models
-{
- public interface IPastryModel : IId
- {
- string PastryName { get; }
- double Price { get; }
- Dictionary PastryComponents { get; }
- }
-}
diff --git a/ConfectioneryDataModels/IStudentModel.cs b/ConfectioneryDataModels/IStudentModel.cs
new file mode 100644
index 0000000..bacbd8c
--- /dev/null
+++ b/ConfectioneryDataModels/IStudentModel.cs
@@ -0,0 +1,13 @@
+namespace EkzamenDataModels
+{
+ public interface IStudentModel : IId
+ {
+ string fio { get; }
+
+ int GroupId { get; }
+ int RecordBookId { get; }
+ int PassMark { get; }
+
+ DateTime DateEnrollment { get; }
+ }
+}
diff --git a/ConfectioneryDataModels/OrderStatus.cs b/ConfectioneryDataModels/OrderStatus.cs
deleted file mode 100644
index bb0ce5a..0000000
--- a/ConfectioneryDataModels/OrderStatus.cs
+++ /dev/null
@@ -1,11 +0,0 @@
-namespace ConfectioneryDataModels.Enums
-{
- public enum OrderStatus
- {
- Неизвестен = -1,
- Принят = 0,
- Выполняется = 1,
- Готов = 2,
- Выдан = 3
- }
-}
\ No newline at end of file
diff --git a/ConfectioneryDatabaseImplement/Component.cs b/ConfectioneryDatabaseImplement/Component.cs
deleted file mode 100644
index e12c8f9..0000000
--- a/ConfectioneryDatabaseImplement/Component.cs
+++ /dev/null
@@ -1,58 +0,0 @@
-using ConfectioneryContracts.BindingModels;
-using ConfectioneryDataModels.Models;
-using System.ComponentModel.DataAnnotations.Schema;
-using System.ComponentModel.DataAnnotations;
-using ConfectioneryContracts.ViewModels;
-
-namespace ConfectioneryDatabaseImplement.Models
-{
- public class Component : IComponentModel
- {
- public int Id { get; private set; }
- [Required]
- public string ComponentName { get; private set; } = string.Empty;
- [Required]
- public double Cost { get; set; }
-
- [ForeignKey("ComponentId")]
- public virtual List PastryComponents { get; set; } = new();
-
- public static Component? Create(ComponentBindingModel model)
- {
- if (model == null)
- {
- return null;
- }
- return new Component()
- {
- Id = model.Id,
- ComponentName = model.ComponentName,
- Cost = model.Cost
- };
- }
- public static Component Create(ComponentViewModel model)
- {
- return new Component
- {
- Id = model.Id,
- ComponentName = model.ComponentName,
- Cost = model.Cost
- };
- }
- public void Update(ComponentBindingModel model)
- {
- if (model == null)
- {
- return;
- }
- ComponentName = model.ComponentName;
- Cost = model.Cost;
- }
- public ComponentViewModel GetViewModel => new()
- {
- Id = Id,
- ComponentName = ComponentName,
- Cost = Cost
- };
- }
-}
diff --git a/ConfectioneryDatabaseImplement/ComponentStorage.cs b/ConfectioneryDatabaseImplement/ComponentStorage.cs
deleted file mode 100644
index 495ecf7..0000000
--- a/ConfectioneryDatabaseImplement/ComponentStorage.cs
+++ /dev/null
@@ -1,80 +0,0 @@
-using ConfectioneryContracts.BindingModels;
-using ConfectioneryContracts.SearchModels;
-using ConfectioneryContracts.StoragesContract;
-using ConfectioneryContracts.ViewModels;
-using ConfectioneryDatabaseImplement.Models;
-
-namespace ConfectioneryDatabaseImplement.Implements
-{
- public class ComponentStorage : IComponentStorage
- {
- public List GetFullList()
- {
- using var context = new ConfectioneryDatabase();
- return context.Components
- .Select(x => x.GetViewModel)
- .ToList();
- }
- public List GetFilteredList(ComponentSearchModel model)
- {
- if (string.IsNullOrEmpty(model.ComponentName))
- {
- return new();
- }
- using var context = new ConfectioneryDatabase();
- return context.Components
- .Where(x => x.ComponentName.Contains(model.ComponentName))
- .Select(x => x.GetViewModel)
- .ToList();
- }
- public ComponentViewModel? GetElement(ComponentSearchModel model)
- {
- if (string.IsNullOrEmpty(model.ComponentName) && !model.Id.HasValue)
- {
- return null;
- }
- using var context = new ConfectioneryDatabase();
- return context.Components
- .FirstOrDefault(x =>
- (!string.IsNullOrEmpty(model.ComponentName) && x.ComponentName == model.ComponentName) ||
- (model.Id.HasValue && x.Id == model.Id))
- ?.GetViewModel;
- }
- public ComponentViewModel? Insert(ComponentBindingModel model)
- {
- var newComponent = Component.Create(model);
- if (newComponent == null)
- {
- return null;
- }
- using var context = new ConfectioneryDatabase();
- context.Components.Add(newComponent);
- context.SaveChanges();
- return newComponent.GetViewModel;
- }
- public ComponentViewModel? Update(ComponentBindingModel model)
- {
- using var context = new ConfectioneryDatabase();
- var component = context.Components.FirstOrDefault(x => x.Id == model.Id);
- if (component == null)
- {
- return null;
- }
- component.Update(model);
- context.SaveChanges();
- return component.GetViewModel;
- }
- public ComponentViewModel? Delete(ComponentBindingModel model)
- {
- using var context = new ConfectioneryDatabase();
- var element = context.Components.FirstOrDefault(rec => rec.Id == model.Id);
- if (element != null)
- {
- context.Components.Remove(element);
- context.SaveChanges();
- return element.GetViewModel;
- }
- return null;
- }
- }
-}
diff --git a/ConfectioneryDatabaseImplement/ConfectioneryDatabase.cs b/ConfectioneryDatabaseImplement/ConfectioneryDatabase.cs
index 08095db..92c4515 100644
--- a/ConfectioneryDatabaseImplement/ConfectioneryDatabase.cs
+++ b/ConfectioneryDatabaseImplement/ConfectioneryDatabase.cs
@@ -1,8 +1,6 @@
-using ConfectioneryDatabaseImplement.Models;
-using Microsoft.EntityFrameworkCore;
-using System.Diagnostics.Metrics;
+using Microsoft.EntityFrameworkCore;
-namespace ConfectioneryDatabaseImplement
+namespace EkzamenDatabaseImplement
{
public class ConfectioneryDatabase : DbContext
{
@@ -13,16 +11,14 @@ namespace ConfectioneryDatabaseImplement
{
optionsBuilder.UseSqlServer(@"
Server = localhost\SQLEXPRESS;
- Initial Catalog = ConfectioneryDatabaseFull;
+ Initial Catalog = EkzamenDatabaseFull;
Integrated Security = True;
MultipleActiveResultSets = True;
TrustServerCertificate = True");
}
base.OnConfiguring(optionsBuilder);
}
- public virtual DbSet Components { set; get; }
- public virtual DbSet Pastries { set; get; }
- public virtual DbSet PastryComponents { set; get; }
- public virtual DbSet Orders { set; get; }
+ public virtual DbSet Students { set; get; }
+ public virtual DbSet Groups { set; get; }
}
}
diff --git a/ConfectioneryDatabaseImplement/ConfectioneryDatabaseImplement.csproj b/ConfectioneryDatabaseImplement/EkzamenDatabaseImplement.csproj
similarity index 79%
rename from ConfectioneryDatabaseImplement/ConfectioneryDatabaseImplement.csproj
rename to ConfectioneryDatabaseImplement/EkzamenDatabaseImplement.csproj
index 6c6f63a..24402cb 100644
--- a/ConfectioneryDatabaseImplement/ConfectioneryDatabaseImplement.csproj
+++ b/ConfectioneryDatabaseImplement/EkzamenDatabaseImplement.csproj
@@ -16,8 +16,8 @@
-
-
+
+
diff --git a/ConfectioneryDatabaseImplement/Group.cs b/ConfectioneryDatabaseImplement/Group.cs
new file mode 100644
index 0000000..a985e98
--- /dev/null
+++ b/ConfectioneryDatabaseImplement/Group.cs
@@ -0,0 +1,53 @@
+using System.ComponentModel.DataAnnotations;
+using EkzamenContracts.BindingModels;
+using EkzamenContracts.ViewModels;
+using EkzamenDataModels;
+
+namespace EkzamenDatabaseImplement
+{
+ public class Group : IGroupModel
+ {
+ public int Id { get; private set; }
+
+ public static Group? Create(GroupBindingModel? model)
+ {
+ if (model == null)
+ {
+ return null;
+ }
+ return new Group()
+ {
+ Name = model.Name,
+ Direction = model.Direction,
+ Created = model.Created,
+ Id = model.Id,
+ };
+ }
+
+ public void Update(GroupBindingModel? model)
+ {
+ if (model == null)
+ {
+ return;
+ }
+ Direction = model.Direction;
+ Id = model.Id;
+ }
+ public GroupViewModel GetViewModel =>
+ new()
+ {
+ Name = Name,
+ Direction = Direction,
+ Created = Created,
+ Id = Id,
+ };
+
+ [Required]
+ public string Name { get; set; }
+ [Required]
+ public string Direction { get; set; }
+ public DateTime Created { get; set; }
+
+ public List Students { get; set; }
+ }
+}
diff --git a/ConfectioneryDatabaseImplement/OrderStorage.cs b/ConfectioneryDatabaseImplement/GroupStorage.cs
similarity index 56%
rename from ConfectioneryDatabaseImplement/OrderStorage.cs
rename to ConfectioneryDatabaseImplement/GroupStorage.cs
index 4e87161..ea9881a 100644
--- a/ConfectioneryDatabaseImplement/OrderStorage.cs
+++ b/ConfectioneryDatabaseImplement/GroupStorage.cs
@@ -1,67 +1,66 @@
-using ConfectioneryContracts.BindingModels;
-using ConfectioneryContracts.SearchModels;
-using ConfectioneryContracts.StoragesContract;
-using ConfectioneryContracts.ViewModels;
-using ConfectioneryDatabaseImplement.Models;
+using EkzamenContracts.BindingModels;
+using EkzamenContracts.SearchModels;
+using EkzamenContracts.StoragesContract;
+using EkzamenContracts.ViewModels;
-namespace ConfectioneryDatabaseImplement.Implements
+namespace EkzamenDatabaseImplement
{
- public class OrderStorage : IOrderStorage
+ public class GroupStorage : IGroupStorage
{
- public OrderViewModel? Delete(OrderBindingModel model)
+ public GroupViewModel? Delete(GroupBindingModel model)
{
using var context = new ConfectioneryDatabase();
- var element = context.Orders.FirstOrDefault(x => x.Id == model.Id);
+ var element = context.Groups.FirstOrDefault(x => x.Id == model.Id);
if (element != null)
{
- context.Orders.Remove(element);
+ context.Groups.Remove(element);
context.SaveChanges();
return element.GetViewModel;
}
return null;
}
- public OrderViewModel? GetElement(OrderSearchModel model)
+ public GroupViewModel? GetElement(GroupSearchModel model)
{
using var context = new ConfectioneryDatabase();
if (!model.Id.HasValue)
{
return null;
}
- return context.Orders.FirstOrDefault(x => model.Id.HasValue && x.Id == model.Id)?.GetViewModel;
+ return context.Groups.FirstOrDefault(x => model.Id.HasValue && x.Id == model.Id)?.GetViewModel;
}
- public List GetFilteredList(OrderSearchModel model)
+ public List GetFilteredList(GroupSearchModel model)
{
var result = GetElement(model);
return result != null ? new() { result } : new();
}
- public List GetFullList()
+ public List GetFullList()
{
using var context = new ConfectioneryDatabase();
- return context.Orders
+ return context.Groups
.Select(x => x.GetViewModel)
.ToList();
}
- public OrderViewModel? Insert(OrderBindingModel model)
+ public GroupViewModel? Insert(GroupBindingModel model)
{
- var newOrder = Order.Create(model);
+ var newOrder = Group.Create(model);
if (newOrder == null)
{
return null;
}
using var context = new ConfectioneryDatabase();
- context.Orders.Add(newOrder);
+ context.Groups.Add(newOrder);
context.SaveChanges();
return newOrder.GetViewModel;
}
- public OrderViewModel? Update(OrderBindingModel model)
+ public GroupViewModel? Update(GroupBindingModel model)
{
using var context = new ConfectioneryDatabase();
- var order = context.Orders.FirstOrDefault(x => x.Id == model.Id);
+ var order = context.Groups.FirstOrDefault(x => x.Id == model.Id);
if (order == null)
{
return null;
diff --git a/ConfectioneryDatabaseImplement/Migrations/20230219142123_InitialCreate.cs b/ConfectioneryDatabaseImplement/Migrations/20230219142123_InitialCreate.cs
deleted file mode 100644
index d633f68..0000000
--- a/ConfectioneryDatabaseImplement/Migrations/20230219142123_InitialCreate.cs
+++ /dev/null
@@ -1,125 +0,0 @@
-using System;
-using Microsoft.EntityFrameworkCore.Migrations;
-
-#nullable disable
-
-namespace ConfectioneryDatabaseImplement.Migrations
-{
- ///
- public partial class InitialCreate : Migration
- {
- ///
- protected override void Up(MigrationBuilder migrationBuilder)
- {
- migrationBuilder.CreateTable(
- name: "Components",
- columns: table => new
- {
- Id = table.Column(type: "int", nullable: false)
- .Annotation("SqlServer:Identity", "1, 1"),
- ComponentName = table.Column(type: "nvarchar(max)", nullable: false),
- Cost = table.Column(type: "float", nullable: false)
- },
- constraints: table =>
- {
- table.PrimaryKey("PK_Components", x => x.Id);
- });
-
- migrationBuilder.CreateTable(
- name: "Pastries",
- columns: table => new
- {
- Id = table.Column(type: "int", nullable: false)
- .Annotation("SqlServer:Identity", "1, 1"),
- PastryName = table.Column(type: "nvarchar(max)", nullable: false),
- Price = table.Column(type: "float", nullable: false)
- },
- constraints: table =>
- {
- table.PrimaryKey("PK_Pastries", x => x.Id);
- });
-
- migrationBuilder.CreateTable(
- name: "Orders",
- columns: table => new
- {
- Id = table.Column(type: "int", nullable: false)
- .Annotation("SqlServer:Identity", "1, 1"),
- PastryId = table.Column(type: "int", nullable: false),
- Count = table.Column(type: "int", nullable: false),
- Sum = table.Column(type: "float", nullable: false),
- Status = table.Column(type: "int", nullable: false),
- DateCreate = table.Column(type: "datetime2", nullable: false),
- DateImplement = table.Column(type: "datetime2", nullable: true)
- },
- constraints: table =>
- {
- table.PrimaryKey("PK_Orders", x => x.Id);
- table.ForeignKey(
- name: "FK_Orders_Pastries_PastryId",
- column: x => x.PastryId,
- principalTable: "Pastries",
- principalColumn: "Id",
- onDelete: ReferentialAction.Cascade);
- });
-
- migrationBuilder.CreateTable(
- name: "PastryComponents",
- columns: table => new
- {
- Id = table.Column(type: "int", nullable: false)
- .Annotation("SqlServer:Identity", "1, 1"),
- PastryId = table.Column(type: "int", nullable: false),
- ComponentId = table.Column(type: "int", nullable: false),
- Count = table.Column(type: "int", nullable: false)
- },
- constraints: table =>
- {
- table.PrimaryKey("PK_PastryComponents", x => x.Id);
- table.ForeignKey(
- name: "FK_PastryComponents_Components_ComponentId",
- column: x => x.ComponentId,
- principalTable: "Components",
- principalColumn: "Id",
- onDelete: ReferentialAction.Cascade);
- table.ForeignKey(
- name: "FK_PastryComponents_Pastries_PastryId",
- column: x => x.PastryId,
- principalTable: "Pastries",
- principalColumn: "Id",
- onDelete: ReferentialAction.Cascade);
- });
-
- migrationBuilder.CreateIndex(
- name: "IX_Orders_PastryId",
- table: "Orders",
- column: "PastryId");
-
- migrationBuilder.CreateIndex(
- name: "IX_PastryComponents_ComponentId",
- table: "PastryComponents",
- column: "ComponentId");
-
- migrationBuilder.CreateIndex(
- name: "IX_PastryComponents_PastryId",
- table: "PastryComponents",
- column: "PastryId");
- }
-
- ///
- protected override void Down(MigrationBuilder migrationBuilder)
- {
- migrationBuilder.DropTable(
- name: "Orders");
-
- migrationBuilder.DropTable(
- name: "PastryComponents");
-
- migrationBuilder.DropTable(
- name: "Components");
-
- migrationBuilder.DropTable(
- name: "Pastries");
- }
- }
-}
diff --git a/ConfectioneryDatabaseImplement/Migrations/20230219142123_InitialCreate.Designer.cs b/ConfectioneryDatabaseImplement/Migrations/20230228200344_create_shop.Designer.cs
similarity index 64%
rename from ConfectioneryDatabaseImplement/Migrations/20230219142123_InitialCreate.Designer.cs
rename to ConfectioneryDatabaseImplement/Migrations/20230228200344_create_shop.Designer.cs
index 4922144..ab30b13 100644
--- a/ConfectioneryDatabaseImplement/Migrations/20230219142123_InitialCreate.Designer.cs
+++ b/ConfectioneryDatabaseImplement/Migrations/20230228200344_create_shop.Designer.cs
@@ -12,8 +12,8 @@ using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
namespace ConfectioneryDatabaseImplement.Migrations
{
[DbContext(typeof(ConfectioneryDatabase))]
- [Migration("20230219142123_InitialCreate")]
- partial class InitialCreate
+ [Migration("20230228200344_create_shop")]
+ partial class create_shop
{
///
protected override void BuildTargetModel(ModelBuilder modelBuilder)
@@ -124,6 +124,64 @@ namespace ConfectioneryDatabaseImplement.Migrations
b.ToTable("PastryComponents");
});
+ modelBuilder.Entity("ConfectioneryDatabaseImplement.Models.Shop", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("int");
+
+ SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"));
+
+ b.Property("Address")
+ .IsRequired()
+ .HasColumnType("nvarchar(max)");
+
+ b.Property("DateOpening")
+ .HasColumnType("datetime2");
+
+ b.Property("MaxCountPastries")
+ .HasColumnType("int");
+
+ b.Property("Name")
+ .IsRequired()
+ .HasColumnType("nvarchar(max)");
+
+ b.Property("PastryId")
+ .HasColumnType("int");
+
+ b.HasKey("Id");
+
+ b.HasIndex("PastryId");
+
+ b.ToTable("Shops");
+ });
+
+ modelBuilder.Entity("ConfectioneryDatabaseImplement.Models.ShopPastry", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("int");
+
+ SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"));
+
+ b.Property("Count")
+ .HasColumnType("int");
+
+ b.Property("PastryId")
+ .HasColumnType("int");
+
+ b.Property("ShopId")
+ .HasColumnType("int");
+
+ b.HasKey("Id");
+
+ b.HasIndex("PastryId");
+
+ b.HasIndex("ShopId");
+
+ b.ToTable("ShopPastry");
+ });
+
modelBuilder.Entity("ConfectioneryDatabaseImplement.Models.Order", b =>
{
b.HasOne("ConfectioneryDatabaseImplement.Models.Pastry", "Pastry")
@@ -154,6 +212,32 @@ namespace ConfectioneryDatabaseImplement.Migrations
b.Navigation("Pastry");
});
+ modelBuilder.Entity("ConfectioneryDatabaseImplement.Models.Shop", b =>
+ {
+ b.HasOne("ConfectioneryDatabaseImplement.Models.Pastry", null)
+ .WithMany("Shops")
+ .HasForeignKey("PastryId");
+ });
+
+ modelBuilder.Entity("ConfectioneryDatabaseImplement.Models.ShopPastry", b =>
+ {
+ b.HasOne("ConfectioneryDatabaseImplement.Models.Pastry", "Pastry")
+ .WithMany()
+ .HasForeignKey("PastryId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
+ b.HasOne("ConfectioneryDatabaseImplement.Models.Shop", "Shop")
+ .WithMany("ShopPastry")
+ .HasForeignKey("ShopId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
+ b.Navigation("Pastry");
+
+ b.Navigation("Shop");
+ });
+
modelBuilder.Entity("ConfectioneryDatabaseImplement.Models.Component", b =>
{
b.Navigation("PastryComponents");
@@ -164,6 +248,13 @@ namespace ConfectioneryDatabaseImplement.Migrations
b.Navigation("Components");
b.Navigation("Orders");
+
+ b.Navigation("Shops");
+ });
+
+ modelBuilder.Entity("ConfectioneryDatabaseImplement.Models.Shop", b =>
+ {
+ b.Navigation("ShopPastry");
});
#pragma warning restore 612, 618
}
diff --git a/ConfectioneryDatabaseImplement/Migrations/20230228200344_create_shop.cs b/ConfectioneryDatabaseImplement/Migrations/20230228200344_create_shop.cs
new file mode 100644
index 0000000..1546c98
--- /dev/null
+++ b/ConfectioneryDatabaseImplement/Migrations/20230228200344_create_shop.cs
@@ -0,0 +1,89 @@
+using System;
+using Microsoft.EntityFrameworkCore.Migrations;
+
+#nullable disable
+
+namespace ConfectioneryDatabaseImplement.Migrations
+{
+ ///
+ public partial class create_shop : Migration
+ {
+ ///
+ protected override void Up(MigrationBuilder migrationBuilder)
+ {
+ migrationBuilder.CreateTable(
+ name: "Shops",
+ columns: table => new
+ {
+ Id = table.Column(type: "int", nullable: false)
+ .Annotation("SqlServer:Identity", "1, 1"),
+ Name = table.Column(type: "nvarchar(max)", nullable: false),
+ Address = table.Column(type: "nvarchar(max)", nullable: false),
+ MaxCountPastries = table.Column(type: "int", nullable: false),
+ DateOpening = table.Column(type: "datetime2", nullable: false),
+ PastryId = table.Column(type: "int", nullable: true)
+ },
+ constraints: table =>
+ {
+ table.PrimaryKey("PK_Shops", x => x.Id);
+ table.ForeignKey(
+ name: "FK_Shops_Pastries_PastryId",
+ column: x => x.PastryId,
+ principalTable: "Pastries",
+ principalColumn: "Id");
+ });
+
+ migrationBuilder.CreateTable(
+ name: "ShopPastry",
+ columns: table => new
+ {
+ Id = table.Column(type: "int", nullable: false)
+ .Annotation("SqlServer:Identity", "1, 1"),
+ PastryId = table.Column(type: "int", nullable: false),
+ ShopId = table.Column(type: "int", nullable: false),
+ Count = table.Column(type: "int", nullable: false)
+ },
+ constraints: table =>
+ {
+ table.PrimaryKey("PK_ShopPastry", x => x.Id);
+ table.ForeignKey(
+ name: "FK_ShopPastry_Pastries_PastryId",
+ column: x => x.PastryId,
+ principalTable: "Pastries",
+ principalColumn: "Id",
+ onDelete: ReferentialAction.Cascade);
+ table.ForeignKey(
+ name: "FK_ShopPastry_Shops_ShopId",
+ column: x => x.ShopId,
+ principalTable: "Shops",
+ principalColumn: "Id",
+ onDelete: ReferentialAction.Cascade);
+ });
+
+ migrationBuilder.CreateIndex(
+ name: "IX_ShopPastry_PastryId",
+ table: "ShopPastry",
+ column: "PastryId");
+
+ migrationBuilder.CreateIndex(
+ name: "IX_ShopPastry_ShopId",
+ table: "ShopPastry",
+ column: "ShopId");
+
+ migrationBuilder.CreateIndex(
+ name: "IX_Shops_PastryId",
+ table: "Shops",
+ column: "PastryId");
+ }
+
+ ///
+ protected override void Down(MigrationBuilder migrationBuilder)
+ {
+ migrationBuilder.DropTable(
+ name: "ShopPastry");
+
+ migrationBuilder.DropTable(
+ name: "Shops");
+ }
+ }
+}
diff --git a/ConfectioneryDatabaseImplement/Migrations/20230228204422_create_shop1.Designer.cs b/ConfectioneryDatabaseImplement/Migrations/20230228204422_create_shop1.Designer.cs
new file mode 100644
index 0000000..d47f4b1
--- /dev/null
+++ b/ConfectioneryDatabaseImplement/Migrations/20230228204422_create_shop1.Designer.cs
@@ -0,0 +1,262 @@
+//
+using System;
+using ConfectioneryDatabaseImplement;
+using Microsoft.EntityFrameworkCore;
+using Microsoft.EntityFrameworkCore.Infrastructure;
+using Microsoft.EntityFrameworkCore.Metadata;
+using Microsoft.EntityFrameworkCore.Migrations;
+using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
+
+#nullable disable
+
+namespace ConfectioneryDatabaseImplement.Migrations
+{
+ [DbContext(typeof(ConfectioneryDatabase))]
+ [Migration("20230228204422_create_shop1")]
+ partial class create_shop1
+ {
+ ///
+ protected override void BuildTargetModel(ModelBuilder modelBuilder)
+ {
+#pragma warning disable 612, 618
+ modelBuilder
+ .HasAnnotation("ProductVersion", "7.0.3")
+ .HasAnnotation("Relational:MaxIdentifierLength", 128);
+
+ SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder);
+
+ modelBuilder.Entity("ConfectioneryDatabaseImplement.Models.Component", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("int");
+
+ SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"));
+
+ b.Property("ComponentName")
+ .IsRequired()
+ .HasColumnType("nvarchar(max)");
+
+ b.Property("Cost")
+ .HasColumnType("float");
+
+ b.HasKey("Id");
+
+ b.ToTable("Components");
+ });
+
+ modelBuilder.Entity("ConfectioneryDatabaseImplement.Models.Order", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("int");
+
+ SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"));
+
+ b.Property("Count")
+ .HasColumnType("int");
+
+ b.Property("DateCreate")
+ .HasColumnType("datetime2");
+
+ b.Property("DateImplement")
+ .HasColumnType("datetime2");
+
+ b.Property("PastryId")
+ .HasColumnType("int");
+
+ b.Property("Status")
+ .HasColumnType("int");
+
+ b.Property("Sum")
+ .HasColumnType("float");
+
+ b.HasKey("Id");
+
+ b.HasIndex("PastryId");
+
+ b.ToTable("Orders");
+ });
+
+ modelBuilder.Entity("ConfectioneryDatabaseImplement.Models.Pastry", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("int");
+
+ SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"));
+
+ b.Property("PastryName")
+ .IsRequired()
+ .HasColumnType("nvarchar(max)");
+
+ b.Property("Price")
+ .HasColumnType("float");
+
+ b.HasKey("Id");
+
+ b.ToTable("Pastries");
+ });
+
+ modelBuilder.Entity("ConfectioneryDatabaseImplement.Models.PastryComponent", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("int");
+
+ SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"));
+
+ b.Property("ComponentId")
+ .HasColumnType("int");
+
+ b.Property("Count")
+ .HasColumnType("int");
+
+ b.Property("PastryId")
+ .HasColumnType("int");
+
+ b.HasKey("Id");
+
+ b.HasIndex("ComponentId");
+
+ b.HasIndex("PastryId");
+
+ b.ToTable("PastryComponents");
+ });
+
+ modelBuilder.Entity("ConfectioneryDatabaseImplement.Models.Shop", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("int");
+
+ SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"));
+
+ b.Property("Address")
+ .IsRequired()
+ .HasColumnType("nvarchar(max)");
+
+ b.Property("DateOpening")
+ .HasColumnType("datetime2");
+
+ b.Property("MaxCountPastries")
+ .HasColumnType("int");
+
+ b.Property("Name")
+ .IsRequired()
+ .HasColumnType("nvarchar(max)");
+
+ b.Property("PastryId")
+ .HasColumnType("int");
+
+ b.HasKey("Id");
+
+ b.HasIndex("PastryId");
+
+ b.ToTable("Shops");
+ });
+
+ modelBuilder.Entity("ConfectioneryDatabaseImplement.Models.ShopPastry", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("int");
+
+ SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"));
+
+ b.Property("Count")
+ .HasColumnType("int");
+
+ b.Property("PastryId")
+ .HasColumnType("int");
+
+ b.Property("ShopId")
+ .HasColumnType("int");
+
+ b.HasKey("Id");
+
+ b.HasIndex("PastryId");
+
+ b.HasIndex("ShopId");
+
+ b.ToTable("ShopPastries");
+ });
+
+ modelBuilder.Entity("ConfectioneryDatabaseImplement.Models.Order", b =>
+ {
+ b.HasOne("ConfectioneryDatabaseImplement.Models.Pastry", "Pastry")
+ .WithMany("Orders")
+ .HasForeignKey("PastryId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
+ b.Navigation("Pastry");
+ });
+
+ modelBuilder.Entity("ConfectioneryDatabaseImplement.Models.PastryComponent", b =>
+ {
+ b.HasOne("ConfectioneryDatabaseImplement.Models.Component", "Component")
+ .WithMany("PastryComponents")
+ .HasForeignKey("ComponentId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
+ b.HasOne("ConfectioneryDatabaseImplement.Models.Pastry", "Pastry")
+ .WithMany("Components")
+ .HasForeignKey("PastryId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
+ b.Navigation("Component");
+
+ b.Navigation("Pastry");
+ });
+
+ modelBuilder.Entity("ConfectioneryDatabaseImplement.Models.Shop", b =>
+ {
+ b.HasOne("ConfectioneryDatabaseImplement.Models.Pastry", null)
+ .WithMany("Shops")
+ .HasForeignKey("PastryId");
+ });
+
+ modelBuilder.Entity("ConfectioneryDatabaseImplement.Models.ShopPastry", b =>
+ {
+ b.HasOne("ConfectioneryDatabaseImplement.Models.Pastry", "Pastry")
+ .WithMany()
+ .HasForeignKey("PastryId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
+ b.HasOne("ConfectioneryDatabaseImplement.Models.Shop", "Shop")
+ .WithMany("ShopPastries")
+ .HasForeignKey("ShopId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
+ b.Navigation("Pastry");
+
+ b.Navigation("Shop");
+ });
+
+ modelBuilder.Entity("ConfectioneryDatabaseImplement.Models.Component", b =>
+ {
+ b.Navigation("PastryComponents");
+ });
+
+ modelBuilder.Entity("ConfectioneryDatabaseImplement.Models.Pastry", b =>
+ {
+ b.Navigation("Components");
+
+ b.Navigation("Orders");
+
+ b.Navigation("Shops");
+ });
+
+ modelBuilder.Entity("ConfectioneryDatabaseImplement.Models.Shop", b =>
+ {
+ b.Navigation("ShopPastries");
+ });
+#pragma warning restore 612, 618
+ }
+ }
+}
diff --git a/ConfectioneryDatabaseImplement/Migrations/20230228204422_create_shop1.cs b/ConfectioneryDatabaseImplement/Migrations/20230228204422_create_shop1.cs
new file mode 100644
index 0000000..107508b
--- /dev/null
+++ b/ConfectioneryDatabaseImplement/Migrations/20230228204422_create_shop1.cs
@@ -0,0 +1,112 @@
+using Microsoft.EntityFrameworkCore.Migrations;
+
+#nullable disable
+
+namespace ConfectioneryDatabaseImplement.Migrations
+{
+ ///
+ public partial class create_shop1 : Migration
+ {
+ ///
+ protected override void Up(MigrationBuilder migrationBuilder)
+ {
+ migrationBuilder.DropForeignKey(
+ name: "FK_ShopPastry_Pastries_PastryId",
+ table: "ShopPastry");
+
+ migrationBuilder.DropForeignKey(
+ name: "FK_ShopPastry_Shops_ShopId",
+ table: "ShopPastry");
+
+ migrationBuilder.DropPrimaryKey(
+ name: "PK_ShopPastry",
+ table: "ShopPastry");
+
+ migrationBuilder.RenameTable(
+ name: "ShopPastry",
+ newName: "ShopPastries");
+
+ migrationBuilder.RenameIndex(
+ name: "IX_ShopPastry_ShopId",
+ table: "ShopPastries",
+ newName: "IX_ShopPastries_ShopId");
+
+ migrationBuilder.RenameIndex(
+ name: "IX_ShopPastry_PastryId",
+ table: "ShopPastries",
+ newName: "IX_ShopPastries_PastryId");
+
+ migrationBuilder.AddPrimaryKey(
+ name: "PK_ShopPastries",
+ table: "ShopPastries",
+ column: "Id");
+
+ migrationBuilder.AddForeignKey(
+ name: "FK_ShopPastries_Pastries_PastryId",
+ table: "ShopPastries",
+ column: "PastryId",
+ principalTable: "Pastries",
+ principalColumn: "Id",
+ onDelete: ReferentialAction.Cascade);
+
+ migrationBuilder.AddForeignKey(
+ name: "FK_ShopPastries_Shops_ShopId",
+ table: "ShopPastries",
+ column: "ShopId",
+ principalTable: "Shops",
+ principalColumn: "Id",
+ onDelete: ReferentialAction.Cascade);
+ }
+
+ ///
+ protected override void Down(MigrationBuilder migrationBuilder)
+ {
+ migrationBuilder.DropForeignKey(
+ name: "FK_ShopPastries_Pastries_PastryId",
+ table: "ShopPastries");
+
+ migrationBuilder.DropForeignKey(
+ name: "FK_ShopPastries_Shops_ShopId",
+ table: "ShopPastries");
+
+ migrationBuilder.DropPrimaryKey(
+ name: "PK_ShopPastries",
+ table: "ShopPastries");
+
+ migrationBuilder.RenameTable(
+ name: "ShopPastries",
+ newName: "ShopPastry");
+
+ migrationBuilder.RenameIndex(
+ name: "IX_ShopPastries_ShopId",
+ table: "ShopPastry",
+ newName: "IX_ShopPastry_ShopId");
+
+ migrationBuilder.RenameIndex(
+ name: "IX_ShopPastries_PastryId",
+ table: "ShopPastry",
+ newName: "IX_ShopPastry_PastryId");
+
+ migrationBuilder.AddPrimaryKey(
+ name: "PK_ShopPastry",
+ table: "ShopPastry",
+ column: "Id");
+
+ migrationBuilder.AddForeignKey(
+ name: "FK_ShopPastry_Pastries_PastryId",
+ table: "ShopPastry",
+ column: "PastryId",
+ principalTable: "Pastries",
+ principalColumn: "Id",
+ onDelete: ReferentialAction.Cascade);
+
+ migrationBuilder.AddForeignKey(
+ name: "FK_ShopPastry_Shops_ShopId",
+ table: "ShopPastry",
+ column: "ShopId",
+ principalTable: "Shops",
+ principalColumn: "Id",
+ onDelete: ReferentialAction.Cascade);
+ }
+ }
+}
diff --git a/ConfectioneryDatabaseImplement/Migrations/20240202070935_Init.Designer.cs b/ConfectioneryDatabaseImplement/Migrations/20240202070935_Init.Designer.cs
new file mode 100644
index 0000000..ef2db2b
--- /dev/null
+++ b/ConfectioneryDatabaseImplement/Migrations/20240202070935_Init.Designer.cs
@@ -0,0 +1,101 @@
+//
+using System;
+using EkzamenDatabaseImplement;
+using Microsoft.EntityFrameworkCore;
+using Microsoft.EntityFrameworkCore.Infrastructure;
+using Microsoft.EntityFrameworkCore.Metadata;
+using Microsoft.EntityFrameworkCore.Migrations;
+using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
+
+#nullable disable
+
+namespace EkzamenDatabaseImplement.Migrations
+{
+ [DbContext(typeof(ConfectioneryDatabase))]
+ [Migration("20240202070935_Init")]
+ partial class Init
+ {
+ ///
+ protected override void BuildTargetModel(ModelBuilder modelBuilder)
+ {
+#pragma warning disable 612, 618
+ modelBuilder
+ .HasAnnotation("ProductVersion", "7.0.3")
+ .HasAnnotation("Relational:MaxIdentifierLength", 128);
+
+ SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder);
+
+ modelBuilder.Entity("EkzamenDatabaseImplement.Group", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("int");
+
+ SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"));
+
+ b.Property("Created")
+ .HasColumnType("datetime2");
+
+ b.Property("Direction")
+ .IsRequired()
+ .HasColumnType("nvarchar(max)");
+
+ b.Property("Name")
+ .IsRequired()
+ .HasColumnType("nvarchar(max)");
+
+ b.HasKey("Id");
+
+ b.ToTable("Groups");
+ });
+
+ modelBuilder.Entity("EkzamenDatabaseImplement.Student", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("int");
+
+ SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"));
+
+ b.Property("DateEnrollment")
+ .HasColumnType("datetime2");
+
+ b.Property("GroupId")
+ .HasColumnType("int");
+
+ b.Property("PassMark")
+ .HasColumnType("int");
+
+ b.Property("RecordBookId")
+ .HasColumnType("int");
+
+ b.Property("fio")
+ .IsRequired()
+ .HasColumnType("nvarchar(max)");
+
+ b.HasKey("Id");
+
+ b.HasIndex("GroupId");
+
+ b.ToTable("Students");
+ });
+
+ modelBuilder.Entity("EkzamenDatabaseImplement.Student", b =>
+ {
+ b.HasOne("EkzamenDatabaseImplement.Group", "Group")
+ .WithMany("Students")
+ .HasForeignKey("GroupId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
+ b.Navigation("Group");
+ });
+
+ modelBuilder.Entity("EkzamenDatabaseImplement.Group", b =>
+ {
+ b.Navigation("Students");
+ });
+#pragma warning restore 612, 618
+ }
+ }
+}
diff --git a/ConfectioneryDatabaseImplement/Migrations/20240202070935_Init.cs b/ConfectioneryDatabaseImplement/Migrations/20240202070935_Init.cs
new file mode 100644
index 0000000..6b10080
--- /dev/null
+++ b/ConfectioneryDatabaseImplement/Migrations/20240202070935_Init.cs
@@ -0,0 +1,68 @@
+using System;
+using Microsoft.EntityFrameworkCore.Migrations;
+
+#nullable disable
+
+namespace EkzamenDatabaseImplement.Migrations
+{
+ ///
+ public partial class Init : Migration
+ {
+ ///
+ protected override void Up(MigrationBuilder migrationBuilder)
+ {
+ migrationBuilder.CreateTable(
+ name: "Groups",
+ columns: table => new
+ {
+ Id = table.Column(type: "int", nullable: false)
+ .Annotation("SqlServer:Identity", "1, 1"),
+ Name = table.Column(type: "nvarchar(max)", nullable: false),
+ Direction = table.Column(type: "nvarchar(max)", nullable: false),
+ Created = table.Column(type: "datetime2", nullable: false)
+ },
+ constraints: table =>
+ {
+ table.PrimaryKey("PK_Groups", x => x.Id);
+ });
+
+ migrationBuilder.CreateTable(
+ name: "Students",
+ columns: table => new
+ {
+ Id = table.Column(type: "int", nullable: false)
+ .Annotation("SqlServer:Identity", "1, 1"),
+ fio = table.Column(type: "nvarchar(max)", nullable: false),
+ GroupId = table.Column(type: "int", nullable: false),
+ RecordBookId = table.Column(type: "int", nullable: false),
+ PassMark = table.Column(type: "int", nullable: false),
+ DateEnrollment = table.Column(type: "datetime2", nullable: false)
+ },
+ constraints: table =>
+ {
+ table.PrimaryKey("PK_Students", x => x.Id);
+ table.ForeignKey(
+ name: "FK_Students_Groups_GroupId",
+ column: x => x.GroupId,
+ principalTable: "Groups",
+ principalColumn: "Id",
+ onDelete: ReferentialAction.Cascade);
+ });
+
+ migrationBuilder.CreateIndex(
+ name: "IX_Students_GroupId",
+ table: "Students",
+ column: "GroupId");
+ }
+
+ ///
+ protected override void Down(MigrationBuilder migrationBuilder)
+ {
+ migrationBuilder.DropTable(
+ name: "Students");
+
+ migrationBuilder.DropTable(
+ name: "Groups");
+ }
+ }
+}
diff --git a/ConfectioneryDatabaseImplement/Migrations/ConfectioneryDatabaseModelSnapshot.cs b/ConfectioneryDatabaseImplement/Migrations/ConfectioneryDatabaseModelSnapshot.cs
index a67eb4a..ae07478 100644
--- a/ConfectioneryDatabaseImplement/Migrations/ConfectioneryDatabaseModelSnapshot.cs
+++ b/ConfectioneryDatabaseImplement/Migrations/ConfectioneryDatabaseModelSnapshot.cs
@@ -1,6 +1,6 @@
//
using System;
-using ConfectioneryDatabaseImplement;
+using EkzamenDatabaseImplement;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Metadata;
@@ -8,7 +8,7 @@ using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
#nullable disable
-namespace ConfectioneryDatabaseImplement.Migrations
+namespace EkzamenDatabaseImplement.Migrations
{
[DbContext(typeof(ConfectioneryDatabase))]
partial class ConfectioneryDatabaseModelSnapshot : ModelSnapshot
@@ -22,7 +22,7 @@ namespace ConfectioneryDatabaseImplement.Migrations
SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder);
- modelBuilder.Entity("ConfectioneryDatabaseImplement.Models.Component", b =>
+ modelBuilder.Entity("EkzamenDatabaseImplement.Group", b =>
{
b.Property("Id")
.ValueGeneratedOnAdd()
@@ -30,72 +30,23 @@ namespace ConfectioneryDatabaseImplement.Migrations
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"));
- b.Property("ComponentName")
+ b.Property("Created")
+ .HasColumnType("datetime2");
+
+ b.Property("Direction")
.IsRequired()
.HasColumnType("nvarchar(max)");
- b.Property("Cost")
- .HasColumnType("float");
-
- b.HasKey("Id");
-
- b.ToTable("Components");
- });
-
- modelBuilder.Entity("ConfectioneryDatabaseImplement.Models.Order", b =>
- {
- b.Property("Id")
- .ValueGeneratedOnAdd()
- .HasColumnType("int");
-
- SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"));
-
- b.Property("Count")
- .HasColumnType("int");
-
- b.Property("DateCreate")
- .HasColumnType("datetime2");
-
- b.Property("DateImplement")
- .HasColumnType("datetime2");
-
- b.Property("PastryId")
- .HasColumnType("int");
-
- b.Property("Status")
- .HasColumnType("int");
-
- b.Property("Sum")
- .HasColumnType("float");
-
- b.HasKey("Id");
-
- b.HasIndex("PastryId");
-
- b.ToTable("Orders");
- });
-
- modelBuilder.Entity("ConfectioneryDatabaseImplement.Models.Pastry", b =>
- {
- b.Property("Id")
- .ValueGeneratedOnAdd()
- .HasColumnType("int");
-
- SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"));
-
- b.Property("PastryName")
+ b.Property("Name")
.IsRequired()
.HasColumnType("nvarchar(max)");
- b.Property("Price")
- .HasColumnType("float");
-
b.HasKey("Id");
- b.ToTable("Pastries");
+ b.ToTable("Groups");
});
- modelBuilder.Entity("ConfectioneryDatabaseImplement.Models.PastryComponent", b =>
+ modelBuilder.Entity("EkzamenDatabaseImplement.Student", b =>
{
b.Property("Id")
.ValueGeneratedOnAdd()
@@ -103,64 +54,43 @@ namespace ConfectioneryDatabaseImplement.Migrations
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"));
- b.Property("ComponentId")
+ b.Property("DateEnrollment")
+ .HasColumnType("datetime2");
+
+ b.Property("GroupId")
.HasColumnType("int");
- b.Property("Count")
+ b.Property("PassMark")
.HasColumnType("int");
- b.Property("PastryId")
+ b.Property("RecordBookId")
.HasColumnType("int");
+ b.Property("fio")
+ .IsRequired()
+ .HasColumnType("nvarchar(max)");
+
b.HasKey("Id");
- b.HasIndex("ComponentId");
+ b.HasIndex("GroupId");
- b.HasIndex("PastryId");
-
- b.ToTable("PastryComponents");
+ b.ToTable("Students");
});
- modelBuilder.Entity("ConfectioneryDatabaseImplement.Models.Order", b =>
+ modelBuilder.Entity("EkzamenDatabaseImplement.Student", b =>
{
- b.HasOne("ConfectioneryDatabaseImplement.Models.Pastry", "Pastry")
- .WithMany("Orders")
- .HasForeignKey("PastryId")
+ b.HasOne("EkzamenDatabaseImplement.Group", "Group")
+ .WithMany("Students")
+ .HasForeignKey("GroupId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
- b.Navigation("Pastry");
+ b.Navigation("Group");
});
- modelBuilder.Entity("ConfectioneryDatabaseImplement.Models.PastryComponent", b =>
+ modelBuilder.Entity("EkzamenDatabaseImplement.Group", b =>
{
- b.HasOne("ConfectioneryDatabaseImplement.Models.Component", "Component")
- .WithMany("PastryComponents")
- .HasForeignKey("ComponentId")
- .OnDelete(DeleteBehavior.Cascade)
- .IsRequired();
-
- b.HasOne("ConfectioneryDatabaseImplement.Models.Pastry", "Pastry")
- .WithMany("Components")
- .HasForeignKey("PastryId")
- .OnDelete(DeleteBehavior.Cascade)
- .IsRequired();
-
- b.Navigation("Component");
-
- b.Navigation("Pastry");
- });
-
- modelBuilder.Entity("ConfectioneryDatabaseImplement.Models.Component", b =>
- {
- b.Navigation("PastryComponents");
- });
-
- modelBuilder.Entity("ConfectioneryDatabaseImplement.Models.Pastry", b =>
- {
- b.Navigation("Components");
-
- b.Navigation("Orders");
+ b.Navigation("Students");
});
#pragma warning restore 612, 618
}
diff --git a/ConfectioneryDatabaseImplement/Order.cs b/ConfectioneryDatabaseImplement/Order.cs
deleted file mode 100644
index 59cbfb0..0000000
--- a/ConfectioneryDatabaseImplement/Order.cs
+++ /dev/null
@@ -1,91 +0,0 @@
-using ConfectioneryContracts.BindingModels;
-using ConfectioneryContracts.ViewModels;
-using ConfectioneryDataModels.Enums;
-using ConfectioneryDataModels.Models;
-using Microsoft.EntityFrameworkCore;
-using System;
-using System.Collections.Generic;
-using System.ComponentModel.DataAnnotations;
-using System.ComponentModel.DataAnnotations.Schema;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-using System.Xml.Linq;
-
-namespace ConfectioneryDatabaseImplement.Models
-{
- public class Order : IOrderModel
- {
- public int Id { get; private set; }
-
- [Required]
- public int PastryId { get; private set; }
-
- [Required]
- public int Count { get; private set; }
-
- [Required]
- public double Sum { get; private set; }
-
- [Required]
- public OrderStatus Status { get; private set; }
-
- [Required]
- public DateTime DateCreate { get; private set; }
-
- public DateTime? DateImplement { get; private set; }
-
- public Pastry Pastry { get; private set; }
-
- public static Order? Create(OrderBindingModel? model)
- {
- if (model == null)
- {
- return null;
- }
- return new Order()
- {
- PastryId = model.PastryId,
- Count = model.Count,
- Sum = model.Sum,
- Status = model.Status,
- DateCreate = model.DateCreate,
- DateImplement = model.DateImplement,
- Id = model.Id,
- };
- }
-
- public void Update(OrderBindingModel? model)
- {
- if (model == null)
- {
- return;
- }
- PastryId = model.PastryId;
- Count = model.Count;
- Sum = model.Sum;
- Status = model.Status;
- DateCreate = model.DateCreate;
- DateImplement = model.DateImplement;
- Id = model.Id;
- }
- public OrderViewModel GetViewModel
- {
- get
- {
- var context = new ConfectioneryDatabase();
- return new()
- {
- PastryName = context.Pastries.FirstOrDefault(x => x.Id == PastryId)?.PastryName ?? string.Empty,
- PastryId = PastryId,
- Count = Count,
- Sum = Sum,
- Status = Status,
- DateCreate = DateCreate,
- DateImplement = DateImplement,
- Id = Id,
- };
- }
- }
- }
-}
diff --git a/ConfectioneryDatabaseImplement/Pastry.cs b/ConfectioneryDatabaseImplement/Pastry.cs
deleted file mode 100644
index 8f69a58..0000000
--- a/ConfectioneryDatabaseImplement/Pastry.cs
+++ /dev/null
@@ -1,103 +0,0 @@
-using ConfectioneryDataModels.Models;
-using System;
-using System.Collections.Generic;
-using System.ComponentModel.DataAnnotations.Schema;
-using System.ComponentModel.DataAnnotations;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-using ConfectioneryContracts.BindingModels;
-using ConfectioneryContracts.ViewModels;
-
-namespace ConfectioneryDatabaseImplement.Models
-{
- public class Pastry : IPastryModel
- {
- public int Id { get; set; }
- [Required]
- public string PastryName { get; set; } = string.Empty;
- [Required]
- public double Price { get; set; }
- private Dictionary? _pastryComponents = null;
-
- [NotMapped]
- public Dictionary PastryComponents
- {
- get
- {
- if (_pastryComponents == null)
- {
- _pastryComponents = Components
- .ToDictionary(recPC => recPC.ComponentId, recPC =>
- (recPC.Component as IComponentModel, recPC.Count));
- }
- return _pastryComponents;
- }
- }
-
- [ForeignKey("PastryId")]
- public virtual List Components { get; set; } = new();
- [ForeignKey("PastryId")]
- public virtual List Orders { get; set; } = new();
-
- public static Pastry Create(ConfectioneryDatabase context, PastryBindingModel model)
- {
- return new Pastry()
- {
- Id = model.Id,
- PastryName = model.PastryName,
- Price = model.Price,
- Components = model.PastryComponents.Select(x => new PastryComponent
- {
- Component = context.Components.First(y => y.Id == x.Key),
- Count = x.Value.Item2
- }).ToList()
- };
- }
- public void Update(PastryBindingModel model)
- {
- PastryName = model.PastryName;
- Price = model.Price;
- }
- public PastryViewModel GetViewModel => new()
- {
- Id = Id,
- PastryName = PastryName,
- Price = Price,
- PastryComponents = PastryComponents
- };
- public void UpdateComponents(ConfectioneryDatabase context, PastryBindingModel model)
- {
- var pastryComponents = context.PastryComponents
- .Where(rec => rec.PastryId == model.Id)
- .ToList();
- if (pastryComponents != null && pastryComponents.Count > 0)
- { // удалили те, которых нет в модели
- context.PastryComponents
- .RemoveRange(pastryComponents
- .Where(rec => !model.PastryComponents
- .ContainsKey(rec.ComponentId)));
- context.SaveChanges();
- // обновили количество у существующих записей
- foreach (var updateComponent in pastryComponents.Where(x => model.PastryComponents.ContainsKey(x.ComponentId)))
- {
- updateComponent.Count = model.PastryComponents[updateComponent.ComponentId].Item2;
- model.PastryComponents.Remove(updateComponent.ComponentId);
- }
- context.SaveChanges();
- }
- var pastry = context.Pastries.First(x => x.Id == Id);
- foreach (var pc in model.PastryComponents)
- {
- context.PastryComponents.Add(new PastryComponent
- {
- Pastry = pastry,
- Component = context.Components.First(x => x.Id == pc.Key),
- Count = pc.Value.Item2
- });
- context.SaveChanges();
- }
- _pastryComponents = null;
- }
- }
-}
diff --git a/ConfectioneryDatabaseImplement/PastryComponent.cs b/ConfectioneryDatabaseImplement/PastryComponent.cs
deleted file mode 100644
index d7ca43d..0000000
--- a/ConfectioneryDatabaseImplement/PastryComponent.cs
+++ /dev/null
@@ -1,18 +0,0 @@
-using System.ComponentModel.DataAnnotations;
-
-namespace ConfectioneryDatabaseImplement.Models
-{
- public class PastryComponent
- {
- public int Id { get; set; }
- [Required]
- public int PastryId { get; set; }
- [Required]
- public int ComponentId { get; set; }
- [Required]
- public int Count { get; set; }
-
- public virtual Component Component { get; set; } = new();
- public virtual Pastry Pastry { get; set; } = new();
- }
-}
diff --git a/ConfectioneryDatabaseImplement/PastryStorage.cs b/ConfectioneryDatabaseImplement/PastryStorage.cs
deleted file mode 100644
index b5a60b0..0000000
--- a/ConfectioneryDatabaseImplement/PastryStorage.cs
+++ /dev/null
@@ -1,104 +0,0 @@
-using ConfectioneryContracts.BindingModels;
-using ConfectioneryContracts.SearchModels;
-using ConfectioneryContracts.StoragesContract;
-using ConfectioneryContracts.ViewModels;
-using ConfectioneryDatabaseImplement;
-using ConfectioneryDatabaseImplement.Models;
-using Microsoft.EntityFrameworkCore;
-
-namespace ConfectioneryDatabaseImplement.Implements
-{
- public class PastryStorage : IPastryStorage
- {
- public PastryViewModel? Delete(PastryBindingModel model)
- {
- using var context = new ConfectioneryDatabase();
- var element = context.Pastries.FirstOrDefault(x => x.Id == model.Id);
- if (element != null)
- {
- context.Pastries.Remove(element);
- context.SaveChanges();
- return element.GetViewModel;
- }
- return null;
- }
-
- public PastryViewModel? GetElement(PastrySearchModel model)
- {
- if (string.IsNullOrEmpty(model.PastryName) && !model.Id.HasValue)
- {
- return null;
- }
- using var context = new ConfectioneryDatabase();
- return context.Pastries
- .Include(x => x.Components)
- .ThenInclude(x => x.Component)
- .FirstOrDefault
- (x => (!string.IsNullOrEmpty(model.PastryName) && x.PastryName == model.PastryName) ||
- (model.Id.HasValue && x.Id == model.Id)
- )?.GetViewModel;
- }
-
- public List GetFilteredList(PastrySearchModel model)
- {
- if (string.IsNullOrEmpty(model.PastryName))
- {
- return new();
- }
- using var context = new ConfectioneryDatabase();
- return context.Pastries
- .Include(x => x.Components)
- .ThenInclude(x => x.Component)
- .Select(x => x.GetViewModel)
- .Where(x => x.PastryName.Contains(model.PastryName))
- .ToList();
- }
-
- public List GetFullList()
- {
- using var context = new ConfectioneryDatabase();
- return context.Pastries
- .Include(x => x.Components)
- .ThenInclude(x => x.Component)
- .Select(x => x.GetViewModel)
- .ToList();
- }
-
- public PastryViewModel? Insert(PastryBindingModel model)
- {
- using var context = new ConfectioneryDatabase();
- var newPastry = Pastry.Create(context, model);
- if (newPastry == null)
- {
- return null;
- }
- context.Pastries.Add(newPastry);
- context.SaveChanges();
- return newPastry.GetViewModel;
- }
-
- public PastryViewModel? Update(PastryBindingModel model)
- {
- using var context = new ConfectioneryDatabase();
- using var transaction = context.Database.BeginTransaction();
- try
- {
- var pastry = context.Pastries.FirstOrDefault(x => x.Id == model.Id);
- if (pastry == null)
- {
- return null;
- }
- pastry.Update(model);
- context.SaveChanges();
- pastry.UpdateComponents(context, model);
- transaction.Commit();
- return pastry.GetViewModel;
- }
- catch
- {
- transaction.Rollback();
- throw;
- }
- }
- }
-}
diff --git a/ConfectioneryDatabaseImplement/Student.cs b/ConfectioneryDatabaseImplement/Student.cs
new file mode 100644
index 0000000..9362c79
--- /dev/null
+++ b/ConfectioneryDatabaseImplement/Student.cs
@@ -0,0 +1,57 @@
+using System.ComponentModel.DataAnnotations;
+using System.ComponentModel.DataAnnotations.Schema;
+using System.Text.RegularExpressions;
+using EkzamenContracts.BindingModels;
+using EkzamenContracts.ViewModels;
+using EkzamenDataModels;
+
+namespace EkzamenDatabaseImplement
+{
+ public class Student : IStudentModel
+ {
+ public int Id { get; private set; }
+
+ public static Student? Create(StudentBindingModel model)
+ {
+ if (model == null)
+ {
+ return null;
+ }
+ return new Student()
+ {
+ Id = model.Id,
+ fio = model.fio,
+ DateEnrollment = model.DateEnrollment,
+ GroupId = model.GroupId,
+ PassMark = model.PassMark,
+ RecordBookId = model.RecordBookId,
+ };
+ }
+ public void Update(StudentBindingModel model)
+ {
+ if (model == null)
+ {
+ return;
+ }
+ fio = model.fio;
+
+ }
+ public StudentViewModel GetViewModel => new()
+ {
+ Id = Id,
+ fio = fio,
+ DateEnrollment = DateEnrollment,
+ GroupId = GroupId,
+ PassMark = PassMark,
+ RecordBookId = RecordBookId,
+ };
+
+ public string fio { get; set; }
+ public int GroupId { get; set; }
+ public int RecordBookId { get; set; }
+ public int PassMark { get; set; }
+ public DateTime DateEnrollment { get; set; }
+
+ public Group Group { get; set; }
+ }
+}
diff --git a/ConfectioneryDatabaseImplement/StudentStorage.cs b/ConfectioneryDatabaseImplement/StudentStorage.cs
new file mode 100644
index 0000000..0430563
--- /dev/null
+++ b/ConfectioneryDatabaseImplement/StudentStorage.cs
@@ -0,0 +1,77 @@
+using EkzamenContracts.BindingModels;
+using EkzamenContracts.SearchModels;
+using EkzamenContracts.StoragesContract;
+using EkzamenContracts.ViewModels;
+
+namespace EkzamenDatabaseImplement
+{
+ public class StudentStorage : IStudentStorage
+ {
+ public List GetFullList()
+ {
+ using var context = new ConfectioneryDatabase();
+ return context.Students
+ .Select(x => x.GetViewModel)
+ .ToList();
+ }
+ public List GetFilteredList(StudentSearchModel model)
+ {
+ if (model.CreatedDateFrom is null || model.CreatedDateTo is null)
+ {
+ return new();
+ }
+ using var context = new ConfectioneryDatabase();
+ return context.Students
+ .Where(x => model.CreatedDateFrom <= x.DateEnrollment && x.DateEnrollment <= model.CreatedDateTo)
+ .Select(x => x.GetViewModel)
+ .ToList();
+ }
+ public StudentViewModel? GetElement(StudentSearchModel model)
+ {
+ if (!model.Id.HasValue)
+ {
+ return null;
+ }
+ using var context = new ConfectioneryDatabase();
+ return context.Students
+ .FirstOrDefault(x => model.Id.HasValue && x.Id == model.Id)
+ ?.GetViewModel;
+ }
+ public StudentViewModel? Insert(StudentBindingModel model)
+ {
+ var newComponent = Student.Create(model);
+ if (newComponent == null)
+ {
+ return null;
+ }
+ using var context = new ConfectioneryDatabase();
+ context.Students.Add(newComponent);
+ context.SaveChanges();
+ return newComponent.GetViewModel;
+ }
+ public StudentViewModel? Update(StudentBindingModel model)
+ {
+ using var context = new ConfectioneryDatabase();
+ var component = context.Students.FirstOrDefault(x => x.Id == model.Id);
+ if (component == null)
+ {
+ return null;
+ }
+ component.Update(model);
+ context.SaveChanges();
+ return component.GetViewModel;
+ }
+ public StudentViewModel? Delete(StudentBindingModel model)
+ {
+ using var context = new ConfectioneryDatabase();
+ var element = context.Students.FirstOrDefault(rec => rec.Id == model.Id);
+ if (element != null)
+ {
+ context.Students.Remove(element);
+ context.SaveChanges();
+ return element.GetViewModel;
+ }
+ return null;
+ }
+ }
+}
diff --git a/Confectionery.sln b/Ekzamen.sln
similarity index 62%
rename from Confectionery.sln
rename to Ekzamen.sln
index cb0512c..6d8ce2e 100644
--- a/Confectionery.sln
+++ b/Ekzamen.sln
@@ -3,19 +3,17 @@ Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.4.33103.184
MinimumVisualStudioVersion = 10.0.40219.1
-Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ConfectioneryView", "Confectionery\ConfectioneryView.csproj", "{4C293123-3570-4E76-A241-E28EB1498585}"
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "EkzamenView", "Confectionery\EkzamenView.csproj", "{4C293123-3570-4E76-A241-E28EB1498585}"
EndProject
-Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ConfectioneryDataModels", "ConfectioneryDataModels\ConfectioneryDataModels.csproj", "{C5FCA6F0-A6D0-47CB-B507-4A6EAA89E645}"
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "EkzamenDataModels", "ConfectioneryDataModels\EkzamenDataModels.csproj", "{C5FCA6F0-A6D0-47CB-B507-4A6EAA89E645}"
EndProject
-Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ConfectioneryContracts", "ConfectioneryContracts\ConfectioneryContracts.csproj", "{28EC043D-88E8-48DA-B5E8-2DE5659EB1BD}"
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "EkzamenContracts", "ConfectioneryContracts\EkzamenContracts.csproj", "{28EC043D-88E8-48DA-B5E8-2DE5659EB1BD}"
EndProject
-Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ConfectioneryBusinessLogic", "ConfectionaryBusinessLogic\ConfectioneryBusinessLogic.csproj", "{82EF78A8-98EC-490A-8D66-66909E5431E2}"
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "EkzamenBusinessLogic", "ConfectionaryBusinessLogic\EkzamenBusinessLogic.csproj", "{82EF78A8-98EC-490A-8D66-66909E5431E2}"
EndProject
-Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ConfectioneryListImplement", "ConfectionaryListImplement\ConfectioneryListImplement.csproj", "{0A7B118B-9B7C-4796-9846-66026159723E}"
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "EkzamenListImplement", "ConfectionaryListImplement\EkzamenListImplement.csproj", "{0A7B118B-9B7C-4796-9846-66026159723E}"
EndProject
-Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ConfectioneryFileImplement", "ConfectionaryFileImplement\ConfectioneryFileImplement.csproj", "{47A2EA59-4443-487E-85F4-AC49C04B7211}"
-EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ConfectioneryDatabaseImplement", "ConfectioneryDatabaseImplement\ConfectioneryDatabaseImplement.csproj", "{2BB59FBD-AA9F-4005-8B0B-6E5176EED6A1}"
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "EkzamenDatabaseImplement", "ConfectioneryDatabaseImplement\EkzamenDatabaseImplement.csproj", "{2BB59FBD-AA9F-4005-8B0B-6E5176EED6A1}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
@@ -43,10 +41,6 @@ Global
{0A7B118B-9B7C-4796-9846-66026159723E}.Debug|Any CPU.Build.0 = Debug|Any CPU
{0A7B118B-9B7C-4796-9846-66026159723E}.Release|Any CPU.ActiveCfg = Release|Any CPU
{0A7B118B-9B7C-4796-9846-66026159723E}.Release|Any CPU.Build.0 = Release|Any CPU
- {47A2EA59-4443-487E-85F4-AC49C04B7211}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {47A2EA59-4443-487E-85F4-AC49C04B7211}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {47A2EA59-4443-487E-85F4-AC49C04B7211}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {47A2EA59-4443-487E-85F4-AC49C04B7211}.Release|Any CPU.Build.0 = Release|Any CPU
{2BB59FBD-AA9F-4005-8B0B-6E5176EED6A1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{2BB59FBD-AA9F-4005-8B0B-6E5176EED6A1}.Debug|Any CPU.Build.0 = Debug|Any CPU
{2BB59FBD-AA9F-4005-8B0B-6E5176EED6A1}.Release|Any CPU.ActiveCfg = Release|Any CPU
diff --git a/ImplementationExtensions/ConfectioneryBusinessLogic.dll b/ImplementationExtensions/ConfectioneryBusinessLogic.dll
new file mode 100644
index 0000000..b55e9d4
Binary files /dev/null and b/ImplementationExtensions/ConfectioneryBusinessLogic.dll differ
diff --git a/ImplementationExtensions/ConfectioneryContracts.dll b/ImplementationExtensions/ConfectioneryContracts.dll
new file mode 100644
index 0000000..841540e
Binary files /dev/null and b/ImplementationExtensions/ConfectioneryContracts.dll differ
diff --git a/ImplementationExtensions/ConfectioneryDataModels.dll b/ImplementationExtensions/ConfectioneryDataModels.dll
new file mode 100644
index 0000000..967dcf5
Binary files /dev/null and b/ImplementationExtensions/ConfectioneryDataModels.dll differ
diff --git a/ImplementationExtensions/ConfectioneryDatabaseImplement.dll b/ImplementationExtensions/ConfectioneryDatabaseImplement.dll
new file mode 100644
index 0000000..71d2680
Binary files /dev/null and b/ImplementationExtensions/ConfectioneryDatabaseImplement.dll differ
diff --git a/ImplementationExtensions/ConfectioneryFileImplement.dll b/ImplementationExtensions/ConfectioneryFileImplement.dll
new file mode 100644
index 0000000..30e29d9
Binary files /dev/null and b/ImplementationExtensions/ConfectioneryFileImplement.dll differ
diff --git a/ImplementationExtensions/ConfectioneryListImplement.dll b/ImplementationExtensions/ConfectioneryListImplement.dll
new file mode 100644
index 0000000..4324887
Binary files /dev/null and b/ImplementationExtensions/ConfectioneryListImplement.dll differ