+рабочие формочки для продуктов и блюд
This commit is contained in:
parent
1fafc07394
commit
ebb55f4300
@ -13,9 +13,9 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DiningRoomDatabaseImplement
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DiningRoomBusinessLogic", "DiningRoomBusinessLogic\DiningRoomBusinessLogic.csproj", "{89A8AB71-ADD4-405D-AE0B-03ACB1A1BF24}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DiningRoomRestApi", "DiningRoomRestApi\DiningRoomRestApi.csproj", "{BE787325-AB78-45A0-AE64-62E46E64248E}"
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DiningRoomClientApp", "DiningRoomClientApp\DiningRoomClientApp.csproj", "{543BA573-04E2-4CF1-8848-19B8EFE56EE1}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DiningRoomClientApp", "DiningRoomClientApp\DiningRoomClientApp.csproj", "{ACC2241A-F9C7-482B-839A-B7D625136145}"
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DiningRoomRestApi", "DiningRoomRestApi\DiningRoomRestApi.csproj", "{75B8E90E-E98D-4B04-9EF1-BBDAC55F1936}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
@ -43,14 +43,14 @@ Global
|
||||
{89A8AB71-ADD4-405D-AE0B-03ACB1A1BF24}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{89A8AB71-ADD4-405D-AE0B-03ACB1A1BF24}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{89A8AB71-ADD4-405D-AE0B-03ACB1A1BF24}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{BE787325-AB78-45A0-AE64-62E46E64248E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{BE787325-AB78-45A0-AE64-62E46E64248E}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{BE787325-AB78-45A0-AE64-62E46E64248E}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{BE787325-AB78-45A0-AE64-62E46E64248E}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{ACC2241A-F9C7-482B-839A-B7D625136145}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{ACC2241A-F9C7-482B-839A-B7D625136145}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{ACC2241A-F9C7-482B-839A-B7D625136145}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{ACC2241A-F9C7-482B-839A-B7D625136145}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{543BA573-04E2-4CF1-8848-19B8EFE56EE1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{543BA573-04E2-4CF1-8848-19B8EFE56EE1}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{543BA573-04E2-4CF1-8848-19B8EFE56EE1}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{543BA573-04E2-4CF1-8848-19B8EFE56EE1}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{75B8E90E-E98D-4B04-9EF1-BBDAC55F1936}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{75B8E90E-E98D-4B04-9EF1-BBDAC55F1936}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{75B8E90E-E98D-4B04-9EF1-BBDAC55F1936}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{75B8E90E-E98D-4B04-9EF1-BBDAC55F1936}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
|
@ -11,7 +11,7 @@ using System.Reflection;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace DiningRoomBusinessLogic.BusinessLogics
|
||||
namespace DiningRoomBusinessLogic.BusinessLogic
|
||||
{
|
||||
public class CardLogic : ICardLogic
|
||||
{
|
||||
@ -25,8 +25,8 @@ namespace DiningRoomBusinessLogic.BusinessLogics
|
||||
|
||||
public List<CardViewModel>? ReadList(CardSearchModel? model)
|
||||
{
|
||||
//model.UserId = -1 для swagger, чтобы можно было считать все заявки всех пользователей
|
||||
var list = (model == null || model.UserId == -1) ? _CardStorage.GetFullList() : _CardStorage.GetFilteredList(model);
|
||||
|
||||
var list = (model == null) ? _CardStorage.GetFullList() : _CardStorage.GetFilteredList(model);
|
||||
if (list == null)
|
||||
{
|
||||
_logger.LogWarning("ReadList Cards return null list");
|
@ -6,7 +6,7 @@ using DiningRoomContracts.ViewModels;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
|
||||
namespace DiningRoomBusinessLogic.BusinessLogics
|
||||
namespace DiningRoomBusinessLogic.BusinessLogic
|
||||
{
|
||||
public class ComponentLogic : IComponentLogic
|
||||
{
|
@ -6,7 +6,7 @@ using DiningRoomContracts.ViewModels;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
|
||||
namespace DiningRoomBusinessLogic.BusinessLogics
|
||||
namespace DiningRoomBusinessLogic.BusinessLogic
|
||||
{
|
||||
public class DrinkLogic : IDrinkLogic
|
||||
{
|
||||
@ -104,10 +104,5 @@ namespace DiningRoomBusinessLogic.BusinessLogics
|
||||
throw new InvalidOperationException("Напиток с таким названием уже есть");
|
||||
}
|
||||
}
|
||||
public bool ConnectCardDrink(DrinkBindingModel model)
|
||||
{
|
||||
_logger.LogInformation("Connect Card {rId} with drink {aId}", model.Id, model.CardId);
|
||||
return _DrinkStorage.ConnectCardDrink(model);
|
||||
}
|
||||
}
|
||||
}
|
@ -11,7 +11,7 @@ using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace DiningRoomBusinessLogic.BusinessLogics
|
||||
namespace DiningRoomBusinessLogic.BusinessLogic
|
||||
{
|
||||
public class OrderLogic : IOrderLogic
|
||||
{
|
||||
@ -28,7 +28,7 @@ namespace DiningRoomBusinessLogic.BusinessLogics
|
||||
public List<OrderViewModel>? ReadList(OrderSearchModel? model)
|
||||
{
|
||||
|
||||
var list = (model == null || model.UserId == -1) ? _orderStorage.GetFullList() : _orderStorage.GetFilteredList(model);
|
||||
var list = (model == null) ? _orderStorage.GetFullList() : _orderStorage.GetFilteredList(model);
|
||||
if (list == null)
|
||||
{
|
||||
_logger.LogWarning("ReadList return null list");
|
@ -6,7 +6,7 @@ using DiningRoomContracts.ViewModels;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
|
||||
namespace DiningRoomBusinessLogic.BusinessLogics
|
||||
namespace DiningRoomBusinessLogic.BusinessLogic
|
||||
{
|
||||
public class ProductLogic : IProductLogic
|
||||
{
|
@ -4,7 +4,7 @@ using DiningRoomContracts.SearchModels;
|
||||
using DiningRoomContracts.StorageContracts;
|
||||
using DiningRoomContracts.ViewModels;
|
||||
|
||||
namespace DiningRoomBusinessLogic.BusinessLogics
|
||||
namespace DiningRoomBusinessLogic.BusinessLogic
|
||||
{
|
||||
public class ReportLogic : IReportLogic
|
||||
{
|
||||
@ -26,9 +26,9 @@ namespace DiningRoomBusinessLogic.BusinessLogics
|
||||
/// <summary>
|
||||
/// Получение отчёта для отправки на почту
|
||||
/// </summary>
|
||||
public List<ReportComponentByDateViewModel> GetReportComponentsByCardDate(UserSearchModel CurrentUser, ReportBindingModel Report)
|
||||
public List<ReportComponentByDateViewModel> GetReportComponentsByCardDate(ReportBindingModel Report)
|
||||
{
|
||||
return _componentStorage.GetComponentsByDate(Report, CurrentUser);
|
||||
return _componentStorage.GetComponentsByDate(Report);
|
||||
}
|
||||
|
||||
public void SaveReportToWordFile(ReportBindingModel Model)
|
@ -10,7 +10,7 @@ using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace DiningRoomBusinessLogic.BusinessLogics
|
||||
namespace DiningRoomBusinessLogic.BusinessLogic
|
||||
{
|
||||
public class UserLogic : IUserLogic
|
||||
{
|
@ -11,8 +11,6 @@ namespace DiningRoomContracts.BindingModels
|
||||
public class CardBindingModel : ICardModel
|
||||
{
|
||||
public int Id { get; set; }
|
||||
|
||||
public int UserId { get; set; }
|
||||
public int? DrinkId { get; set; }
|
||||
public string CardName { get; set; } = string.Empty;
|
||||
public DateTime DateCardCreate { get; set; } = DateTime.Now;
|
||||
|
@ -1,4 +1,5 @@
|
||||
using DiningRoomDataModels.Models;
|
||||
using DiningRoomDataModels.Enums;
|
||||
using DiningRoomDataModels.Models;
|
||||
|
||||
namespace DiningRoomContracts.BindingModels
|
||||
{
|
||||
@ -6,10 +7,8 @@ namespace DiningRoomContracts.BindingModels
|
||||
{
|
||||
public int Id { get; set; }
|
||||
|
||||
public int UserId { get; set; }
|
||||
|
||||
public string ComponentName { get; set; } = string.Empty;
|
||||
public string Unit { get; set; } = string.Empty;
|
||||
public ComponentUnit Unit { get; set; } = ComponentUnit.Неизвестна;
|
||||
public double Cost { get; set; }
|
||||
}
|
||||
}
|
||||
|
@ -6,9 +6,6 @@ namespace DiningRoomContracts.BindingModels
|
||||
{
|
||||
public int Id { get; set; }
|
||||
|
||||
public int UserId { get; set; }
|
||||
public int CardId { get; set; }
|
||||
|
||||
public string DrinkName { get; set; } = string.Empty;
|
||||
|
||||
public double Cost { get; set; }
|
||||
|
@ -11,7 +11,6 @@ namespace DiningRoomContracts.BindingModels
|
||||
public class OrderBindingModel : IOrderModel
|
||||
{
|
||||
public int Id { get; set; }
|
||||
public int UserId { get; set; }
|
||||
public int ProductId { get; set; }
|
||||
public string ProductName { get; set; } = string.Empty;
|
||||
public DateTime DateCreate { get; set; } = DateTime.Now;
|
||||
|
@ -6,9 +6,6 @@ namespace DiningRoomContracts.BindingModels
|
||||
{
|
||||
public int Id { get; set; }
|
||||
|
||||
public int UserId { get; set; }
|
||||
public int? OrderId { get; set; }
|
||||
|
||||
public string ProductName { get; set; } = string.Empty;
|
||||
|
||||
public double Cost { get; set; }
|
||||
|
@ -15,6 +15,5 @@ namespace DiningRoomContracts.BusinessLogicContracts
|
||||
bool Update(DrinkBindingModel Model);
|
||||
|
||||
bool Delete(DrinkBindingModel Model);
|
||||
bool ConnectCardDrink(DrinkBindingModel model);
|
||||
}
|
||||
}
|
||||
|
@ -14,7 +14,7 @@ namespace DiningRoomContracts.BusinessLogicContracts
|
||||
/// <summary>
|
||||
/// Получение отчёта для отправки на почту
|
||||
/// </summary>
|
||||
List<ReportComponentByDateViewModel> GetReportComponentsByCardDate(UserSearchModel CurrentUser, ReportBindingModel Report);
|
||||
List<ReportComponentByDateViewModel> GetReportComponentsByCardDate(ReportBindingModel Report);
|
||||
|
||||
void SaveReportToWordFile(ReportBindingModel Model);
|
||||
|
||||
|
@ -4,7 +4,6 @@
|
||||
{
|
||||
public int? Id { get; set; }
|
||||
|
||||
public int? UserId { get; set; }
|
||||
public DateTime? DateCardCreate { get; set; }
|
||||
public DateTime? DateFrom { get; set; }
|
||||
public DateTime? DateTo { get; set; }
|
||||
|
@ -3,8 +3,6 @@
|
||||
public class ComponentSearchModel
|
||||
{
|
||||
public int? Id { get; set; }
|
||||
|
||||
public int? UserId { get; set; }
|
||||
public string ComponentName { get; set; }
|
||||
}
|
||||
}
|
||||
|
@ -4,7 +4,6 @@
|
||||
{
|
||||
public int? Id { get; set; }
|
||||
|
||||
public int? UserId { get; set; }
|
||||
public int? CardId { get; set; }
|
||||
|
||||
public string? DrinkName { get; set; }
|
||||
|
@ -11,7 +11,6 @@ namespace DiningRoomContracts.SearchModels
|
||||
public class OrderSearchModel
|
||||
{
|
||||
public int? Id { get; set; }
|
||||
public int? UserId { get; set; }
|
||||
|
||||
public DateTime? DateFrom { get; set; }
|
||||
public DateTime? DateTo { get; set; }
|
||||
|
@ -4,9 +4,6 @@
|
||||
{
|
||||
public int? Id { get; set; }
|
||||
|
||||
public int? UserId { get; set; }
|
||||
public int? OrderId { get; set; }
|
||||
|
||||
public string? ProductName { get; set; }
|
||||
}
|
||||
}
|
||||
|
@ -19,6 +19,6 @@ namespace DiningRoomContracts.StorageContracts
|
||||
ComponentViewModel? Delete(ComponentBindingModel Model);
|
||||
List<ReportComponentOrderViewModel> GetComponentsOrders(List<ComponentSearchModel> Models);
|
||||
|
||||
List<ReportComponentByDateViewModel> GetComponentsByDate(ReportBindingModel ReportModel, UserSearchModel UserModel);
|
||||
List<ReportComponentByDateViewModel> GetComponentsByDate(ReportBindingModel ReportModel);
|
||||
}
|
||||
}
|
||||
|
@ -17,6 +17,5 @@ namespace DiningRoomContracts.StorageContracts
|
||||
DrinkViewModel? Update(DrinkBindingModel Model);
|
||||
|
||||
DrinkViewModel? Delete(DrinkBindingModel Model);
|
||||
bool ConnectCardDrink(DrinkBindingModel model);
|
||||
}
|
||||
}
|
||||
|
@ -7,8 +7,6 @@ namespace DiningRoomContracts.ViewModels
|
||||
{
|
||||
public int Id { get; set; }
|
||||
|
||||
public int UserId { get; set; }
|
||||
|
||||
|
||||
[DisplayName("Название карты")]
|
||||
public string CardName { get; set; } = string.Empty;
|
||||
|
@ -1,4 +1,5 @@
|
||||
using DiningRoomDataModels.Models;
|
||||
using DiningRoomDataModels.Enums;
|
||||
using DiningRoomDataModels.Models;
|
||||
using System.ComponentModel;
|
||||
|
||||
namespace DiningRoomContracts.ViewModels
|
||||
@ -7,13 +8,11 @@ namespace DiningRoomContracts.ViewModels
|
||||
{
|
||||
public int Id { get; set; }
|
||||
|
||||
public int UserId { get; set; }
|
||||
|
||||
|
||||
[DisplayName("Название продукта")]
|
||||
public string ComponentName { get; set; } = string.Empty;
|
||||
[DisplayName("Единица измерения")]
|
||||
public string Unit { get; set; } = string.Empty;
|
||||
public ComponentUnit Unit { get; set; } = ComponentUnit.Неизвестна;
|
||||
|
||||
[DisplayName("Стоимость")]
|
||||
public double Cost { get; set; }
|
||||
|
@ -6,9 +6,6 @@ namespace DiningRoomContracts.ViewModels
|
||||
public class DrinkViewModel : IDrinkModel
|
||||
{
|
||||
public int Id { get; set; }
|
||||
|
||||
public int UserId { get; set; }
|
||||
public int CardId { get; set; }
|
||||
public string CardName { get; set; } = string.Empty;
|
||||
|
||||
[DisplayName("Название товара")]
|
||||
|
@ -14,7 +14,6 @@ namespace DiningRoomContracts.ViewModels
|
||||
[DisplayName("Номер")]
|
||||
public int Id { get; set; }
|
||||
public int ProductId { get; set; }
|
||||
public int UserId { get; set; }
|
||||
[DisplayName("Дата Создания")]
|
||||
public DateTime DateCreate { get; set; } = DateTime.Now;
|
||||
[DisplayName("Блюдо")]
|
||||
|
@ -7,9 +7,6 @@ namespace DiningRoomContracts.ViewModels
|
||||
{
|
||||
public int Id { get; set; }
|
||||
|
||||
public int UserId { get; set; }
|
||||
public int? OrderId { get; set; }
|
||||
|
||||
[DisplayName("Название товара")]
|
||||
public string ProductName { get; set; } = string.Empty;
|
||||
|
||||
|
9
DiningRoom/DiningRoomDataModels/Enums/ComponentUnit.cs
Normal file
9
DiningRoom/DiningRoomDataModels/Enums/ComponentUnit.cs
Normal file
@ -0,0 +1,9 @@
|
||||
namespace DiningRoomDataModels.Enums
|
||||
{
|
||||
public enum ComponentUnit
|
||||
{
|
||||
Неизвестна = -1,
|
||||
Граммы = 0,
|
||||
Миллилитры = 1,
|
||||
}
|
||||
}
|
@ -5,10 +5,6 @@
|
||||
/// </summary>
|
||||
public interface ICardModel : IId
|
||||
{
|
||||
/// <summary>
|
||||
/// Пользователь, который добавил карту
|
||||
/// </summary>
|
||||
int UserId { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Название карты
|
||||
|
@ -1,15 +1,12 @@
|
||||
namespace DiningRoomDataModels.Models
|
||||
using DiningRoomDataModels.Enums;
|
||||
|
||||
namespace DiningRoomDataModels.Models
|
||||
{
|
||||
/// <summary>
|
||||
/// Продукт
|
||||
/// </summary>
|
||||
public interface IComponentModel : IId
|
||||
{
|
||||
/// <summary>
|
||||
/// Пользователь, который добавил продукт
|
||||
/// </summary>
|
||||
int UserId { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Название продукта
|
||||
/// </summary>
|
||||
@ -17,7 +14,7 @@
|
||||
/// <summary>
|
||||
/// Единица измерения
|
||||
/// </summary>
|
||||
string Unit { get; }
|
||||
ComponentUnit Unit { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Цена продукта
|
||||
|
@ -5,10 +5,6 @@
|
||||
/// </summary>
|
||||
public interface IDrinkModel : IId
|
||||
{
|
||||
/// <summary>
|
||||
/// Пользователь, который добавил напиток
|
||||
/// </summary>
|
||||
int UserId { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Название напитка
|
||||
@ -19,7 +15,6 @@
|
||||
/// Стоимость товара
|
||||
/// </summary>
|
||||
double Cost { get; }
|
||||
int CardId { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Список продуктов
|
||||
|
@ -9,8 +9,6 @@ namespace DiningRoomDataModels.Models
|
||||
{
|
||||
public interface IOrderModel : IId
|
||||
{
|
||||
//ID пользователя, который создал заказ
|
||||
int UserId { get; }
|
||||
/// <summary>
|
||||
/// Дата создания заказа
|
||||
/// </summary>
|
||||
|
@ -5,10 +5,6 @@
|
||||
/// </summary>
|
||||
public interface IProductModel : IId
|
||||
{
|
||||
/// <summary>
|
||||
/// Пользователь, который добавил блюдо
|
||||
/// </summary>
|
||||
int UserId { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Название блюда
|
||||
|
@ -32,14 +32,14 @@ namespace DiningRoomDatabaseImplement.Implements
|
||||
if (model.DateFrom.HasValue && model.DateTo.HasValue)
|
||||
{
|
||||
return context.Cards
|
||||
.Where(x => (x.UserId == model.UserId) && (x.DateCardCreate >= model.DateFrom && x.DateCardCreate <= model.DateTo))
|
||||
.Where(x => (x.DateCardCreate >= model.DateFrom && x.DateCardCreate <= model.DateTo))
|
||||
.Include(x => x.Drinks)
|
||||
.Select(x => x.GetViewModel)
|
||||
.ToList();
|
||||
}
|
||||
//возвращение просто всех заявок пользователя (замена GetFullList)
|
||||
return context.Cards
|
||||
.Where(x => x.UserId == model.UserId)
|
||||
.Where(x => x.Id == model.Id)
|
||||
.Include(x => x.Drinks)
|
||||
.Select(x => x.GetViewModel)
|
||||
.ToList();
|
||||
|
@ -114,12 +114,12 @@ namespace DiningRoomDatabaseImplement.Implements
|
||||
.ToList();
|
||||
}
|
||||
|
||||
public List<ReportComponentByDateViewModel> GetComponentsByDate(ReportBindingModel ReportModel, UserSearchModel UserModel)
|
||||
public List<ReportComponentByDateViewModel> GetComponentsByDate(ReportBindingModel ReportModel)
|
||||
{
|
||||
using var Context = new DiningRoomDatabase();
|
||||
|
||||
return Context.Cards
|
||||
.Where(card => card.UserId == UserModel.Id && card.DateCardCreate >= ReportModel.DateFrom && card.DateCardCreate <= ReportModel.DateTo)
|
||||
.Where(card => card.DateCardCreate >= ReportModel.DateFrom && card.DateCardCreate <= ReportModel.DateTo)
|
||||
.Include(card => card.Drinks)
|
||||
.ThenInclude(d => d.Components)
|
||||
.ThenInclude(dc => dc.Component)
|
||||
|
@ -102,18 +102,5 @@ namespace DiningRoomDatabaseImplement.Implements
|
||||
}
|
||||
return null;
|
||||
}
|
||||
public bool ConnectCardDrink(DrinkBindingModel model)
|
||||
{
|
||||
using var context = new DiningRoomDatabase();
|
||||
var Card = context.Cards.FirstOrDefault(x => x.Id == model.Id);
|
||||
var Drink = context.Drinks.FirstOrDefault(x => x.Id == model.CardId);
|
||||
if (Card == null || Drink == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
Drink.ConnectDrink(context, model);
|
||||
context.SaveChanges();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
@ -55,7 +55,7 @@ namespace DiningRoomDatabaseImplement.Implements
|
||||
if (model.DateFrom.HasValue && model.DateTo.HasValue)
|
||||
{
|
||||
return context.Orders
|
||||
.Where(x => (x.UserId == model.UserId) && (x.DateCreate >= model.DateFrom && x.DateCreate <= model.DateTo))
|
||||
.Where(x =>(x.DateCreate >= model.DateFrom && x.DateCreate <= model.DateTo))
|
||||
.Include(x => x.Product)
|
||||
.ToList()
|
||||
.Select(x => x.GetViewModel)
|
||||
@ -65,7 +65,7 @@ namespace DiningRoomDatabaseImplement.Implements
|
||||
else if (model.Status.HasValue)
|
||||
{
|
||||
return context.Orders
|
||||
.Where(x => (x.UserId == model.UserId) && (x.Status == model.Status))
|
||||
.Where(x => (x.Status == model.Status))
|
||||
.Include(x => x.Product)
|
||||
.ToList()
|
||||
.Select(x => x.GetViewModel)
|
||||
@ -73,7 +73,7 @@ namespace DiningRoomDatabaseImplement.Implements
|
||||
}
|
||||
|
||||
return context.Orders
|
||||
.Where(x => x.UserId == model.UserId)
|
||||
.Where(x => x.Id == model.Id)
|
||||
.Include(x => x.Product)
|
||||
.ToList()
|
||||
.Select(x => x.GetViewModel)
|
||||
|
@ -24,24 +24,12 @@ namespace DiningRoomDatabaseImplement.Implements
|
||||
public List<ProductViewModel> GetFilteredList(ProductSearchModel model)
|
||||
{
|
||||
using var context = new DiningRoomDatabase();
|
||||
|
||||
// Optional search by order
|
||||
if (model.OrderId.HasValue)
|
||||
{
|
||||
return context.Products
|
||||
.Include(x => x.Order)
|
||||
.Include(x => x.Components)
|
||||
.ThenInclude(x => x.Component)
|
||||
.Where(x => x.UserId == model.UserId)
|
||||
.Select(x => x.GetViewModel)
|
||||
.ToList();
|
||||
}
|
||||
|
||||
return context.Products
|
||||
.Include(x => x.Order)
|
||||
.Include(x => x.Components)
|
||||
.ThenInclude(x => x.Component)
|
||||
.Where(x => x.UserId == model.UserId)
|
||||
.Where(x => x.Id == model.Id)
|
||||
.Select(x => x.GetViewModel)
|
||||
.ToList();
|
||||
}
|
||||
|
@ -12,7 +12,7 @@ using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
|
||||
namespace DiningRoomDatabaseImplement.Migrations
|
||||
{
|
||||
[DbContext(typeof(DiningRoomDatabase))]
|
||||
[Migration("20240504170055_InitialCreate")]
|
||||
[Migration("20240525184442_InitialCreate")]
|
||||
partial class InitialCreate
|
||||
{
|
||||
/// <inheritdoc />
|
||||
@ -20,11 +20,26 @@ namespace DiningRoomDatabaseImplement.Migrations
|
||||
{
|
||||
#pragma warning disable 612, 618
|
||||
modelBuilder
|
||||
.HasAnnotation("ProductVersion", "7.0.18")
|
||||
.HasAnnotation("DrinkVersion", "7.0.18")
|
||||
.HasAnnotation("Relational:MaxIdentifierLength", 63);
|
||||
|
||||
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
|
||||
|
||||
modelBuilder.Entity("CardDrink", b =>
|
||||
{
|
||||
b.Property<int>("CardId")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<int>("DrinkId")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.HasKey("CardId", "DrinkId");
|
||||
|
||||
b.HasIndex("DrinkId");
|
||||
|
||||
b.ToTable("CardDrink");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("DiningRoomDatabaseImplement.Models.Card", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
@ -40,7 +55,7 @@ namespace DiningRoomDatabaseImplement.Migrations
|
||||
b.Property<DateTime>("DateCardCreate")
|
||||
.HasColumnType("timestamp without time zone");
|
||||
|
||||
b.Property<int>("UserId")
|
||||
b.Property<int?>("UserId")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.HasKey("Id");
|
||||
@ -65,11 +80,10 @@ namespace DiningRoomDatabaseImplement.Migrations
|
||||
b.Property<double>("Cost")
|
||||
.HasColumnType("double precision");
|
||||
|
||||
b.Property<string>("Unit")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
b.Property<int>("Unit")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<int>("UserId")
|
||||
b.Property<int?>("UserId")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.HasKey("Id");
|
||||
@ -87,9 +101,6 @@ namespace DiningRoomDatabaseImplement.Migrations
|
||||
|
||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<int>("CardId")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<double>("Cost")
|
||||
.HasColumnType("double precision");
|
||||
|
||||
@ -97,13 +108,11 @@ namespace DiningRoomDatabaseImplement.Migrations
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<int>("UserId")
|
||||
b.Property<int?>("UserId")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("CardId");
|
||||
|
||||
b.HasIndex("UserId");
|
||||
|
||||
b.ToTable("Drinks");
|
||||
@ -130,6 +139,8 @@ namespace DiningRoomDatabaseImplement.Migrations
|
||||
|
||||
b.HasIndex("ComponentId");
|
||||
|
||||
b.HasIndex("DrinkId");
|
||||
|
||||
b.ToTable("DrinkComponents");
|
||||
});
|
||||
|
||||
@ -147,10 +158,10 @@ namespace DiningRoomDatabaseImplement.Migrations
|
||||
b.Property<DateTime>("DateCreate")
|
||||
.HasColumnType("timestamp without time zone");
|
||||
|
||||
b.Property<int>("ProductId")
|
||||
b.Property<int>("DrinkId")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<string>("ProductName")
|
||||
b.Property<string>("DrinkName")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
@ -160,19 +171,19 @@ namespace DiningRoomDatabaseImplement.Migrations
|
||||
b.Property<double>("Sum")
|
||||
.HasColumnType("double precision");
|
||||
|
||||
b.Property<int>("UserId")
|
||||
b.Property<int?>("UserId")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("ProductId");
|
||||
b.HasIndex("DrinkId");
|
||||
|
||||
b.HasIndex("UserId");
|
||||
|
||||
b.ToTable("Orders");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("DiningRoomDatabaseImplement.Models.Product", b =>
|
||||
modelBuilder.Entity("DiningRoomDatabaseImplement.Models.Drink", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
@ -183,21 +194,21 @@ namespace DiningRoomDatabaseImplement.Migrations
|
||||
b.Property<double>("Cost")
|
||||
.HasColumnType("double precision");
|
||||
|
||||
b.Property<string>("ProductName")
|
||||
b.Property<string>("DrinkName")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<int>("UserId")
|
||||
b.Property<int?>("UserId")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("UserId");
|
||||
|
||||
b.ToTable("Products");
|
||||
b.ToTable("Drinks");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("DiningRoomDatabaseImplement.Models.ProductComponent", b =>
|
||||
modelBuilder.Entity("DiningRoomDatabaseImplement.Models.DrinkComponent", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
@ -211,16 +222,16 @@ namespace DiningRoomDatabaseImplement.Migrations
|
||||
b.Property<int>("Count")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<int>("ProductId")
|
||||
b.Property<int>("DrinkId")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("ComponentId");
|
||||
|
||||
b.HasIndex("ProductId");
|
||||
b.HasIndex("DrinkId");
|
||||
|
||||
b.ToTable("ProductComponents");
|
||||
b.ToTable("DrinkComponents");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("DiningRoomDatabaseImplement.Models.User", b =>
|
||||
@ -248,39 +259,40 @@ namespace DiningRoomDatabaseImplement.Migrations
|
||||
b.ToTable("Users");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("CardDrink", b =>
|
||||
{
|
||||
b.HasOne("DiningRoomDatabaseImplement.Models.Card", null)
|
||||
.WithMany()
|
||||
.HasForeignKey("CardId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("DiningRoomDatabaseImplement.Models.Drink", null)
|
||||
.WithMany()
|
||||
.HasForeignKey("DrinkId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
});
|
||||
|
||||
modelBuilder.Entity("DiningRoomDatabaseImplement.Models.Card", b =>
|
||||
{
|
||||
b.HasOne("DiningRoomDatabaseImplement.Models.User", null)
|
||||
.WithMany("Cards")
|
||||
.HasForeignKey("UserId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
.HasForeignKey("UserId");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("DiningRoomDatabaseImplement.Models.Component", b =>
|
||||
{
|
||||
b.HasOne("DiningRoomDatabaseImplement.Models.User", null)
|
||||
.WithMany("Components")
|
||||
.HasForeignKey("UserId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
.HasForeignKey("UserId");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("DiningRoomDatabaseImplement.Models.Drink", b =>
|
||||
{
|
||||
b.HasOne("DiningRoomDatabaseImplement.Models.Card", "Card")
|
||||
.WithMany("Drinks")
|
||||
.HasForeignKey("CardId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("DiningRoomDatabaseImplement.Models.User", null)
|
||||
.WithMany("Drinks")
|
||||
.HasForeignKey("UserId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Card");
|
||||
.HasForeignKey("UserId");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("DiningRoomDatabaseImplement.Models.DrinkComponent", b =>
|
||||
@ -293,7 +305,7 @@ namespace DiningRoomDatabaseImplement.Migrations
|
||||
|
||||
b.HasOne("DiningRoomDatabaseImplement.Models.Drink", "Drink")
|
||||
.WithMany("Components")
|
||||
.HasForeignKey("ComponentId")
|
||||
.HasForeignKey("DrinkId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
@ -304,59 +316,50 @@ namespace DiningRoomDatabaseImplement.Migrations
|
||||
|
||||
modelBuilder.Entity("DiningRoomDatabaseImplement.Models.Order", b =>
|
||||
{
|
||||
b.HasOne("DiningRoomDatabaseImplement.Models.Product", "Product")
|
||||
b.HasOne("DiningRoomDatabaseImplement.Models.Drink", "Drink")
|
||||
.WithMany("Order")
|
||||
.HasForeignKey("ProductId")
|
||||
.HasForeignKey("DrinkId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("DiningRoomDatabaseImplement.Models.User", null)
|
||||
.WithMany("Orders")
|
||||
.HasForeignKey("UserId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
.HasForeignKey("UserId");
|
||||
|
||||
b.Navigation("Product");
|
||||
b.Navigation("Drink");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("DiningRoomDatabaseImplement.Models.Product", b =>
|
||||
modelBuilder.Entity("DiningRoomDatabaseImplement.Models.Drink", b =>
|
||||
{
|
||||
b.HasOne("DiningRoomDatabaseImplement.Models.User", null)
|
||||
.WithMany("Products")
|
||||
.HasForeignKey("UserId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
.WithMany("Drinks")
|
||||
.HasForeignKey("UserId");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("DiningRoomDatabaseImplement.Models.ProductComponent", b =>
|
||||
modelBuilder.Entity("DiningRoomDatabaseImplement.Models.DrinkComponent", b =>
|
||||
{
|
||||
b.HasOne("DiningRoomDatabaseImplement.Models.Component", "Component")
|
||||
.WithMany("ProductComponents")
|
||||
.WithMany("DrinkComponents")
|
||||
.HasForeignKey("ComponentId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("DiningRoomDatabaseImplement.Models.Product", "Product")
|
||||
b.HasOne("DiningRoomDatabaseImplement.Models.Drink", "Drink")
|
||||
.WithMany("Components")
|
||||
.HasForeignKey("ProductId")
|
||||
.HasForeignKey("DrinkId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Component");
|
||||
|
||||
b.Navigation("Product");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("DiningRoomDatabaseImplement.Models.Card", b =>
|
||||
{
|
||||
b.Navigation("Drinks");
|
||||
b.Navigation("Drink");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("DiningRoomDatabaseImplement.Models.Component", b =>
|
||||
{
|
||||
b.Navigation("DrinkComponents");
|
||||
|
||||
b.Navigation("ProductComponents");
|
||||
b.Navigation("DrinkComponents");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("DiningRoomDatabaseImplement.Models.Drink", b =>
|
||||
@ -364,7 +367,7 @@ namespace DiningRoomDatabaseImplement.Migrations
|
||||
b.Navigation("Components");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("DiningRoomDatabaseImplement.Models.Product", b =>
|
||||
modelBuilder.Entity("DiningRoomDatabaseImplement.Models.Drink", b =>
|
||||
{
|
||||
b.Navigation("Components");
|
||||
|
||||
@ -381,7 +384,7 @@ namespace DiningRoomDatabaseImplement.Migrations
|
||||
|
||||
b.Navigation("Orders");
|
||||
|
||||
b.Navigation("Products");
|
||||
b.Navigation("Drinks");
|
||||
});
|
||||
#pragma warning restore 612, 618
|
||||
}
|
@ -33,9 +33,9 @@ namespace DiningRoomDatabaseImplement.Migrations
|
||||
{
|
||||
Id = table.Column<int>(type: "integer", nullable: false)
|
||||
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
||||
UserId = table.Column<int>(type: "integer", nullable: false),
|
||||
CardName = table.Column<string>(type: "text", nullable: false),
|
||||
DateCardCreate = table.Column<DateTime>(type: "timestamp without time zone", nullable: false)
|
||||
DateCardCreate = table.Column<DateTime>(type: "timestamp without time zone", nullable: false),
|
||||
UserId = table.Column<int>(type: "integer", nullable: true)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
@ -44,8 +44,7 @@ namespace DiningRoomDatabaseImplement.Migrations
|
||||
name: "FK_Cards_Users_UserId",
|
||||
column: x => x.UserId,
|
||||
principalTable: "Users",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
principalColumn: "Id");
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
@ -54,10 +53,10 @@ namespace DiningRoomDatabaseImplement.Migrations
|
||||
{
|
||||
Id = table.Column<int>(type: "integer", nullable: false)
|
||||
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
||||
UserId = table.Column<int>(type: "integer", nullable: false),
|
||||
ComponentName = table.Column<string>(type: "text", nullable: false),
|
||||
Unit = table.Column<string>(type: "text", nullable: false),
|
||||
Cost = table.Column<double>(type: "double precision", nullable: false)
|
||||
Unit = table.Column<int>(type: "integer", nullable: false),
|
||||
Cost = table.Column<double>(type: "double precision", nullable: false),
|
||||
UserId = table.Column<int>(type: "integer", nullable: true)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
@ -66,29 +65,7 @@ namespace DiningRoomDatabaseImplement.Migrations
|
||||
name: "FK_Components_Users_UserId",
|
||||
column: x => x.UserId,
|
||||
principalTable: "Users",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "Products",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(type: "integer", nullable: false)
|
||||
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
||||
UserId = table.Column<int>(type: "integer", nullable: false),
|
||||
ProductName = table.Column<string>(type: "text", nullable: false),
|
||||
Cost = table.Column<double>(type: "double precision", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_Products", x => x.Id);
|
||||
table.ForeignKey(
|
||||
name: "FK_Products_Users_UserId",
|
||||
column: x => x.UserId,
|
||||
principalTable: "Users",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
principalColumn: "Id");
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
@ -97,82 +74,60 @@ namespace DiningRoomDatabaseImplement.Migrations
|
||||
{
|
||||
Id = table.Column<int>(type: "integer", nullable: false)
|
||||
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
||||
UserId = table.Column<int>(type: "integer", nullable: false),
|
||||
DrinkName = table.Column<string>(type: "text", nullable: false),
|
||||
Cost = table.Column<double>(type: "double precision", nullable: false),
|
||||
CardId = table.Column<int>(type: "integer", nullable: false)
|
||||
UserId = table.Column<int>(type: "integer", nullable: true)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_Drinks", x => x.Id);
|
||||
table.ForeignKey(
|
||||
name: "FK_Drinks_Cards_CardId",
|
||||
name: "FK_Drinks_Users_UserId",
|
||||
column: x => x.UserId,
|
||||
principalTable: "Users",
|
||||
principalColumn: "Id");
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "Drinks",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(type: "integer", nullable: false)
|
||||
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
||||
DrinkName = table.Column<string>(type: "text", nullable: false),
|
||||
Cost = table.Column<double>(type: "double precision", nullable: false),
|
||||
UserId = table.Column<int>(type: "integer", nullable: true)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_Drinks", x => x.Id);
|
||||
table.ForeignKey(
|
||||
name: "FK_Drinks_Users_UserId",
|
||||
column: x => x.UserId,
|
||||
principalTable: "Users",
|
||||
principalColumn: "Id");
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "CardDrink",
|
||||
columns: table => new
|
||||
{
|
||||
CardId = table.Column<int>(type: "integer", nullable: false),
|
||||
DrinkId = table.Column<int>(type: "integer", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_CardDrink", x => new { x.CardId, x.DrinkId });
|
||||
table.ForeignKey(
|
||||
name: "FK_CardDrink_Cards_CardId",
|
||||
column: x => x.CardId,
|
||||
principalTable: "Cards",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
table.ForeignKey(
|
||||
name: "FK_Drinks_Users_UserId",
|
||||
column: x => x.UserId,
|
||||
principalTable: "Users",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "Orders",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(type: "integer", nullable: false)
|
||||
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
||||
ProductId = table.Column<int>(type: "integer", nullable: false),
|
||||
ProductName = table.Column<string>(type: "text", nullable: false),
|
||||
Count = table.Column<int>(type: "integer", nullable: false),
|
||||
Sum = table.Column<double>(type: "double precision", nullable: false),
|
||||
Status = table.Column<int>(type: "integer", nullable: false),
|
||||
DateCreate = table.Column<DateTime>(type: "timestamp without time zone", nullable: false),
|
||||
UserId = table.Column<int>(type: "integer", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_Orders", x => x.Id);
|
||||
table.ForeignKey(
|
||||
name: "FK_Orders_Products_ProductId",
|
||||
column: x => x.ProductId,
|
||||
principalTable: "Products",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
table.ForeignKey(
|
||||
name: "FK_Orders_Users_UserId",
|
||||
column: x => x.UserId,
|
||||
principalTable: "Users",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "ProductComponents",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(type: "integer", nullable: false)
|
||||
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
||||
ProductId = table.Column<int>(type: "integer", nullable: false),
|
||||
ComponentId = table.Column<int>(type: "integer", nullable: false),
|
||||
Count = table.Column<int>(type: "integer", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_ProductComponents", x => x.Id);
|
||||
table.ForeignKey(
|
||||
name: "FK_ProductComponents_Components_ComponentId",
|
||||
column: x => x.ComponentId,
|
||||
principalTable: "Components",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
table.ForeignKey(
|
||||
name: "FK_ProductComponents_Products_ProductId",
|
||||
column: x => x.ProductId,
|
||||
principalTable: "Products",
|
||||
name: "FK_CardDrink_Drinks_DrinkId",
|
||||
column: x => x.DrinkId,
|
||||
principalTable: "Drinks",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
});
|
||||
@ -197,13 +152,75 @@ namespace DiningRoomDatabaseImplement.Migrations
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
table.ForeignKey(
|
||||
name: "FK_DrinkComponents_Drinks_ComponentId",
|
||||
column: x => x.ComponentId,
|
||||
name: "FK_DrinkComponents_Drinks_DrinkId",
|
||||
column: x => x.DrinkId,
|
||||
principalTable: "Drinks",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "Orders",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(type: "integer", nullable: false)
|
||||
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
||||
DrinkId = table.Column<int>(type: "integer", nullable: false),
|
||||
DrinkName = table.Column<string>(type: "text", nullable: false),
|
||||
Count = table.Column<int>(type: "integer", nullable: false),
|
||||
Sum = table.Column<double>(type: "double precision", nullable: false),
|
||||
Status = table.Column<int>(type: "integer", nullable: false),
|
||||
DateCreate = table.Column<DateTime>(type: "timestamp without time zone", nullable: false),
|
||||
UserId = table.Column<int>(type: "integer", nullable: true)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_Orders", x => x.Id);
|
||||
table.ForeignKey(
|
||||
name: "FK_Orders_Drinks_DrinkId",
|
||||
column: x => x.DrinkId,
|
||||
principalTable: "Drinks",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
table.ForeignKey(
|
||||
name: "FK_Orders_Users_UserId",
|
||||
column: x => x.UserId,
|
||||
principalTable: "Users",
|
||||
principalColumn: "Id");
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "DrinkComponents",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(type: "integer", nullable: false)
|
||||
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
||||
DrinkId = table.Column<int>(type: "integer", nullable: false),
|
||||
ComponentId = table.Column<int>(type: "integer", nullable: false),
|
||||
Count = table.Column<int>(type: "integer", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_DrinkComponents", x => x.Id);
|
||||
table.ForeignKey(
|
||||
name: "FK_DrinkComponents_Components_ComponentId",
|
||||
column: x => x.ComponentId,
|
||||
principalTable: "Components",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
table.ForeignKey(
|
||||
name: "FK_DrinkComponents_Drinks_DrinkId",
|
||||
column: x => x.DrinkId,
|
||||
principalTable: "Drinks",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_CardDrink_DrinkId",
|
||||
table: "CardDrink",
|
||||
column: "DrinkId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_Cards_UserId",
|
||||
table: "Cards",
|
||||
@ -220,9 +237,9 @@ namespace DiningRoomDatabaseImplement.Migrations
|
||||
column: "ComponentId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_Drinks_CardId",
|
||||
table: "Drinks",
|
||||
column: "CardId");
|
||||
name: "IX_DrinkComponents_DrinkId",
|
||||
table: "DrinkComponents",
|
||||
column: "DrinkId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_Drinks_UserId",
|
||||
@ -230,9 +247,9 @@ namespace DiningRoomDatabaseImplement.Migrations
|
||||
column: "UserId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_Orders_ProductId",
|
||||
name: "IX_Orders_DrinkId",
|
||||
table: "Orders",
|
||||
column: "ProductId");
|
||||
column: "DrinkId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_Orders_UserId",
|
||||
@ -240,24 +257,27 @@ namespace DiningRoomDatabaseImplement.Migrations
|
||||
column: "UserId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_ProductComponents_ComponentId",
|
||||
table: "ProductComponents",
|
||||
name: "IX_DrinkComponents_ComponentId",
|
||||
table: "DrinkComponents",
|
||||
column: "ComponentId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_ProductComponents_ProductId",
|
||||
table: "ProductComponents",
|
||||
column: "ProductId");
|
||||
name: "IX_DrinkComponents_DrinkId",
|
||||
table: "DrinkComponents",
|
||||
column: "DrinkId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_Products_UserId",
|
||||
table: "Products",
|
||||
name: "IX_Drinks_UserId",
|
||||
table: "Drinks",
|
||||
column: "UserId");
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropTable(
|
||||
name: "CardDrink");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "DrinkComponents");
|
||||
|
||||
@ -265,7 +285,10 @@ namespace DiningRoomDatabaseImplement.Migrations
|
||||
name: "Orders");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "ProductComponents");
|
||||
name: "DrinkComponents");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "Cards");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "Drinks");
|
||||
@ -274,10 +297,7 @@ namespace DiningRoomDatabaseImplement.Migrations
|
||||
name: "Components");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "Products");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "Cards");
|
||||
name: "Drinks");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "Users");
|
@ -17,11 +17,26 @@ namespace DiningRoomDatabaseImplement.Migrations
|
||||
{
|
||||
#pragma warning disable 612, 618
|
||||
modelBuilder
|
||||
.HasAnnotation("ProductVersion", "7.0.18")
|
||||
.HasAnnotation("DrinkVersion", "7.0.18")
|
||||
.HasAnnotation("Relational:MaxIdentifierLength", 63);
|
||||
|
||||
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
|
||||
|
||||
modelBuilder.Entity("CardDrink", b =>
|
||||
{
|
||||
b.Property<int>("CardId")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<int>("DrinkId")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.HasKey("CardId", "DrinkId");
|
||||
|
||||
b.HasIndex("DrinkId");
|
||||
|
||||
b.ToTable("CardDrink");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("DiningRoomDatabaseImplement.Models.Card", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
@ -37,7 +52,7 @@ namespace DiningRoomDatabaseImplement.Migrations
|
||||
b.Property<DateTime>("DateCardCreate")
|
||||
.HasColumnType("timestamp without time zone");
|
||||
|
||||
b.Property<int>("UserId")
|
||||
b.Property<int?>("UserId")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.HasKey("Id");
|
||||
@ -62,11 +77,10 @@ namespace DiningRoomDatabaseImplement.Migrations
|
||||
b.Property<double>("Cost")
|
||||
.HasColumnType("double precision");
|
||||
|
||||
b.Property<string>("Unit")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
b.Property<int>("Unit")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<int>("UserId")
|
||||
b.Property<int?>("UserId")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.HasKey("Id");
|
||||
@ -84,9 +98,6 @@ namespace DiningRoomDatabaseImplement.Migrations
|
||||
|
||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<int>("CardId")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<double>("Cost")
|
||||
.HasColumnType("double precision");
|
||||
|
||||
@ -94,13 +105,11 @@ namespace DiningRoomDatabaseImplement.Migrations
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<int>("UserId")
|
||||
b.Property<int?>("UserId")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("CardId");
|
||||
|
||||
b.HasIndex("UserId");
|
||||
|
||||
b.ToTable("Drinks");
|
||||
@ -127,6 +136,8 @@ namespace DiningRoomDatabaseImplement.Migrations
|
||||
|
||||
b.HasIndex("ComponentId");
|
||||
|
||||
b.HasIndex("DrinkId");
|
||||
|
||||
b.ToTable("DrinkComponents");
|
||||
});
|
||||
|
||||
@ -144,10 +155,10 @@ namespace DiningRoomDatabaseImplement.Migrations
|
||||
b.Property<DateTime>("DateCreate")
|
||||
.HasColumnType("timestamp without time zone");
|
||||
|
||||
b.Property<int>("ProductId")
|
||||
b.Property<int>("DrinkId")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<string>("ProductName")
|
||||
b.Property<string>("DrinkName")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
@ -157,19 +168,19 @@ namespace DiningRoomDatabaseImplement.Migrations
|
||||
b.Property<double>("Sum")
|
||||
.HasColumnType("double precision");
|
||||
|
||||
b.Property<int>("UserId")
|
||||
b.Property<int?>("UserId")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("ProductId");
|
||||
b.HasIndex("DrinkId");
|
||||
|
||||
b.HasIndex("UserId");
|
||||
|
||||
b.ToTable("Orders");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("DiningRoomDatabaseImplement.Models.Product", b =>
|
||||
modelBuilder.Entity("DiningRoomDatabaseImplement.Models.Drink", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
@ -180,21 +191,21 @@ namespace DiningRoomDatabaseImplement.Migrations
|
||||
b.Property<double>("Cost")
|
||||
.HasColumnType("double precision");
|
||||
|
||||
b.Property<string>("ProductName")
|
||||
b.Property<string>("DrinkName")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<int>("UserId")
|
||||
b.Property<int?>("UserId")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("UserId");
|
||||
|
||||
b.ToTable("Products");
|
||||
b.ToTable("Drinks");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("DiningRoomDatabaseImplement.Models.ProductComponent", b =>
|
||||
modelBuilder.Entity("DiningRoomDatabaseImplement.Models.DrinkComponent", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
@ -208,16 +219,16 @@ namespace DiningRoomDatabaseImplement.Migrations
|
||||
b.Property<int>("Count")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<int>("ProductId")
|
||||
b.Property<int>("DrinkId")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("ComponentId");
|
||||
|
||||
b.HasIndex("ProductId");
|
||||
b.HasIndex("DrinkId");
|
||||
|
||||
b.ToTable("ProductComponents");
|
||||
b.ToTable("DrinkComponents");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("DiningRoomDatabaseImplement.Models.User", b =>
|
||||
@ -245,39 +256,40 @@ namespace DiningRoomDatabaseImplement.Migrations
|
||||
b.ToTable("Users");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("CardDrink", b =>
|
||||
{
|
||||
b.HasOne("DiningRoomDatabaseImplement.Models.Card", null)
|
||||
.WithMany()
|
||||
.HasForeignKey("CardId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("DiningRoomDatabaseImplement.Models.Drink", null)
|
||||
.WithMany()
|
||||
.HasForeignKey("DrinkId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
});
|
||||
|
||||
modelBuilder.Entity("DiningRoomDatabaseImplement.Models.Card", b =>
|
||||
{
|
||||
b.HasOne("DiningRoomDatabaseImplement.Models.User", null)
|
||||
.WithMany("Cards")
|
||||
.HasForeignKey("UserId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
.HasForeignKey("UserId");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("DiningRoomDatabaseImplement.Models.Component", b =>
|
||||
{
|
||||
b.HasOne("DiningRoomDatabaseImplement.Models.User", null)
|
||||
.WithMany("Components")
|
||||
.HasForeignKey("UserId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
.HasForeignKey("UserId");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("DiningRoomDatabaseImplement.Models.Drink", b =>
|
||||
{
|
||||
b.HasOne("DiningRoomDatabaseImplement.Models.Card", "Card")
|
||||
.WithMany("Drinks")
|
||||
.HasForeignKey("CardId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("DiningRoomDatabaseImplement.Models.User", null)
|
||||
.WithMany("Drinks")
|
||||
.HasForeignKey("UserId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Card");
|
||||
.HasForeignKey("UserId");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("DiningRoomDatabaseImplement.Models.DrinkComponent", b =>
|
||||
@ -290,7 +302,7 @@ namespace DiningRoomDatabaseImplement.Migrations
|
||||
|
||||
b.HasOne("DiningRoomDatabaseImplement.Models.Drink", "Drink")
|
||||
.WithMany("Components")
|
||||
.HasForeignKey("ComponentId")
|
||||
.HasForeignKey("DrinkId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
@ -301,59 +313,50 @@ namespace DiningRoomDatabaseImplement.Migrations
|
||||
|
||||
modelBuilder.Entity("DiningRoomDatabaseImplement.Models.Order", b =>
|
||||
{
|
||||
b.HasOne("DiningRoomDatabaseImplement.Models.Product", "Product")
|
||||
b.HasOne("DiningRoomDatabaseImplement.Models.Drink", "Drink")
|
||||
.WithMany("Order")
|
||||
.HasForeignKey("ProductId")
|
||||
.HasForeignKey("DrinkId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("DiningRoomDatabaseImplement.Models.User", null)
|
||||
.WithMany("Orders")
|
||||
.HasForeignKey("UserId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
.HasForeignKey("UserId");
|
||||
|
||||
b.Navigation("Product");
|
||||
b.Navigation("Drink");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("DiningRoomDatabaseImplement.Models.Product", b =>
|
||||
modelBuilder.Entity("DiningRoomDatabaseImplement.Models.Drink", b =>
|
||||
{
|
||||
b.HasOne("DiningRoomDatabaseImplement.Models.User", null)
|
||||
.WithMany("Products")
|
||||
.HasForeignKey("UserId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
.WithMany("Drinks")
|
||||
.HasForeignKey("UserId");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("DiningRoomDatabaseImplement.Models.ProductComponent", b =>
|
||||
modelBuilder.Entity("DiningRoomDatabaseImplement.Models.DrinkComponent", b =>
|
||||
{
|
||||
b.HasOne("DiningRoomDatabaseImplement.Models.Component", "Component")
|
||||
.WithMany("ProductComponents")
|
||||
.WithMany("DrinkComponents")
|
||||
.HasForeignKey("ComponentId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("DiningRoomDatabaseImplement.Models.Product", "Product")
|
||||
b.HasOne("DiningRoomDatabaseImplement.Models.Drink", "Drink")
|
||||
.WithMany("Components")
|
||||
.HasForeignKey("ProductId")
|
||||
.HasForeignKey("DrinkId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Component");
|
||||
|
||||
b.Navigation("Product");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("DiningRoomDatabaseImplement.Models.Card", b =>
|
||||
{
|
||||
b.Navigation("Drinks");
|
||||
b.Navigation("Drink");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("DiningRoomDatabaseImplement.Models.Component", b =>
|
||||
{
|
||||
b.Navigation("DrinkComponents");
|
||||
|
||||
b.Navigation("ProductComponents");
|
||||
b.Navigation("DrinkComponents");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("DiningRoomDatabaseImplement.Models.Drink", b =>
|
||||
@ -361,7 +364,7 @@ namespace DiningRoomDatabaseImplement.Migrations
|
||||
b.Navigation("Components");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("DiningRoomDatabaseImplement.Models.Product", b =>
|
||||
modelBuilder.Entity("DiningRoomDatabaseImplement.Models.Drink", b =>
|
||||
{
|
||||
b.Navigation("Components");
|
||||
|
||||
@ -378,7 +381,7 @@ namespace DiningRoomDatabaseImplement.Migrations
|
||||
|
||||
b.Navigation("Orders");
|
||||
|
||||
b.Navigation("Products");
|
||||
b.Navigation("Drinks");
|
||||
});
|
||||
#pragma warning restore 612, 618
|
||||
}
|
||||
|
@ -16,7 +16,6 @@ namespace DiningRoomDatabaseImplement.Models
|
||||
public class Card : ICardModel
|
||||
{
|
||||
public int Id { get; set; }
|
||||
public int UserId { get; set; }
|
||||
[Required]
|
||||
public string CardName { get; set; } = string.Empty;
|
||||
[Required]
|
||||
@ -29,7 +28,6 @@ namespace DiningRoomDatabaseImplement.Models
|
||||
{
|
||||
Id = model.Id,
|
||||
CardName = model.CardName,
|
||||
UserId = model.UserId,
|
||||
DateCardCreate = model.DateCardCreate,
|
||||
};
|
||||
}
|
||||
@ -41,7 +39,6 @@ namespace DiningRoomDatabaseImplement.Models
|
||||
{
|
||||
Id = Id,
|
||||
CardName = CardName,
|
||||
UserId = UserId,
|
||||
DateCardCreate = DateCardCreate,
|
||||
};
|
||||
|
||||
|
@ -1,5 +1,6 @@
|
||||
using DiningRoomContracts.BindingModels;
|
||||
using DiningRoomContracts.ViewModels;
|
||||
using DiningRoomDataModels.Enums;
|
||||
using DiningRoomDataModels.Models;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
@ -10,13 +11,10 @@ namespace DiningRoomDatabaseImplement.Models
|
||||
{
|
||||
public int Id { get; private set; }
|
||||
|
||||
[Required]
|
||||
public int UserId { get; private set; }
|
||||
|
||||
[Required]
|
||||
public string ComponentName { get; private set; } = string.Empty;
|
||||
[Required]
|
||||
public string Unit { get; private set; } = string.Empty;
|
||||
public ComponentUnit Unit { get; private set; } = ComponentUnit.Неизвестна;
|
||||
|
||||
[Required]
|
||||
public double Cost { get; private set; }
|
||||
@ -35,7 +33,6 @@ namespace DiningRoomDatabaseImplement.Models
|
||||
return new Component()
|
||||
{
|
||||
Id = Model.Id,
|
||||
UserId = Model.UserId,
|
||||
ComponentName = Model.ComponentName,
|
||||
Cost = Model.Cost,
|
||||
Unit = Model.Unit,
|
||||
@ -46,7 +43,6 @@ namespace DiningRoomDatabaseImplement.Models
|
||||
return new Component
|
||||
{
|
||||
Id = Model.Id,
|
||||
UserId = Model.UserId,
|
||||
ComponentName = Model.ComponentName,
|
||||
Cost = Model.Cost,
|
||||
Unit = Model.Unit,
|
||||
@ -66,7 +62,6 @@ namespace DiningRoomDatabaseImplement.Models
|
||||
public ComponentViewModel GetViewModel => new()
|
||||
{
|
||||
Id = Id,
|
||||
UserId = UserId,
|
||||
ComponentName = ComponentName,
|
||||
Cost = Cost,
|
||||
Unit = Unit,
|
||||
|
@ -12,20 +12,15 @@ namespace DiningRoomDatabaseImplement.Models
|
||||
{
|
||||
public int Id { get; private set; }
|
||||
|
||||
[Required]
|
||||
public int UserId { get; private set; }
|
||||
|
||||
[Required]
|
||||
public string DrinkName { get; private set; } = string.Empty;
|
||||
|
||||
[Required]
|
||||
public double Cost { get; private set; }
|
||||
[ForeignKey("DrinkId")]
|
||||
public virtual List<Card> Card { get; set; } = new();
|
||||
|
||||
public int CardId { get; private set; }
|
||||
public virtual Card? Card { get; set; } = new();
|
||||
|
||||
|
||||
[ForeignKey("ComponentId")]
|
||||
[ForeignKey("DrinkId")]
|
||||
public virtual List<DrinkComponent> Components { get; set; } = new();
|
||||
|
||||
private Dictionary<int, (IComponentModel, int)>? _drinkComponents;
|
||||
@ -52,10 +47,8 @@ namespace DiningRoomDatabaseImplement.Models
|
||||
return new()
|
||||
{
|
||||
Id = Model.Id,
|
||||
UserId = Model.UserId,
|
||||
DrinkName = Model.DrinkName,
|
||||
Cost = Model.Cost,
|
||||
CardId = Model.CardId,
|
||||
Components = Model.DrinkComponents.Select(x => new DrinkComponent
|
||||
{
|
||||
Component = Context.Components.First(y => y.Id == x.Key),
|
||||
@ -78,7 +71,6 @@ namespace DiningRoomDatabaseImplement.Models
|
||||
{
|
||||
Id = Id,
|
||||
DrinkName = DrinkName,
|
||||
CardName = context.Cards.FirstOrDefault(x => x.Id == CardId)?.CardName ?? string.Empty,
|
||||
Cost = Cost,
|
||||
DrinkComponents = DrinkComponents
|
||||
};
|
||||
@ -112,10 +104,5 @@ namespace DiningRoomDatabaseImplement.Models
|
||||
}
|
||||
_drinkComponents = null;
|
||||
}
|
||||
public void ConnectDrink(DiningRoomDatabase context, DrinkBindingModel model)
|
||||
{
|
||||
CardId = model.CardId;
|
||||
Card = context.Cards.First(x => x.Id == model.CardId);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -28,8 +28,7 @@ namespace DiningRoomDatabaseImplement.Models
|
||||
[Required]
|
||||
public DateTime DateCreate { get; set; }
|
||||
public virtual Product Product { get; set; }
|
||||
[Required]
|
||||
public int UserId { get; private set; }
|
||||
|
||||
|
||||
public static Order? Create(OrderBindingModel model)
|
||||
{
|
||||
@ -42,7 +41,6 @@ namespace DiningRoomDatabaseImplement.Models
|
||||
Id = model.Id,
|
||||
ProductId = model.ProductId,
|
||||
ProductName = model.ProductName,
|
||||
UserId = model.UserId,
|
||||
DateCreate = model.DateCreate,
|
||||
Status = model.Status,
|
||||
Count = model.Count,
|
||||
@ -71,7 +69,6 @@ namespace DiningRoomDatabaseImplement.Models
|
||||
Id = Id,
|
||||
ProductId = ProductId,
|
||||
ProductName = context.Products.FirstOrDefault(x => x.Id == ProductId)?.ProductName ?? string.Empty,
|
||||
UserId = UserId,
|
||||
DateCreate = DateCreate,
|
||||
Status = Status,
|
||||
Count = Count,
|
||||
|
@ -11,9 +11,6 @@ namespace DiningRoomDatabaseImplement.Models
|
||||
{
|
||||
public int Id { get; set; }
|
||||
|
||||
[Required]
|
||||
public int UserId { get; set; }
|
||||
|
||||
[Required]
|
||||
public string ProductName { get; set; } = string.Empty;
|
||||
|
||||
@ -46,7 +43,6 @@ namespace DiningRoomDatabaseImplement.Models
|
||||
return new()
|
||||
{
|
||||
Id = Model.Id,
|
||||
UserId = Model.UserId,
|
||||
ProductName = Model.ProductName,
|
||||
Cost = Model.Cost,
|
||||
Components = Model.ProductComponents.Select(x => new ProductComponent
|
||||
@ -64,7 +60,6 @@ namespace DiningRoomDatabaseImplement.Models
|
||||
public ProductViewModel GetViewModel => new()
|
||||
{
|
||||
Id = Id,
|
||||
UserId = UserId,
|
||||
ProductName = ProductName,
|
||||
Cost = Cost,
|
||||
ProductComponents = ProductComponents
|
||||
|
@ -39,20 +39,19 @@ namespace DiningRoomRestApi.Controllers
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Получение карт по id пользователя (полный список, кот. будет выводиться)
|
||||
/// Получение карт по id(полный список, кот. будет выводиться)
|
||||
/// </summary>
|
||||
/// <param name="userId"></param>
|
||||
/// <returns></returns>
|
||||
|
||||
[HttpGet]
|
||||
public List<CardViewModel>? GetCards(int userId)
|
||||
public List<CardViewModel>? GetCards(int Id)
|
||||
{
|
||||
try
|
||||
{
|
||||
return _logic.ReadList(new CardSearchModel { UserId = userId });
|
||||
return _logic.ReadList(new CardSearchModel { Id = Id });
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка получения списка заказов клиента id={Id}", userId);
|
||||
_logger.LogError(ex, "Ошибка получения списка заказов клиента id={Id}", Id);
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
@ -36,22 +36,6 @@ namespace DiningRoomRestApi.Controllers
|
||||
}
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public List<ComponentViewModel>? GetComponents(int? UserId)
|
||||
{
|
||||
try
|
||||
{
|
||||
return _componentLogic.ReadList(new ComponentSearchModel
|
||||
{
|
||||
UserId = UserId
|
||||
});
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка получения списка продуктов пользователя с Id = {Id}", UserId);
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public void CreateComponent(ComponentBindingModel Model)
|
||||
|
@ -36,35 +36,6 @@ namespace DiningRoomRestApi.Controllers
|
||||
}
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public List<DrinkViewModel>? GetDrinks(int? UserId)
|
||||
{
|
||||
try
|
||||
{
|
||||
return _DrinkLogic.ReadList(new DrinkSearchModel
|
||||
{
|
||||
UserId = UserId
|
||||
});
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка получения списка напитков пользователя с Id = {Id}", UserId);
|
||||
throw;
|
||||
}
|
||||
}
|
||||
[HttpPost]
|
||||
public void ConnectCardDrink(int CardId, int DrinkId)
|
||||
{
|
||||
try
|
||||
{
|
||||
_DrinkLogic.ConnectCardDrink(new DrinkBindingModel { Id = DrinkId, CardId = CardId });
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка связывания заявки со сборкой");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public void CreateDrink(DrinkBindingModel Model)
|
||||
|
@ -38,24 +38,7 @@ namespace DiningRoomRestApi.Controllers
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Получение заказов по id пользователя (полный список, кот. будет выводиться)
|
||||
/// </summary>
|
||||
/// <param name="userId"></param>
|
||||
/// <returns></returns>
|
||||
[HttpGet]
|
||||
public List<OrderViewModel>? GetOrders(int? userId)
|
||||
{
|
||||
try
|
||||
{
|
||||
return _logic.ReadList(new OrderSearchModel { UserId = userId });
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка получения списка заказов клиента id={Id}", userId);
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
[HttpPost]
|
||||
public void CreateOrder(OrderBindingModel model)
|
||||
|
@ -36,22 +36,6 @@ namespace DiningRoomRestApi.Controllers
|
||||
}
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public List<ProductViewModel>? GetProducts(int? UserId)
|
||||
{
|
||||
try
|
||||
{
|
||||
return _productLogic.ReadList(new ProductSearchModel
|
||||
{
|
||||
UserId = UserId
|
||||
});
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка получения списка блюд пользователя с Id = {Id}", UserId);
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public void CreateProduct(ProductBindingModel Model)
|
||||
|
@ -1,4 +1,4 @@
|
||||
using DiningRoomBusinessLogic.BusinessLogics;
|
||||
using DiningRoomBusinessLogic.BusinessLogic;
|
||||
using DiningRoomContracts.BusinessLogicContracts;
|
||||
using DiningRoomContracts.StorageContracts;
|
||||
using DiningRoomDatabaseImplement.Implements;
|
||||
|
@ -13,11 +13,15 @@
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
</PackageReference>
|
||||
<PackageReference Include="Microsoft.Extensions.Logging" Version="7.0.0" />
|
||||
<PackageReference Include="NLog.Extensions.Logging" Version="5.3.11" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\DiningRoomBusinessLogic\DiningRoomBusinessLogic.csproj" />
|
||||
<ProjectReference Include="..\DiningRoomContracts\DiningRoomContracts.csproj" />
|
||||
<ProjectReference Include="..\DiningRoomDatabaseImplement\DiningRoomDatabaseImplement.csproj" />
|
||||
<ProjectReference Include="..\DiningRoomDataModels\DiningRoomDataModels.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
39
DiningRoom/DiningRoomView/Form1.Designer.cs
generated
39
DiningRoom/DiningRoomView/Form1.Designer.cs
generated
@ -1,39 +0,0 @@
|
||||
namespace DiningRoomView
|
||||
{
|
||||
partial class Form1
|
||||
{
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// Clean up any resources being used.
|
||||
/// </summary>
|
||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region Windows Form Designer generated code
|
||||
|
||||
/// <summary>
|
||||
/// Required method for Designer support - do not modify
|
||||
/// the contents of this method with the code editor.
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
this.components = new System.ComponentModel.Container();
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(800, 450);
|
||||
this.Text = "Form1";
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
@ -1,10 +0,0 @@
|
||||
namespace DiningRoomView
|
||||
{
|
||||
public partial class Form1 : Form
|
||||
{
|
||||
public Form1()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
}
|
||||
}
|
142
DiningRoom/DiningRoomView/FormComponent.Designer.cs
generated
Normal file
142
DiningRoom/DiningRoomView/FormComponent.Designer.cs
generated
Normal file
@ -0,0 +1,142 @@
|
||||
namespace DiningRoomView
|
||||
{
|
||||
partial class FormComponent
|
||||
{
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// Clean up any resources being used.
|
||||
/// </summary>
|
||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region Windows Form Designer generated code
|
||||
|
||||
/// <summary>
|
||||
/// Required method for Designer support - do not modify
|
||||
/// the contents of this method with the code editor.
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
ButtonSave = new Button();
|
||||
ButtonCancel = new Button();
|
||||
label1 = new Label();
|
||||
textBoxName = new TextBox();
|
||||
textBoxCost = new TextBox();
|
||||
label2 = new Label();
|
||||
comboBoxUnit = new ComboBox();
|
||||
label3 = new Label();
|
||||
SuspendLayout();
|
||||
//
|
||||
// ButtonSave
|
||||
//
|
||||
ButtonSave.Location = new Point(192, 111);
|
||||
ButtonSave.Name = "ButtonSave";
|
||||
ButtonSave.Size = new Size(86, 23);
|
||||
ButtonSave.TabIndex = 0;
|
||||
ButtonSave.Text = "Сохранение";
|
||||
ButtonSave.UseVisualStyleBackColor = true;
|
||||
ButtonSave.Click += ButtonSave_Click;
|
||||
//
|
||||
// ButtonCancel
|
||||
//
|
||||
ButtonCancel.Location = new Point(284, 111);
|
||||
ButtonCancel.Name = "ButtonCancel";
|
||||
ButtonCancel.Size = new Size(75, 23);
|
||||
ButtonCancel.TabIndex = 1;
|
||||
ButtonCancel.Text = "Отмена";
|
||||
ButtonCancel.UseVisualStyleBackColor = true;
|
||||
ButtonCancel.Click += ButtonCancel_Click;
|
||||
//
|
||||
// label1
|
||||
//
|
||||
label1.AutoSize = true;
|
||||
label1.Location = new Point(12, 15);
|
||||
label1.Name = "label1";
|
||||
label1.Size = new Size(62, 15);
|
||||
label1.TabIndex = 2;
|
||||
label1.Text = "Название:";
|
||||
//
|
||||
// textBoxName
|
||||
//
|
||||
textBoxName.Location = new Point(138, 12);
|
||||
textBoxName.Name = "textBoxName";
|
||||
textBoxName.Size = new Size(222, 23);
|
||||
textBoxName.TabIndex = 3;
|
||||
//
|
||||
// textBoxCost
|
||||
//
|
||||
textBoxCost.Location = new Point(138, 38);
|
||||
textBoxCost.Name = "textBoxCost";
|
||||
textBoxCost.Size = new Size(222, 23);
|
||||
textBoxCost.TabIndex = 4;
|
||||
//
|
||||
// label2
|
||||
//
|
||||
label2.AutoSize = true;
|
||||
label2.Location = new Point(12, 41);
|
||||
label2.Name = "label2";
|
||||
label2.Size = new Size(38, 15);
|
||||
label2.TabIndex = 5;
|
||||
label2.Text = "Цена:";
|
||||
//
|
||||
// comboBoxUnit
|
||||
//
|
||||
comboBoxUnit.DropDownStyle = ComboBoxStyle.DropDownList;
|
||||
comboBoxUnit.FormattingEnabled = true;
|
||||
comboBoxUnit.Location = new Point(137, 64);
|
||||
comboBoxUnit.Name = "comboBoxUnit";
|
||||
comboBoxUnit.Size = new Size(222, 23);
|
||||
comboBoxUnit.TabIndex = 11;
|
||||
//
|
||||
// label3
|
||||
//
|
||||
label3.AutoSize = true;
|
||||
label3.Location = new Point(12, 67);
|
||||
label3.Name = "label3";
|
||||
label3.Size = new Size(119, 15);
|
||||
label3.TabIndex = 12;
|
||||
label3.Text = "Единица измерения:";
|
||||
//
|
||||
// FormComponent
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(7F, 15F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
ClientSize = new Size(377, 151);
|
||||
Controls.Add(label3);
|
||||
Controls.Add(comboBoxUnit);
|
||||
Controls.Add(label2);
|
||||
Controls.Add(textBoxCost);
|
||||
Controls.Add(textBoxName);
|
||||
Controls.Add(label1);
|
||||
Controls.Add(ButtonCancel);
|
||||
Controls.Add(ButtonSave);
|
||||
Name = "FormComponent";
|
||||
Text = "Компонент";
|
||||
Load += FormComponent_Load;
|
||||
ResumeLayout(false);
|
||||
PerformLayout();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private System.Windows.Forms.Button ButtonSave;
|
||||
private System.Windows.Forms.Button ButtonCancel;
|
||||
private System.Windows.Forms.Label label1;
|
||||
private System.Windows.Forms.TextBox textBoxName;
|
||||
private TextBox textBoxCost;
|
||||
private Label label2;
|
||||
private ComboBox comboBoxUnit;
|
||||
private Label label3;
|
||||
}
|
||||
}
|
88
DiningRoom/DiningRoomView/FormComponent.cs
Normal file
88
DiningRoom/DiningRoomView/FormComponent.cs
Normal file
@ -0,0 +1,88 @@
|
||||
using DiningRoomContracts.BindingModels;
|
||||
using DiningRoomContracts.BusinessLogicContracts;
|
||||
using DiningRoomContracts.SearchModels;
|
||||
using DiningRoomDataModels.Enums;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
namespace DiningRoomView
|
||||
{
|
||||
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<FormComponent> 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();
|
||||
comboBoxUnit.DisplayMember = "Unit";
|
||||
comboBoxUnit.ValueMember = "Id";
|
||||
comboBoxUnit.DataSource = Enum.GetValues(typeof(ComponentUnit)); ;
|
||||
comboBoxUnit.SelectedItem = null;
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Îøèáêà ïîëó÷åíèÿ êîìïîíåíòà");
|
||||
MessageBox.Show(ex.Message, "Îøèáêà", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
comboBoxUnit.DataSource = Enum.GetValues(typeof(ComponentUnit)); ;
|
||||
comboBoxUnit.SelectedItem = 1;
|
||||
}
|
||||
}
|
||||
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,
|
||||
Unit = (ComponentUnit)comboBoxUnit.SelectedItem,
|
||||
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();
|
||||
}
|
||||
}
|
||||
}
|
@ -1,17 +1,17 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
|
||||
Example:
|
||||
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
@ -26,36 +26,36 @@
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
114
DiningRoom/DiningRoomView/FormComponents.Designer.cs
generated
Normal file
114
DiningRoom/DiningRoomView/FormComponents.Designer.cs
generated
Normal file
@ -0,0 +1,114 @@
|
||||
namespace DiningRoomView
|
||||
{
|
||||
partial class FormComponents
|
||||
{
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// Clean up any resources being used.
|
||||
/// </summary>
|
||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region Windows Form Designer generated code
|
||||
|
||||
/// <summary>
|
||||
/// Required method for Designer support - do not modify
|
||||
/// the contents of this method with the code editor.
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
dataGridView = new DataGridView();
|
||||
ButtonAdd = new Button();
|
||||
ButtonUpd = new Button();
|
||||
ButtonDel = new Button();
|
||||
ButtonRef = new Button();
|
||||
((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit();
|
||||
SuspendLayout();
|
||||
//
|
||||
// dataGridView
|
||||
//
|
||||
dataGridView.BackgroundColor = SystemColors.ControlLightLight;
|
||||
dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
||||
dataGridView.Location = new Point(0, 0);
|
||||
dataGridView.Name = "dataGridView";
|
||||
dataGridView.RowTemplate.Height = 25;
|
||||
dataGridView.Size = new Size(414, 426);
|
||||
dataGridView.TabIndex = 0;
|
||||
//
|
||||
// ButtonAdd
|
||||
//
|
||||
ButtonAdd.Location = new Point(429, 12);
|
||||
ButtonAdd.Name = "ButtonAdd";
|
||||
ButtonAdd.Size = new Size(101, 23);
|
||||
ButtonAdd.TabIndex = 1;
|
||||
ButtonAdd.Text = "Добавить";
|
||||
ButtonAdd.UseVisualStyleBackColor = true;
|
||||
ButtonAdd.Click += ButtonAdd_Click;
|
||||
//
|
||||
// ButtonUpd
|
||||
//
|
||||
ButtonUpd.Location = new Point(429, 51);
|
||||
ButtonUpd.Name = "ButtonUpd";
|
||||
ButtonUpd.Size = new Size(101, 23);
|
||||
ButtonUpd.TabIndex = 2;
|
||||
ButtonUpd.Text = "Изменить";
|
||||
ButtonUpd.UseVisualStyleBackColor = true;
|
||||
ButtonUpd.Click += ButtonUpd_Click;
|
||||
//
|
||||
// ButtonDel
|
||||
//
|
||||
ButtonDel.Location = new Point(429, 91);
|
||||
ButtonDel.Name = "ButtonDel";
|
||||
ButtonDel.Size = new Size(101, 23);
|
||||
ButtonDel.TabIndex = 3;
|
||||
ButtonDel.Text = "Удалить";
|
||||
ButtonDel.UseVisualStyleBackColor = true;
|
||||
ButtonDel.Click += ButtonDel_Click;
|
||||
//
|
||||
// ButtonRef
|
||||
//
|
||||
ButtonRef.Location = new Point(429, 133);
|
||||
ButtonRef.Name = "ButtonRef";
|
||||
ButtonRef.Size = new Size(101, 23);
|
||||
ButtonRef.TabIndex = 4;
|
||||
ButtonRef.Text = "Обновить";
|
||||
ButtonRef.UseVisualStyleBackColor = true;
|
||||
ButtonRef.Click += ButtonRef_Click;
|
||||
//
|
||||
// FormComponents
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(7F, 15F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
ClientSize = new Size(542, 428);
|
||||
Controls.Add(ButtonRef);
|
||||
Controls.Add(ButtonDel);
|
||||
Controls.Add(ButtonUpd);
|
||||
Controls.Add(ButtonAdd);
|
||||
Controls.Add(dataGridView);
|
||||
Name = "FormComponents";
|
||||
Text = "Компоненты";
|
||||
Load += FormComponents_Load;
|
||||
((System.ComponentModel.ISupportInitialize)dataGridView).EndInit();
|
||||
ResumeLayout(false);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private System.Windows.Forms.DataGridView dataGridView;
|
||||
private System.Windows.Forms.Button ButtonAdd;
|
||||
private System.Windows.Forms.Button ButtonUpd;
|
||||
private System.Windows.Forms.Button ButtonDel;
|
||||
private System.Windows.Forms.Button ButtonRef;
|
||||
}
|
||||
}
|
107
DiningRoom/DiningRoomView/FormComponents.cs
Normal file
107
DiningRoom/DiningRoomView/FormComponents.cs
Normal file
@ -0,0 +1,107 @@
|
||||
using DiningRoomContracts.BindingModels;
|
||||
using DiningRoomContracts.BusinessLogicContracts;
|
||||
using DiningRoomContracts.SearchModels;
|
||||
using DiningRoomDataModels.Models;
|
||||
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 DiningRoomView
|
||||
{
|
||||
public partial class FormComponents : Form
|
||||
{
|
||||
private readonly ILogger _logger;
|
||||
private readonly IComponentLogic _logic;
|
||||
public FormComponents(ILogger<FormComponents> 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();
|
||||
}
|
||||
}
|
||||
}
|
120
DiningRoom/DiningRoomView/FormComponents.resx
Normal file
120
DiningRoom/DiningRoomView/FormComponents.resx
Normal file
@ -0,0 +1,120 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
</root>
|
228
DiningRoom/DiningRoomView/FormMain.Designer.cs
generated
Normal file
228
DiningRoom/DiningRoomView/FormMain.Designer.cs
generated
Normal file
@ -0,0 +1,228 @@
|
||||
namespace DiningRoomView
|
||||
{
|
||||
partial class FormMain
|
||||
{
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// Clean up any resources being used.
|
||||
/// </summary>
|
||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region Windows Form Designer generated code
|
||||
|
||||
/// <summary>
|
||||
/// Required method for Designer support - do not modify
|
||||
/// the contents of this method with the code editor.
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
dataGridView1 = new DataGridView();
|
||||
dataGridView2 = new DataGridView();
|
||||
menuStrip1 = new MenuStrip();
|
||||
продуктыToolStripMenuItem = new ToolStripMenuItem();
|
||||
клиентыToolStripMenuItem = new ToolStripMenuItem();
|
||||
поставщикиToolStripMenuItem = new ToolStripMenuItem();
|
||||
button1 = new Button();
|
||||
label1 = new Label();
|
||||
label2 = new Label();
|
||||
button3 = new Button();
|
||||
button4 = new Button();
|
||||
button2 = new Button();
|
||||
button5 = new Button();
|
||||
button6 = new Button();
|
||||
button7 = new Button();
|
||||
((System.ComponentModel.ISupportInitialize)dataGridView1).BeginInit();
|
||||
((System.ComponentModel.ISupportInitialize)dataGridView2).BeginInit();
|
||||
menuStrip1.SuspendLayout();
|
||||
SuspendLayout();
|
||||
//
|
||||
// dataGridView1
|
||||
//
|
||||
dataGridView1.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
||||
dataGridView1.Location = new Point(12, 53);
|
||||
dataGridView1.Name = "dataGridView1";
|
||||
dataGridView1.RowTemplate.Height = 25;
|
||||
dataGridView1.Size = new Size(455, 257);
|
||||
dataGridView1.TabIndex = 0;
|
||||
//
|
||||
// dataGridView2
|
||||
//
|
||||
dataGridView2.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
||||
dataGridView2.Location = new Point(12, 341);
|
||||
dataGridView2.Name = "dataGridView2";
|
||||
dataGridView2.RowTemplate.Height = 25;
|
||||
dataGridView2.Size = new Size(455, 240);
|
||||
dataGridView2.TabIndex = 1;
|
||||
//
|
||||
// menuStrip1
|
||||
//
|
||||
menuStrip1.Items.AddRange(new ToolStripItem[] { продуктыToolStripMenuItem, клиентыToolStripMenuItem, поставщикиToolStripMenuItem });
|
||||
menuStrip1.Location = new Point(0, 0);
|
||||
menuStrip1.Name = "menuStrip1";
|
||||
menuStrip1.Size = new Size(666, 24);
|
||||
menuStrip1.TabIndex = 2;
|
||||
menuStrip1.Text = "menuStrip1";
|
||||
//
|
||||
// продуктыToolStripMenuItem
|
||||
//
|
||||
продуктыToolStripMenuItem.Name = "продуктыToolStripMenuItem";
|
||||
продуктыToolStripMenuItem.Size = new Size(74, 20);
|
||||
продуктыToolStripMenuItem.Text = "Продукты";
|
||||
продуктыToolStripMenuItem.Click += ПродуктыToolStripMenuItem_Click;
|
||||
//
|
||||
// клиентыToolStripMenuItem
|
||||
//
|
||||
клиентыToolStripMenuItem.Name = "клиентыToolStripMenuItem";
|
||||
клиентыToolStripMenuItem.Size = new Size(12, 20);
|
||||
//
|
||||
// поставщикиToolStripMenuItem
|
||||
//
|
||||
поставщикиToolStripMenuItem.Name = "поставщикиToolStripMenuItem";
|
||||
поставщикиToolStripMenuItem.Size = new Size(12, 20);
|
||||
//
|
||||
// button1
|
||||
//
|
||||
button1.Location = new Point(491, 139);
|
||||
button1.Name = "button1";
|
||||
button1.Size = new Size(153, 23);
|
||||
button1.TabIndex = 3;
|
||||
button1.Text = "Создать блюдо";
|
||||
button1.UseVisualStyleBackColor = true;
|
||||
button1.Click += ButtonAddProduct_Click;
|
||||
//
|
||||
// label1
|
||||
//
|
||||
label1.AutoSize = true;
|
||||
label1.Font = new Font("Segoe UI", 14.25F, FontStyle.Regular, GraphicsUnit.Point);
|
||||
label1.Location = new Point(179, 24);
|
||||
label1.Name = "label1";
|
||||
label1.Size = new Size(68, 25);
|
||||
label1.TabIndex = 5;
|
||||
label1.Text = "Блюда";
|
||||
//
|
||||
// label2
|
||||
//
|
||||
label2.AutoSize = true;
|
||||
label2.Font = new Font("Segoe UI", 14.25F, FontStyle.Regular, GraphicsUnit.Point);
|
||||
label2.Location = new Point(179, 313);
|
||||
label2.Name = "label2";
|
||||
label2.Size = new Size(85, 25);
|
||||
label2.TabIndex = 6;
|
||||
label2.Text = "Напитки";
|
||||
//
|
||||
// button3
|
||||
//
|
||||
button3.Location = new Point(491, 168);
|
||||
button3.Name = "button3";
|
||||
button3.Size = new Size(153, 23);
|
||||
button3.TabIndex = 7;
|
||||
button3.Text = "Редактировать блюдо";
|
||||
button3.UseVisualStyleBackColor = true;
|
||||
button3.Click += ButtonUpdProduct_Click;
|
||||
//
|
||||
// button4
|
||||
//
|
||||
button4.Location = new Point(491, 442);
|
||||
button4.Name = "button4";
|
||||
button4.Size = new Size(153, 23);
|
||||
button4.TabIndex = 8;
|
||||
button4.Text = "Редактировать напиток";
|
||||
button4.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// button2
|
||||
//
|
||||
button2.Location = new Point(491, 197);
|
||||
button2.Name = "button2";
|
||||
button2.Size = new Size(153, 23);
|
||||
button2.TabIndex = 9;
|
||||
button2.Text = "Удалить блюдо";
|
||||
button2.UseVisualStyleBackColor = true;
|
||||
button2.Click += ButtonDelProduct_Click;
|
||||
//
|
||||
// button5
|
||||
//
|
||||
button5.Location = new Point(491, 315);
|
||||
button5.Name = "button5";
|
||||
button5.Size = new Size(153, 23);
|
||||
button5.TabIndex = 10;
|
||||
button5.Text = "Обновить списки";
|
||||
button5.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// button6
|
||||
//
|
||||
button6.Location = new Point(491, 413);
|
||||
button6.Name = "button6";
|
||||
button6.Size = new Size(153, 23);
|
||||
button6.TabIndex = 11;
|
||||
button6.Text = "Создать напиток";
|
||||
button6.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// button7
|
||||
//
|
||||
button7.Location = new Point(491, 471);
|
||||
button7.Name = "button7";
|
||||
button7.Size = new Size(153, 23);
|
||||
button7.TabIndex = 12;
|
||||
button7.Text = "Удалить напиток";
|
||||
button7.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// FormMain
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(7F, 15F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
ClientSize = new Size(666, 593);
|
||||
Controls.Add(button7);
|
||||
Controls.Add(button6);
|
||||
Controls.Add(button5);
|
||||
Controls.Add(button2);
|
||||
Controls.Add(button4);
|
||||
Controls.Add(button3);
|
||||
Controls.Add(label2);
|
||||
Controls.Add(label1);
|
||||
Controls.Add(button1);
|
||||
Controls.Add(dataGridView2);
|
||||
Controls.Add(dataGridView1);
|
||||
Controls.Add(menuStrip1);
|
||||
MainMenuStrip = menuStrip1;
|
||||
Name = "FormMain";
|
||||
Text = "FormMain";
|
||||
Load += FormMain_Load;
|
||||
((System.ComponentModel.ISupportInitialize)dataGridView1).EndInit();
|
||||
((System.ComponentModel.ISupportInitialize)dataGridView2).EndInit();
|
||||
menuStrip1.ResumeLayout(false);
|
||||
menuStrip1.PerformLayout();
|
||||
ResumeLayout(false);
|
||||
PerformLayout();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private DataGridView dataGridView1;
|
||||
private DataGridView dataGridView2;
|
||||
private MenuStrip menuStrip1;
|
||||
private ToolStripMenuItem продуктыToolStripMenuItem;
|
||||
private ToolStripMenuItem клиентыToolStripMenuItem;
|
||||
private ToolStripMenuItem поставщикиToolStripMenuItem;
|
||||
private Button button1;
|
||||
private Label label1;
|
||||
private Label label2;
|
||||
private Button button3;
|
||||
private Button button4;
|
||||
private Button button2;
|
||||
private Button button5;
|
||||
private Button button6;
|
||||
private Button button7;
|
||||
}
|
||||
}
|
198
DiningRoom/DiningRoomView/FormMain.cs
Normal file
198
DiningRoom/DiningRoomView/FormMain.cs
Normal file
@ -0,0 +1,198 @@
|
||||
using Microsoft.Extensions.Logging;
|
||||
using DiningRoomContracts.BusinessLogicContracts;
|
||||
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;
|
||||
using DiningRoomContracts.BindingModels;
|
||||
|
||||
namespace DiningRoomView
|
||||
{
|
||||
public partial class FormMain : Form
|
||||
{
|
||||
private readonly ILogger _logger;
|
||||
private readonly IProductLogic _productLogic;
|
||||
private readonly IDrinkLogic _drinkLogic;
|
||||
public FormMain(ILogger<FormMain> logger, IProductLogic productLogic, IDrinkLogic drinkLogic)
|
||||
{
|
||||
InitializeComponent();
|
||||
_logger = logger;
|
||||
_productLogic = productLogic;
|
||||
_drinkLogic = drinkLogic;
|
||||
}
|
||||
private void FormMain_Load(object sender, EventArgs e)
|
||||
{
|
||||
LoadData();
|
||||
}
|
||||
private void LoadData()
|
||||
{
|
||||
_logger.LogInformation("Загрузка блюд");
|
||||
try
|
||||
{
|
||||
var list = _productLogic.ReadList(null);
|
||||
if (list != null)
|
||||
{
|
||||
dataGridView1.DataSource = list;
|
||||
dataGridView1.Columns["Id"].Visible = false;
|
||||
dataGridView1.Columns["ProductComponents"].Visible = false;
|
||||
dataGridView1.Columns["ProductName"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
|
||||
|
||||
}
|
||||
_logger.LogInformation("Загрузка блюд успешна");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка загрузки блюд");
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
|
||||
_logger.LogInformation("Загрузка напитков");
|
||||
try
|
||||
{
|
||||
var list = _drinkLogic.ReadList(null);
|
||||
if (list != null)
|
||||
{
|
||||
dataGridView2.DataSource = list;
|
||||
|
||||
}
|
||||
_logger.LogInformation("Загрузка напитков успешна");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка загрузки напитков");
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
private void ПродуктыToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
var service = Program.ServiceProvider?.GetService(typeof(FormComponents));
|
||||
if (service is FormComponents form)
|
||||
{
|
||||
form.ShowDialog();
|
||||
}
|
||||
}
|
||||
private void ButtonAddProduct_Click(object sender, EventArgs e)
|
||||
{
|
||||
var service = Program.ServiceProvider?.GetService(typeof(FormProduct));
|
||||
if (service is FormProduct form)
|
||||
{
|
||||
if (form.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
LoadData();
|
||||
}
|
||||
}
|
||||
}
|
||||
private void ButtonUpdProduct_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (dataGridView1.SelectedRows.Count == 1)
|
||||
{
|
||||
var service = Program.ServiceProvider?.GetService(typeof(FormProduct));
|
||||
if (service is FormProduct form)
|
||||
{
|
||||
form.Id = Convert.ToInt32(dataGridView1.SelectedRows[0].Cells["Id"].Value);
|
||||
if (form.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
LoadData();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
private void ButtonDelProduct_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (dataGridView1.SelectedRows.Count == 1)
|
||||
{
|
||||
if (MessageBox.Show("Удалить запись?", "Вопрос", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
|
||||
{
|
||||
int id = Convert.ToInt32(dataGridView1.SelectedRows[0].Cells["Id"].Value);
|
||||
_logger.LogInformation("Удаление продукта");
|
||||
try
|
||||
{
|
||||
if (!_productLogic.Delete(new ProductBindingModel { Id = id }))
|
||||
{
|
||||
throw new Exception("Ошибка при удалении. Дополнительная информация в логах.");
|
||||
}
|
||||
LoadData();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка удаления продукта");
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
private void ButtonAddDrink_Click(object sender, EventArgs e)
|
||||
{
|
||||
var service = Program.ServiceProvider?.GetService(typeof(FormProduct));
|
||||
if (service is FormProduct form)
|
||||
{
|
||||
if (form.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
LoadData();
|
||||
}
|
||||
}
|
||||
}
|
||||
private void ButtonUpdDrink_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (dataGridView1.SelectedRows.Count == 1)
|
||||
{
|
||||
var service = Program.ServiceProvider?.GetService(typeof(FormProduct));
|
||||
if (service is FormProduct form)
|
||||
{
|
||||
form.Id = Convert.ToInt32(dataGridView1.SelectedRows[0].Cells["Id"].Value);
|
||||
if (form.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
LoadData();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
private void ButtonDelDrink_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (dataGridView1.SelectedRows.Count == 1)
|
||||
{
|
||||
if (MessageBox.Show("Удалить запись?", "Вопрос", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
|
||||
{
|
||||
int id = Convert.ToInt32(dataGridView1.SelectedRows[0].Cells["Id"].Value);
|
||||
_logger.LogInformation("Удаление продукта");
|
||||
try
|
||||
{
|
||||
if (!_productLogic.Delete(new ProductBindingModel { Id = id }))
|
||||
{
|
||||
throw new Exception("Ошибка при удалении. Дополнительная информация в логах.");
|
||||
}
|
||||
LoadData();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка удаления продукта");
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
//private void ButtonCreateSale_Click(object sender, EventArgs e)
|
||||
//{
|
||||
// var service = Program.ServiceProvider?.GetService(typeof(FormCreateSale));
|
||||
// if (service is FormCreateSale form)
|
||||
// {
|
||||
// form.ShowDialog();
|
||||
// LoadData();
|
||||
// }
|
||||
//}
|
||||
//private void ButtonCreateSupply_Click(object sender, EventArgs e)
|
||||
//{
|
||||
// var service = Program.ServiceProvider?.GetService(typeof(FormCreateSupply));
|
||||
// if (service is FormCreateSupply form)
|
||||
// {
|
||||
// form.ShowDialog();
|
||||
// LoadData();
|
||||
// }
|
||||
//}
|
||||
}
|
||||
}
|
126
DiningRoom/DiningRoomView/FormMain.resx
Normal file
126
DiningRoom/DiningRoomView/FormMain.resx
Normal file
@ -0,0 +1,126 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<metadata name="menuStrip1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>17, 17</value>
|
||||
</metadata>
|
||||
<metadata name="$this.TrayHeight" type="System.Int32, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>75</value>
|
||||
</metadata>
|
||||
</root>
|
224
DiningRoom/DiningRoomView/FormProduct.Designer.cs
generated
Normal file
224
DiningRoom/DiningRoomView/FormProduct.Designer.cs
generated
Normal file
@ -0,0 +1,224 @@
|
||||
namespace DiningRoomView
|
||||
{
|
||||
partial class FormProduct
|
||||
{
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// Clean up any resources being used.
|
||||
/// </summary>
|
||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region Windows Form Designer generated code
|
||||
|
||||
/// <summary>
|
||||
/// Required method for Designer support - do not modify
|
||||
/// the contents of this method with the code editor.
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
labelName = new Label();
|
||||
labelPrice = new Label();
|
||||
textBoxName = new TextBox();
|
||||
textBoxPrice = new TextBox();
|
||||
groupBox1 = new GroupBox();
|
||||
dataGridView = new DataGridView();
|
||||
ID = new DataGridViewTextBoxColumn();
|
||||
ComponentName = new DataGridViewTextBoxColumn();
|
||||
Count = new DataGridViewTextBoxColumn();
|
||||
ButtonRef = new Button();
|
||||
ButtonDel = new Button();
|
||||
ButtonUpd = new Button();
|
||||
ButtonAdd = new Button();
|
||||
ButtonSave = new Button();
|
||||
ButtonCancel = new Button();
|
||||
groupBox1.SuspendLayout();
|
||||
((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit();
|
||||
SuspendLayout();
|
||||
//
|
||||
// labelName
|
||||
//
|
||||
labelName.AutoSize = true;
|
||||
labelName.Location = new Point(12, 9);
|
||||
labelName.Name = "labelName";
|
||||
labelName.Size = new Size(62, 15);
|
||||
labelName.TabIndex = 0;
|
||||
labelName.Text = "Название:";
|
||||
//
|
||||
// labelPrice
|
||||
//
|
||||
labelPrice.AutoSize = true;
|
||||
labelPrice.Location = new Point(12, 41);
|
||||
labelPrice.Name = "labelPrice";
|
||||
labelPrice.Size = new Size(38, 15);
|
||||
labelPrice.TabIndex = 1;
|
||||
labelPrice.Text = "Цена:";
|
||||
//
|
||||
// textBoxName
|
||||
//
|
||||
textBoxName.Location = new Point(94, 6);
|
||||
textBoxName.Name = "textBoxName";
|
||||
textBoxName.Size = new Size(247, 23);
|
||||
textBoxName.TabIndex = 2;
|
||||
//
|
||||
// textBoxPrice
|
||||
//
|
||||
textBoxPrice.Location = new Point(94, 38);
|
||||
textBoxPrice.Name = "textBoxPrice";
|
||||
textBoxPrice.Size = new Size(100, 23);
|
||||
textBoxPrice.TabIndex = 3;
|
||||
//
|
||||
// groupBox1
|
||||
//
|
||||
groupBox1.Controls.Add(dataGridView);
|
||||
groupBox1.Controls.Add(ButtonRef);
|
||||
groupBox1.Controls.Add(ButtonDel);
|
||||
groupBox1.Controls.Add(ButtonUpd);
|
||||
groupBox1.Controls.Add(ButtonAdd);
|
||||
groupBox1.Location = new Point(12, 67);
|
||||
groupBox1.Name = "groupBox1";
|
||||
groupBox1.Size = new Size(510, 338);
|
||||
groupBox1.TabIndex = 4;
|
||||
groupBox1.TabStop = false;
|
||||
groupBox1.Text = "Компонент";
|
||||
//
|
||||
// dataGridView
|
||||
//
|
||||
dataGridView.BackgroundColor = SystemColors.ButtonHighlight;
|
||||
dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
||||
dataGridView.Columns.AddRange(new DataGridViewColumn[] { ID, ComponentName, Count });
|
||||
dataGridView.Location = new Point(0, 21);
|
||||
dataGridView.Name = "dataGridView";
|
||||
dataGridView.RowTemplate.Height = 25;
|
||||
dataGridView.Size = new Size(394, 311);
|
||||
dataGridView.TabIndex = 5;
|
||||
//
|
||||
// ID
|
||||
//
|
||||
ID.HeaderText = "Id";
|
||||
ID.Name = "ID";
|
||||
ID.Visible = false;
|
||||
ID.Width = 250;
|
||||
//
|
||||
// ComponentName
|
||||
//
|
||||
ComponentName.HeaderText = "Компоненте";
|
||||
ComponentName.Name = "ComponentName";
|
||||
ComponentName.Width = 250;
|
||||
//
|
||||
// Count
|
||||
//
|
||||
Count.HeaderText = "Количество";
|
||||
Count.Name = "Count";
|
||||
//
|
||||
// ButtonRef
|
||||
//
|
||||
ButtonRef.Location = new Point(400, 169);
|
||||
ButtonRef.Name = "ButtonRef";
|
||||
ButtonRef.Size = new Size(106, 28);
|
||||
ButtonRef.TabIndex = 4;
|
||||
ButtonRef.Text = "Обновить";
|
||||
ButtonRef.UseVisualStyleBackColor = true;
|
||||
ButtonRef.Click += ButtonRef_Click;
|
||||
//
|
||||
// ButtonDel
|
||||
//
|
||||
ButtonDel.Location = new Point(400, 135);
|
||||
ButtonDel.Name = "ButtonDel";
|
||||
ButtonDel.Size = new Size(106, 28);
|
||||
ButtonDel.TabIndex = 3;
|
||||
ButtonDel.Text = "Удалить";
|
||||
ButtonDel.UseVisualStyleBackColor = true;
|
||||
ButtonDel.Click += ButtonDel_Click;
|
||||
//
|
||||
// ButtonUpd
|
||||
//
|
||||
ButtonUpd.Location = new Point(400, 101);
|
||||
ButtonUpd.Name = "ButtonUpd";
|
||||
ButtonUpd.Size = new Size(106, 28);
|
||||
ButtonUpd.TabIndex = 2;
|
||||
ButtonUpd.Text = "Изменить";
|
||||
ButtonUpd.UseVisualStyleBackColor = true;
|
||||
ButtonUpd.Click += ButtonUpd_Click;
|
||||
//
|
||||
// ButtonAdd
|
||||
//
|
||||
ButtonAdd.Location = new Point(400, 67);
|
||||
ButtonAdd.Name = "ButtonAdd";
|
||||
ButtonAdd.Size = new Size(106, 28);
|
||||
ButtonAdd.TabIndex = 1;
|
||||
ButtonAdd.Text = "Добавить";
|
||||
ButtonAdd.UseVisualStyleBackColor = true;
|
||||
ButtonAdd.Click += ButtonAdd_Click;
|
||||
//
|
||||
// ButtonSave
|
||||
//
|
||||
ButtonSave.Location = new Point(354, 415);
|
||||
ButtonSave.Name = "ButtonSave";
|
||||
ButtonSave.Size = new Size(75, 23);
|
||||
ButtonSave.TabIndex = 5;
|
||||
ButtonSave.Text = "Сохранить";
|
||||
ButtonSave.UseVisualStyleBackColor = true;
|
||||
ButtonSave.Click += ButtonSave_Click;
|
||||
//
|
||||
// ButtonCancel
|
||||
//
|
||||
ButtonCancel.Location = new Point(435, 415);
|
||||
ButtonCancel.Name = "ButtonCancel";
|
||||
ButtonCancel.Size = new Size(75, 23);
|
||||
ButtonCancel.TabIndex = 6;
|
||||
ButtonCancel.Text = "Отмена";
|
||||
ButtonCancel.UseVisualStyleBackColor = true;
|
||||
ButtonCancel.Click += ButtonCancel_Click;
|
||||
//
|
||||
// FormProduct
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(7F, 15F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
ClientSize = new Size(536, 450);
|
||||
Controls.Add(ButtonCancel);
|
||||
Controls.Add(ButtonSave);
|
||||
Controls.Add(groupBox1);
|
||||
Controls.Add(textBoxPrice);
|
||||
Controls.Add(textBoxName);
|
||||
Controls.Add(labelPrice);
|
||||
Controls.Add(labelName);
|
||||
Name = "FormProduct";
|
||||
Text = "Создание изделия";
|
||||
Load += FormProduct_Load;
|
||||
groupBox1.ResumeLayout(false);
|
||||
((System.ComponentModel.ISupportInitialize)dataGridView).EndInit();
|
||||
ResumeLayout(false);
|
||||
PerformLayout();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private System.Windows.Forms.Label labelName;
|
||||
private System.Windows.Forms.Label labelPrice;
|
||||
private System.Windows.Forms.TextBox textBoxName;
|
||||
private System.Windows.Forms.TextBox textBoxPrice;
|
||||
private System.Windows.Forms.GroupBox groupBox1;
|
||||
private System.Windows.Forms.DataGridView dataGridView;
|
||||
private System.Windows.Forms.Button ButtonRef;
|
||||
private System.Windows.Forms.Button ButtonDel;
|
||||
private System.Windows.Forms.Button ButtonUpd;
|
||||
private System.Windows.Forms.Button ButtonAdd;
|
||||
private System.Windows.Forms.Button ButtonSave;
|
||||
private System.Windows.Forms.Button ButtonCancel;
|
||||
private System.Windows.Forms.DataGridViewTextBoxColumn ID;
|
||||
private System.Windows.Forms.DataGridViewTextBoxColumn ComponentName;
|
||||
private System.Windows.Forms.DataGridViewTextBoxColumn Count;
|
||||
}
|
||||
}
|
201
DiningRoom/DiningRoomView/FormProduct.cs
Normal file
201
DiningRoom/DiningRoomView/FormProduct.cs
Normal file
@ -0,0 +1,201 @@
|
||||
using DiningRoomContracts.BindingModels;
|
||||
using DiningRoomContracts.BusinessLogicContracts;
|
||||
using DiningRoomContracts.SearchModels;
|
||||
using DiningRoomDataModels.Models;
|
||||
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 DiningRoomView
|
||||
{
|
||||
public partial class FormProduct : Form
|
||||
{
|
||||
private readonly ILogger _logger;
|
||||
private readonly IProductLogic _logic;
|
||||
private int? _id;
|
||||
private Dictionary<int, (IComponentModel, int)> _productComponents;
|
||||
public int Id { set { _id = value; } }
|
||||
public FormProduct(ILogger<FormProduct> logger, IProductLogic logic)
|
||||
{
|
||||
InitializeComponent();
|
||||
_logger = logger;
|
||||
_logic = logic;
|
||||
_productComponents = new Dictionary<int, (IComponentModel, int)>();
|
||||
}
|
||||
private void FormProduct_Load(object sender, EventArgs e)
|
||||
{
|
||||
if (_id.HasValue)
|
||||
{
|
||||
_logger.LogInformation("Загрузка изделия");
|
||||
try
|
||||
{
|
||||
var view = _logic.ReadElement(new ProductSearchModel { Id = _id.Value });
|
||||
if (view != null)
|
||||
{
|
||||
textBoxName.Text = view.ProductName;
|
||||
textBoxPrice.Text = view.Cost.ToString();
|
||||
_productComponents = view.ProductComponents ?? new Dictionary<int, (IComponentModel, int)>();
|
||||
LoadData();
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка загрузки изделия");
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
}
|
||||
private void LoadData()
|
||||
{
|
||||
_logger.LogInformation("Загрузка компонент изделия");
|
||||
try
|
||||
{
|
||||
if (_productComponents != null)
|
||||
{
|
||||
dataGridView.Rows.Clear();
|
||||
foreach (var pc in _productComponents)
|
||||
{
|
||||
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(FormProductComponent));
|
||||
if (service is FormProductComponent form)
|
||||
{
|
||||
if (form.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
if (form.ComponentModel == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
_logger.LogInformation("Добавление нового компонента: {ComponentName} - {Count}", form.ComponentModel.ComponentName, form.Count);
|
||||
if (_productComponents.ContainsKey(form.Id))
|
||||
{
|
||||
_productComponents[form.Id] = (form.ComponentModel, form.Count);
|
||||
}
|
||||
else
|
||||
{
|
||||
_productComponents.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(FormProductComponent));
|
||||
if (service is FormProductComponent form)
|
||||
{
|
||||
int id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells[0].Value);
|
||||
form.Id = id;
|
||||
form.Count = _productComponents[id].Item2;
|
||||
if (form.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
if (form.ComponentModel == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
_logger.LogInformation("Изменение компонента: {ComponentName} - {Count}", form.ComponentModel.ComponentName, form.Count);
|
||||
_productComponents[form.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); _productComponents?.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 (_productComponents == null || _productComponents.Count == 0)
|
||||
{
|
||||
MessageBox.Show("Заполните компоненты", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
return;
|
||||
}
|
||||
_logger.LogInformation("Сохранение изделия");
|
||||
try
|
||||
{
|
||||
var model = new ProductBindingModel
|
||||
{
|
||||
Id = _id ?? 0,
|
||||
ProductName = textBoxName.Text,
|
||||
Cost = Convert.ToDouble(textBoxPrice.Text),
|
||||
ProductComponents = _productComponents
|
||||
};
|
||||
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 _productComponents)
|
||||
{
|
||||
price += ((elem.Value.Item1?.Cost ?? 0) * elem.Value.Item2);
|
||||
}
|
||||
return Math.Round(price * 1.1, 2);
|
||||
}
|
||||
}
|
||||
}
|
120
DiningRoom/DiningRoomView/FormProduct.resx
Normal file
120
DiningRoom/DiningRoomView/FormProduct.resx
Normal file
@ -0,0 +1,120 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
</root>
|
120
DiningRoom/DiningRoomView/FormProductComponent.Designer.cs
generated
Normal file
120
DiningRoom/DiningRoomView/FormProductComponent.Designer.cs
generated
Normal file
@ -0,0 +1,120 @@
|
||||
namespace DiningRoomView
|
||||
{
|
||||
partial class FormProductComponent
|
||||
{
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// Clean up any resources being used.
|
||||
/// </summary>
|
||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region Windows Form Designer generated code
|
||||
|
||||
/// <summary>
|
||||
/// Required method for Designer support - do not modify
|
||||
/// the contents of this method with the code editor.
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
labelComponent = new Label();
|
||||
labelCount = new Label();
|
||||
textBoxCount = new TextBox();
|
||||
comboBoxComponent = new ComboBox();
|
||||
buttonCancel = new Button();
|
||||
buttonSave = new Button();
|
||||
SuspendLayout();
|
||||
//
|
||||
// labelComponent
|
||||
//
|
||||
labelComponent.AutoSize = true;
|
||||
labelComponent.Location = new Point(12, 9);
|
||||
labelComponent.Name = "labelComponent";
|
||||
labelComponent.Size = new Size(72, 15);
|
||||
labelComponent.TabIndex = 0;
|
||||
labelComponent.Text = "Компонент:";
|
||||
labelComponent.Click += labelComponent_Click;
|
||||
//
|
||||
// labelCount
|
||||
//
|
||||
labelCount.AutoSize = true;
|
||||
labelCount.Location = new Point(12, 37);
|
||||
labelCount.Name = "labelCount";
|
||||
labelCount.Size = new Size(75, 15);
|
||||
labelCount.TabIndex = 1;
|
||||
labelCount.Text = "Количество:";
|
||||
//
|
||||
// textBoxCount
|
||||
//
|
||||
textBoxCount.Location = new Point(90, 34);
|
||||
textBoxCount.Name = "textBoxCount";
|
||||
textBoxCount.Size = new Size(235, 23);
|
||||
textBoxCount.TabIndex = 3;
|
||||
//
|
||||
// comboBoxComponent
|
||||
//
|
||||
comboBoxComponent.BackColor = SystemColors.Window;
|
||||
comboBoxComponent.FormattingEnabled = true;
|
||||
comboBoxComponent.Location = new Point(90, 6);
|
||||
comboBoxComponent.Name = "comboBoxComponent";
|
||||
comboBoxComponent.Size = new Size(235, 23);
|
||||
comboBoxComponent.TabIndex = 4;
|
||||
//
|
||||
// buttonCancel
|
||||
//
|
||||
buttonCancel.Location = new Point(248, 63);
|
||||
buttonCancel.Name = "buttonCancel";
|
||||
buttonCancel.Size = new Size(75, 23);
|
||||
buttonCancel.TabIndex = 5;
|
||||
buttonCancel.Text = "Отмена";
|
||||
buttonCancel.UseVisualStyleBackColor = true;
|
||||
buttonCancel.Click += buttonCancel_Click;
|
||||
//
|
||||
// buttonSave
|
||||
//
|
||||
buttonSave.Location = new Point(167, 63);
|
||||
buttonSave.Name = "buttonSave";
|
||||
buttonSave.Size = new Size(75, 23);
|
||||
buttonSave.TabIndex = 6;
|
||||
buttonSave.Text = "Сохранить";
|
||||
buttonSave.UseVisualStyleBackColor = true;
|
||||
buttonSave.Click += buttonSave_Click;
|
||||
//
|
||||
// FormProductComponent
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(7F, 15F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
ClientSize = new Size(337, 97);
|
||||
Controls.Add(buttonSave);
|
||||
Controls.Add(buttonCancel);
|
||||
Controls.Add(comboBoxComponent);
|
||||
Controls.Add(textBoxCount);
|
||||
Controls.Add(labelCount);
|
||||
Controls.Add(labelComponent);
|
||||
Name = "FormProductComponent";
|
||||
Text = "Компонент";
|
||||
ResumeLayout(false);
|
||||
PerformLayout();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private System.Windows.Forms.Label labelComponent;
|
||||
private System.Windows.Forms.Label labelCount;
|
||||
private System.Windows.Forms.TextBox textBoxCount;
|
||||
private System.Windows.Forms.ComboBox comboBoxComponent;
|
||||
private System.Windows.Forms.Button buttonCancel;
|
||||
private System.Windows.Forms.Button buttonSave;
|
||||
}
|
||||
}
|
77
DiningRoom/DiningRoomView/FormProductComponent.cs
Normal file
77
DiningRoom/DiningRoomView/FormProductComponent.cs
Normal file
@ -0,0 +1,77 @@
|
||||
using DiningRoomContracts.BusinessLogicContracts;
|
||||
using DiningRoomContracts.ViewModels;
|
||||
using DiningRoomDataModels.Models;
|
||||
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 DiningRoomView
|
||||
{
|
||||
public partial class FormProductComponent : Form
|
||||
{
|
||||
private readonly List<ComponentViewModel>? _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 FormProductComponent(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();
|
||||
}
|
||||
|
||||
private void labelComponent_Click(object sender, EventArgs e)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
120
DiningRoom/DiningRoomView/FormProductComponent.resx
Normal file
120
DiningRoom/DiningRoomView/FormProductComponent.resx
Normal file
@ -0,0 +1,120 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
</root>
|
@ -1,7 +1,19 @@
|
||||
using DiningRoomView;
|
||||
using DiningRoomContracts.BusinessLogicContracts;
|
||||
using DiningRoomContracts.StorageContracts;
|
||||
using DiningRoomDatabaseImplement.Implements;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using DiningRoomBusinessLogic.BusinessLogic;
|
||||
|
||||
|
||||
|
||||
namespace DiningRoomView
|
||||
{
|
||||
internal static class Program
|
||||
{
|
||||
private static ServiceProvider? _serviceProvider;
|
||||
public static ServiceProvider? ServiceProvider => _serviceProvider;
|
||||
/// <summary>
|
||||
/// The main entry point for the application.
|
||||
/// </summary>
|
||||
@ -11,7 +23,37 @@ namespace DiningRoomView
|
||||
// To customize application configuration such as set high DPI settings or default font,
|
||||
// see https://aka.ms/applicationconfiguration.
|
||||
ApplicationConfiguration.Initialize();
|
||||
Application.Run(new Form1());
|
||||
var services = new ServiceCollection();
|
||||
ConfigureServices(services);
|
||||
_serviceProvider = services.BuildServiceProvider();
|
||||
Application.Run(_serviceProvider.GetRequiredService<FormMain>());
|
||||
}
|
||||
|
||||
private static void ConfigureServices(ServiceCollection services)
|
||||
{
|
||||
services.AddLogging(option =>
|
||||
{
|
||||
option.SetMinimumLevel(LogLevel.Information);
|
||||
});
|
||||
services.AddTransient<IComponentStorage, ComponentStorage>();
|
||||
services.AddTransient<IProductStorage, ProductStorage>();
|
||||
services.AddTransient<IDrinkStorage, DrinkStorage>();
|
||||
services.AddTransient<ICardStorage, CardStorage>();
|
||||
services.AddTransient<IOrderStorage, OrderStorage>();
|
||||
|
||||
services.AddTransient<IComponentLogic, ComponentLogic>();
|
||||
services.AddTransient<IProductLogic, ProductLogic>();
|
||||
services.AddTransient<IDrinkLogic, DrinkLogic>();
|
||||
services.AddTransient<ICardLogic, CardLogic>();
|
||||
services.AddTransient<IOrderLogic, OrderLogic>();
|
||||
|
||||
services.AddTransient<FormMain>();
|
||||
services.AddTransient<FormComponent>();
|
||||
services.AddTransient<FormComponents>();
|
||||
services.AddTransient<FormProduct>();
|
||||
services.AddTransient<FormProductComponent>();
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user