fix commit 1.0
This commit is contained in:
parent
8a359f676f
commit
0ce6ffd4eb
@ -7,6 +7,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CanteenDataModels", "Cantee
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CanteenContracts", "CanteenContracts\CanteenContracts.csproj", "{A4B80B56-049E-4BBE-938A-7AFB99F13B6E}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CanteenDatabaseImplement", "CanteenDatabaseImplement\CanteenDatabaseImplement.csproj", "{3B63A55E-B35A-4720-B784-014E52A33112}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
@ -21,6 +23,10 @@ Global
|
||||
{A4B80B56-049E-4BBE-938A-7AFB99F13B6E}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{A4B80B56-049E-4BBE-938A-7AFB99F13B6E}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{A4B80B56-049E-4BBE-938A-7AFB99F13B6E}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{3B63A55E-B35A-4720-B784-014E52A33112}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{3B63A55E-B35A-4720-B784-014E52A33112}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{3B63A55E-B35A-4720-B784-014E52A33112}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{3B63A55E-B35A-4720-B784-014E52A33112}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
|
@ -9,18 +9,16 @@ namespace CanteenContracts.BindingModels
|
||||
{
|
||||
public class CookBindingModel : ICookModel
|
||||
{
|
||||
public int Id { get; set; }
|
||||
public int ManagerId { get; set; }
|
||||
public string Name { get; set; } = string.Empty;
|
||||
|
||||
public string Surname { get; set; } = string.Empty;
|
||||
|
||||
public string Patronymic { get; set; } = string.Empty;
|
||||
|
||||
public DateTime DateOfBirth { get; set; }
|
||||
|
||||
public string Position { get; set; }
|
||||
|
||||
public int ClientId { get; set; }
|
||||
|
||||
public int Id { get; set; }
|
||||
}
|
||||
}
|
||||
|
@ -9,14 +9,10 @@ namespace CanteenContracts.BindingModels
|
||||
{
|
||||
public class DishBindingModel : IDishModel
|
||||
{
|
||||
public string DishName { get; set; } = string.Empty;
|
||||
|
||||
public double Cost { get; set; }
|
||||
|
||||
public int ClientId { get; set; }
|
||||
|
||||
public int ProductId { get; set; }
|
||||
|
||||
public int Id { get; set; }
|
||||
public string DishName { get; set; } = string.Empty;
|
||||
public double Cost { get; set; }
|
||||
public int ManagerId { get; set; }
|
||||
public Dictionary<int, IProductModel> DishProducts { get; set; } = new();
|
||||
}
|
||||
}
|
||||
|
@ -1,4 +1,5 @@
|
||||
using CanteenDataModels.Models;
|
||||
using CanteenDataModels.Enums;
|
||||
using CanteenDataModels.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
@ -9,14 +10,14 @@ namespace CanteenContracts.BindingModels
|
||||
{
|
||||
public class LunchBindingModel : ILunchModel
|
||||
{
|
||||
public string LunchName { get; set; } = string.Empty;
|
||||
|
||||
public double Cost { get; set; }
|
||||
|
||||
public int VisitorId { get; set; }
|
||||
|
||||
public Dictionary<int, (IProductModel, int)> LunchProducts { get; set; } = new();
|
||||
|
||||
public int Id { get; set; }
|
||||
public int VisitorId { get; set; }
|
||||
public string LunchName { get; set; } = string.Empty;
|
||||
public double Cost { get; set; }
|
||||
public DateTime DateCreate { get; set; } = DateTime.Now;
|
||||
public Dictionary<int, IProductModel> LunchProducts { get; set; } = new();
|
||||
public Dictionary<int, IOrderModel> LunchOrders { get; set; } = new();
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -9,6 +9,7 @@ namespace CanteenContracts.BindingModels
|
||||
{
|
||||
public class ManagerBindingModel : IManagerModel
|
||||
{
|
||||
public int Id { get; set; }
|
||||
public string FIO { get; set; } = string.Empty;
|
||||
|
||||
public string Login { get; set; } = string.Empty;
|
||||
@ -19,6 +20,5 @@ namespace CanteenContracts.BindingModels
|
||||
|
||||
public int RoleId { get; set; }
|
||||
|
||||
public int Id { get; set; }
|
||||
}
|
||||
}
|
||||
|
@ -10,16 +10,10 @@ namespace CanteenContracts.BindingModels
|
||||
{
|
||||
public class OrderBindingModel : IOrderModel
|
||||
{
|
||||
public int ClientId { get; set; }
|
||||
|
||||
public double Sum { get; set; }
|
||||
|
||||
public OrderStatus Status { get; set; } = OrderStatus.Неизвестен;
|
||||
|
||||
public DateTime DateCreate { get; set; } = DateTime.Now;
|
||||
|
||||
public DateTime? DateImplement { get; set; }
|
||||
|
||||
public int Id { get; set; }
|
||||
public int VisitorId { get; set; }
|
||||
|
||||
public string Description { get; set; } = string.Empty;
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -9,14 +9,14 @@ namespace CanteenContracts.BindingModels
|
||||
{
|
||||
public class ProductBindingModel : IProductModel
|
||||
{
|
||||
public int Id { get; set; }
|
||||
public string ProductName { get; set; } = string.Empty;
|
||||
|
||||
public double Cost { get; set; }
|
||||
|
||||
public int ClientId { get; set; }
|
||||
public int ManagerId { get; set; }
|
||||
|
||||
public Dictionary<int, ICookModel> ProductCooks{ get; set; } = new();
|
||||
|
||||
public int Id { get; set; }
|
||||
}
|
||||
}
|
||||
|
@ -9,8 +9,8 @@ namespace CanteenContracts.BindingModels
|
||||
{
|
||||
public class RoleBindingModel : IRoleModel
|
||||
{
|
||||
public string RoleName { get; set; } = string.Empty;
|
||||
|
||||
public int Id { get; set; }
|
||||
public string RoleName { get; set; } = string.Empty;
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -9,12 +9,11 @@ namespace CanteenContracts.BindingModels
|
||||
{
|
||||
public class TablewareBindingModel : ITablewareModel
|
||||
{
|
||||
public int Id { get; set; }
|
||||
public string TablewareName { get; set; } = string.Empty;
|
||||
|
||||
public int ClientId { get; set; }
|
||||
|
||||
public int Count { get; set; }
|
||||
public int ManagerId { get; set; }
|
||||
public int OrderId { get; set; }
|
||||
|
||||
public int Id { get; set; }
|
||||
}
|
||||
}
|
||||
|
@ -9,6 +9,7 @@ namespace CanteenContracts.BindingModels
|
||||
{
|
||||
public class VisitorBindingModel : IVisitorModel
|
||||
{
|
||||
public int Id { get; set; }
|
||||
public string FIO { get; set; } = string.Empty;
|
||||
|
||||
public string Login { get; set; } = string.Empty;
|
||||
@ -18,7 +19,5 @@ namespace CanteenContracts.BindingModels
|
||||
public string PhoneNumber { get; set; } = string.Empty;
|
||||
|
||||
public int RoleId { get; set; }
|
||||
|
||||
public int Id { get; set; }
|
||||
}
|
||||
}
|
||||
|
@ -1,4 +1,7 @@
|
||||
using System;
|
||||
using CanteenContracts.BindingModels;
|
||||
using CanteenContracts.SearchModel;
|
||||
using CanteenContracts.View;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
@ -6,7 +9,13 @@ using System.Threading.Tasks;
|
||||
|
||||
namespace CanteenContracts.StoragesContracts
|
||||
{
|
||||
internal interface ICookStorage
|
||||
public interface ICookStorage
|
||||
{
|
||||
List<CookViewModel> GetFullList();
|
||||
List<CookViewModel> GetFilteredList(CookSearchModel model);
|
||||
CookViewModel? GetElement(CookSearchModel model);
|
||||
CookViewModel? Insert(CookBindingModel model);
|
||||
CookViewModel? Update(CookBindingModel model);
|
||||
CookViewModel? Delete(CookBindingModel model);
|
||||
}
|
||||
}
|
||||
|
@ -1,4 +1,7 @@
|
||||
using System;
|
||||
using CanteenContracts.BindingModels;
|
||||
using CanteenContracts.SearchModel;
|
||||
using CanteenContracts.View;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
@ -6,7 +9,13 @@ using System.Threading.Tasks;
|
||||
|
||||
namespace CanteenContracts.StoragesContracts
|
||||
{
|
||||
internal interface IDishStorage
|
||||
public interface IDishStorage
|
||||
{
|
||||
List<DishViewModel> GetFullList();
|
||||
List<DishViewModel> GetFilteredList(DishSearchModel model);
|
||||
DishViewModel? GetElement(DishSearchModel model);
|
||||
DishViewModel? Insert(DishBindingModel model);
|
||||
DishViewModel? Update(DishBindingModel model);
|
||||
DishViewModel? Delete(DishBindingModel model);
|
||||
}
|
||||
}
|
||||
|
@ -1,4 +1,7 @@
|
||||
using System;
|
||||
using CanteenContracts.BindingModels;
|
||||
using CanteenContracts.SearchModel;
|
||||
using CanteenContracts.View;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
@ -6,7 +9,13 @@ using System.Threading.Tasks;
|
||||
|
||||
namespace CanteenContracts.StoragesContracts
|
||||
{
|
||||
internal interface ILunchStorage
|
||||
public interface ILunchStorage
|
||||
{
|
||||
List<LunchViewModel> GetFullList();
|
||||
List<LunchViewModel> GetFilteredList(LunchSearchModel model);
|
||||
LunchViewModel? GetElement(LunchSearchModel model);
|
||||
LunchViewModel? Insert(LunchBindingModel model);
|
||||
LunchViewModel? Update(LunchBindingModel model);
|
||||
LunchViewModel? Delete(LunchBindingModel model);
|
||||
}
|
||||
}
|
||||
|
@ -1,4 +1,7 @@
|
||||
using System;
|
||||
using CanteenContracts.BindingModels;
|
||||
using CanteenContracts.SearchModel;
|
||||
using CanteenContracts.View;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
@ -6,7 +9,13 @@ using System.Threading.Tasks;
|
||||
|
||||
namespace CanteenContracts.StoragesContracts
|
||||
{
|
||||
internal interface IManagerStorage
|
||||
public interface IManagerStorage
|
||||
{
|
||||
List<ManagerViewModel> GetFullList();
|
||||
List<ManagerViewModel> GetFilteredList(ManagerSearchModel model);
|
||||
ManagerViewModel? GetElement(ManagerSearchModel model);
|
||||
ManagerViewModel? Insert(ManagerBindingModel model);
|
||||
ManagerViewModel? Update(ManagerBindingModel model);
|
||||
ManagerViewModel? Delete(ManagerBindingModel model);
|
||||
}
|
||||
}
|
||||
|
@ -1,4 +1,7 @@
|
||||
using System;
|
||||
using CanteenContracts.BindingModels;
|
||||
using CanteenContracts.SearchModel;
|
||||
using CanteenContracts.View;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
@ -6,7 +9,13 @@ using System.Threading.Tasks;
|
||||
|
||||
namespace CanteenContracts.StoragesContracts
|
||||
{
|
||||
internal interface IOrderStorage
|
||||
public interface IOrderStorage
|
||||
{
|
||||
List<OrderViewModel> GetFullList();
|
||||
List<OrderViewModel> GetFilteredList(OrderSearchModel model);
|
||||
OrderViewModel? GetElement(OrderSearchModel model);
|
||||
OrderViewModel? Insert(OrderBindingModel model);
|
||||
OrderViewModel? Update(OrderBindingModel model);
|
||||
OrderViewModel? Delete(OrderBindingModel model);
|
||||
}
|
||||
}
|
||||
|
@ -1,4 +1,7 @@
|
||||
using System;
|
||||
using CanteenContracts.BindingModels;
|
||||
using CanteenContracts.SearchModel;
|
||||
using CanteenContracts.View;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
@ -6,7 +9,13 @@ using System.Threading.Tasks;
|
||||
|
||||
namespace CanteenContracts.StoragesContracts
|
||||
{
|
||||
internal interface IProductStorage
|
||||
public interface IProductStorage
|
||||
{
|
||||
List<ProductViewModel> GetFullList();
|
||||
List<ProductViewModel> GetFilteredList(ProductSearchModel model);
|
||||
ProductViewModel? GetElement(ProductSearchModel model);
|
||||
ProductViewModel? Insert(ProductBindingModel model);
|
||||
ProductViewModel? Update(ProductBindingModel model);
|
||||
ProductViewModel? Delete(ProductBindingModel model);
|
||||
}
|
||||
}
|
||||
|
@ -1,4 +1,7 @@
|
||||
using System;
|
||||
using CanteenContracts.BindingModels;
|
||||
using CanteenContracts.SearchModel;
|
||||
using CanteenContracts.View;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
@ -6,7 +9,13 @@ using System.Threading.Tasks;
|
||||
|
||||
namespace CanteenContracts.StoragesContracts
|
||||
{
|
||||
internal interface IRoleStorage
|
||||
public interface IRoleStorage
|
||||
{
|
||||
List<RoleViewModel> GetFullList();
|
||||
List<RoleViewModel> GetFilteredList(RoleSearchModel model);
|
||||
RoleViewModel? GetElement(RoleSearchModel model);
|
||||
RoleViewModel? Insert(RoleBindingModel model);
|
||||
RoleViewModel? Update(RoleBindingModel model);
|
||||
RoleViewModel? Delete(RoleBindingModel model);
|
||||
}
|
||||
}
|
||||
|
@ -1,4 +1,7 @@
|
||||
using System;
|
||||
using CanteenContracts.BindingModels;
|
||||
using CanteenContracts.SearchModel;
|
||||
using CanteenContracts.View;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
@ -6,7 +9,13 @@ using System.Threading.Tasks;
|
||||
|
||||
namespace CanteenContracts.StoragesContracts
|
||||
{
|
||||
internal interface ITablewarerStorage
|
||||
public interface ITablewarerStorage
|
||||
{
|
||||
List<TablewareViewModel> GetFullList();
|
||||
List<TablewareViewModel> GetFilteredList(TablewareSearchModel model);
|
||||
TablewareViewModel? GetElement(TablewareSearchModel model);
|
||||
TablewareViewModel? Insert(TablewareBindingModel model);
|
||||
TablewareViewModel? Update(TablewareBindingModel model);
|
||||
TablewareViewModel? Delete(TablewareBindingModel model);
|
||||
}
|
||||
}
|
||||
|
@ -1,4 +1,7 @@
|
||||
using System;
|
||||
using CanteenContracts.BindingModels;
|
||||
using CanteenContracts.SearchModel;
|
||||
using CanteenContracts.View;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
@ -6,7 +9,13 @@ using System.Threading.Tasks;
|
||||
|
||||
namespace CanteenContracts.StoragesContracts
|
||||
{
|
||||
internal interface IVisitorStorage
|
||||
public interface IVisitorStorage
|
||||
{
|
||||
List<VisitorViewModel> GetFullList();
|
||||
List<VisitorViewModel> GetFilteredList(VisitorSearchModel model);
|
||||
VisitorViewModel? GetElement(VisitorSearchModel model);
|
||||
VisitorViewModel? Insert(VisitorBindingModel model);
|
||||
VisitorViewModel? Update(VisitorBindingModel model);
|
||||
VisitorViewModel? Delete(VisitorBindingModel model);
|
||||
}
|
||||
}
|
||||
|
@ -21,7 +21,7 @@ namespace CanteenContracts.View
|
||||
[DisplayName("Должность")]
|
||||
public string Position { get; set; } = string.Empty;
|
||||
|
||||
public int ClientId { get; set; }
|
||||
public int ManagerId { get; set; }
|
||||
|
||||
public int Id { get; set; }
|
||||
}
|
||||
|
@ -15,7 +15,7 @@ namespace CanteenContracts.View
|
||||
[DisplayName("Цена")]
|
||||
public double Cost { get; set; }
|
||||
|
||||
public int ClientId { get; set; }
|
||||
public int ManagerId { get; set; }
|
||||
|
||||
public Dictionary<int, ICookModel> ProductCooks { get; set; } = new();
|
||||
|
||||
|
@ -8,11 +8,14 @@ namespace CanteenDataModels.Models
|
||||
{
|
||||
public interface ICookModel : IId
|
||||
{
|
||||
int Id { get; }
|
||||
int ManagerId { get; }
|
||||
string Name { get; }
|
||||
|
||||
string Surname { get; }
|
||||
string? Patronymic { get; }
|
||||
DateTime DateOfBirth { get; }
|
||||
|
||||
string Patronymic { get; }
|
||||
|
||||
string Position { get; }
|
||||
int ClientId { get; }
|
||||
}
|
||||
}
|
||||
|
@ -8,9 +8,10 @@ namespace CanteenDataModels.Models
|
||||
{
|
||||
public interface IDishModel : IId
|
||||
{
|
||||
int Id { get; }
|
||||
string DishName { get; }
|
||||
double Cost { get; }
|
||||
int VisitorId { get; }
|
||||
int ProductId { get; }
|
||||
int ManagerId { get; }
|
||||
Dictionary<int, IProductModel> DishProducts { get; }
|
||||
}
|
||||
}
|
||||
|
@ -8,9 +8,12 @@ namespace CanteenDataModels.Models
|
||||
{
|
||||
public interface ILunchModel : IId
|
||||
{
|
||||
int Id { get; }
|
||||
int VisitorId { get; }
|
||||
string LunchName { get; }
|
||||
double Cost { get; }
|
||||
int VisitorId { get; }
|
||||
Dictionary<int, (IProductModel, int)> LunchProducts { get; }
|
||||
DateTime DateCreate { get; }
|
||||
Dictionary<int, IProductModel> LunchProducts { get; }
|
||||
Dictionary<int, IOrderModel> LunchOrders { get; }
|
||||
}
|
||||
}
|
||||
|
@ -8,10 +8,15 @@ namespace CanteenDataModels.Models
|
||||
{
|
||||
public interface IManagerModel : IId
|
||||
{
|
||||
int Id { get; }
|
||||
string FIO { get; }
|
||||
|
||||
string Login { get; }
|
||||
|
||||
string Password { get; }
|
||||
|
||||
string PhoneNumber { get; }
|
||||
|
||||
int RoleId { get; }
|
||||
}
|
||||
}
|
||||
|
@ -9,10 +9,9 @@ namespace CanteenDataModels.Models
|
||||
{
|
||||
public interface IOrderModel : IId
|
||||
{
|
||||
int ClientId { get; }
|
||||
double Sum { get; }
|
||||
OrderStatus Status { get; }
|
||||
DateTime DateCreate { get; }
|
||||
DateTime? DateImplement { get; }
|
||||
int Id { get; }
|
||||
int VisitorId { get; }
|
||||
|
||||
string Description { get; }
|
||||
}
|
||||
}
|
||||
|
@ -10,7 +10,7 @@ namespace CanteenDataModels.Models
|
||||
{
|
||||
string ProductName { get; }
|
||||
double Cost { get; }
|
||||
int ClientId { get; }
|
||||
int ManagerId { get; }
|
||||
Dictionary<int, ICookModel> ProductCooks { get; }
|
||||
}
|
||||
}
|
||||
|
@ -9,7 +9,7 @@ namespace CanteenDataModels.Models
|
||||
public interface ITablewareModel : IId
|
||||
{
|
||||
string TablewareName { get; }
|
||||
int ClientId { get; }
|
||||
int ManagerId { get; }
|
||||
int OrderId { get; }
|
||||
}
|
||||
}
|
||||
|
30
Canteen/CanteenDatabaseImplement/CanteenDatabase.cs
Normal file
30
Canteen/CanteenDatabaseImplement/CanteenDatabase.cs
Normal file
@ -0,0 +1,30 @@
|
||||
using CanteenDatabaseImplement.Models;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace CanteenDatabaseImplement
|
||||
{
|
||||
public class CanteenDatabase : DbContext
|
||||
{
|
||||
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
|
||||
{
|
||||
if (optionsBuilder.IsConfigured == false)
|
||||
{
|
||||
optionsBuilder.UseSqlServer(@"Data Source=DESKTOP-AOSK1F5\SQLEXPRESS;Initial Catalog=CanteenDataBase;Integrated Security=True;MultipleActiveResultSets=True;;TrustServerCertificate=True");
|
||||
}
|
||||
base.OnConfiguring(optionsBuilder);
|
||||
}
|
||||
public virtual DbSet<Cook> Cooks { set; get; }
|
||||
public virtual DbSet<CookOrder> OrderCooks { set; get; }
|
||||
public virtual DbSet<Dish> Dishes { set; get; }
|
||||
public virtual DbSet<Lunch> Lunches { set; get; }
|
||||
public virtual DbSet<LunchOrder> OrderLunches { set; get; }
|
||||
public virtual DbSet<Manager> Managers { set; get; }
|
||||
public virtual DbSet<Order> Orders { set; get; }
|
||||
public virtual DbSet<Product> Products { set; get; }
|
||||
public virtual DbSet<ProductCook> ProductCooks { set; get; }
|
||||
public virtual DbSet<ProductLunch> LunchProducts { set; get; }
|
||||
public virtual DbSet<Role> Roles { set; get; }
|
||||
public virtual DbSet<Tableware> Tablewares { set; get; }
|
||||
public virtual DbSet<Visitor> Visitors { set; get; }
|
||||
}
|
||||
}
|
@ -0,0 +1,23 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Folder Include="Implements\" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="7.0.4" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="7.0.4" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\CanteenContracts\CanteenContracts.csproj" />
|
||||
<ProjectReference Include="..\CanteenDataModels\CanteenDataModels.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
33
Canteen/CanteenDatabaseImplement/Models/Cook.cs
Normal file
33
Canteen/CanteenDatabaseImplement/Models/Cook.cs
Normal file
@ -0,0 +1,33 @@
|
||||
using CanteenDataModels.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace CanteenDatabaseImplement.Models
|
||||
{
|
||||
public class Cook : ICookModel
|
||||
{
|
||||
[Required]
|
||||
public string Name { get; private set; } = string.Empty;
|
||||
[Required]
|
||||
public string Surname { get; private set; } = string.Empty;
|
||||
|
||||
public string? Patronymic { get; private set; } = string.Empty;
|
||||
[Required]
|
||||
public DateTime DateOfBirth { get; private set; }
|
||||
[Required]
|
||||
public string Position { get; private set; } = string.Empty;
|
||||
[Required]
|
||||
public int ManagerId { get; private set; }
|
||||
|
||||
public int Id { get; private set; }
|
||||
[ForeignKey("CookId")]
|
||||
public virtual List<ProductCook> Products{ get; set; } = new();
|
||||
[ForeignKey("CookId")]
|
||||
public virtual List<CookOrder> Orders { get; set; } = new();
|
||||
}
|
||||
}
|
24
Canteen/CanteenDatabaseImplement/Models/CookOrder.cs
Normal file
24
Canteen/CanteenDatabaseImplement/Models/CookOrder.cs
Normal file
@ -0,0 +1,24 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace CanteenDatabaseImplement.Models
|
||||
{
|
||||
public class CookOrder
|
||||
{
|
||||
public int Id { get; set; }
|
||||
|
||||
[Required]
|
||||
public int CookId { get; set; }
|
||||
|
||||
[Required]
|
||||
public int OrderId { get; set; }
|
||||
|
||||
public virtual Order Order { get; set; } = new();
|
||||
|
||||
public virtual Cook Cook { get; set; } = new();
|
||||
}
|
||||
}
|
12
Canteen/CanteenDatabaseImplement/Models/Dish.cs
Normal file
12
Canteen/CanteenDatabaseImplement/Models/Dish.cs
Normal file
@ -0,0 +1,12 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace CanteenDatabaseImplement.Models
|
||||
{
|
||||
public class Dish
|
||||
{
|
||||
}
|
||||
}
|
22
Canteen/CanteenDatabaseImplement/Models/Lunch.cs
Normal file
22
Canteen/CanteenDatabaseImplement/Models/Lunch.cs
Normal file
@ -0,0 +1,22 @@
|
||||
using CanteenDataModels.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace CanteenDatabaseImplement.Models
|
||||
{
|
||||
public class Lunch : ILunchModel
|
||||
{
|
||||
public string LunchName => throw new NotImplementedException();
|
||||
|
||||
public double Cost => throw new NotImplementedException();
|
||||
|
||||
public int VisitorId => throw new NotImplementedException();
|
||||
|
||||
public Dictionary<int, (IProductModel, int)> LunchProducts => throw new NotImplementedException();
|
||||
|
||||
public int Id => throw new NotImplementedException();
|
||||
}
|
||||
}
|
12
Canteen/CanteenDatabaseImplement/Models/LunchOrder.cs
Normal file
12
Canteen/CanteenDatabaseImplement/Models/LunchOrder.cs
Normal file
@ -0,0 +1,12 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace CanteenDatabaseImplement.Models
|
||||
{
|
||||
public class LunchOrder
|
||||
{
|
||||
}
|
||||
}
|
12
Canteen/CanteenDatabaseImplement/Models/Manager.cs
Normal file
12
Canteen/CanteenDatabaseImplement/Models/Manager.cs
Normal file
@ -0,0 +1,12 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace CanteenDatabaseImplement.Models
|
||||
{
|
||||
public class Manager
|
||||
{
|
||||
}
|
||||
}
|
30
Canteen/CanteenDatabaseImplement/Models/Order.cs
Normal file
30
Canteen/CanteenDatabaseImplement/Models/Order.cs
Normal file
@ -0,0 +1,30 @@
|
||||
using CanteenDataModels.Enums;
|
||||
using CanteenDataModels.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace CanteenDatabaseImplement.Models
|
||||
{
|
||||
public class Order : IOrderModel
|
||||
{
|
||||
public int ClientId { get; private set; }
|
||||
|
||||
public double Sum { get; private set; }
|
||||
|
||||
public OrderStatus Status { get; private set; } = OrderStatus.Неизвестен;
|
||||
|
||||
public DateTime DateCreate { get; private set; } = DateTime.Now;
|
||||
|
||||
public DateTime? DateImplement { get; private set; }
|
||||
|
||||
public int Id { get; private set; }
|
||||
[ForeignKey("OrderId")]
|
||||
public virtual List<LunchOrder> LunchOrders { get; set; } = new();
|
||||
[ForeignKey("OrderId")]
|
||||
public virtual List<CookOrder> CookOrders { get; set; } = new();
|
||||
}
|
||||
}
|
90
Canteen/CanteenDatabaseImplement/Models/Product.cs
Normal file
90
Canteen/CanteenDatabaseImplement/Models/Product.cs
Normal file
@ -0,0 +1,90 @@
|
||||
using CanteenContracts.BindingModels;
|
||||
using CanteenContracts.View;
|
||||
using CanteenDataModels.Models;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
|
||||
namespace CanteenDatabaseImplement.Models
|
||||
{
|
||||
public class Product : IProductModel
|
||||
{
|
||||
[Required]
|
||||
public string ProductName { get; private set; } = string.Empty;
|
||||
[Required]
|
||||
public double Cost { get; private set; }
|
||||
[Required]
|
||||
public int ManagerId { get; private set; }
|
||||
|
||||
private Dictionary<int, ICookModel>? _productCooks = null;
|
||||
|
||||
public int Id { get; private set; }
|
||||
[NotMapped]
|
||||
public Dictionary<int, ICookModel> ProductCooks
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_productCooks == null)
|
||||
{
|
||||
_productCooks = Cooks.ToDictionary(record => record.CookId, record => record.Cook as ICookModel);
|
||||
}
|
||||
return _productCooks;
|
||||
}
|
||||
}
|
||||
[ForeignKey("ProductId")]
|
||||
public virtual List<ProductCook> Cooks { get; set; } = new();
|
||||
|
||||
[ForeignKey("ProductId")]
|
||||
public virtual List<Order> Lunches { get; set; } = new();
|
||||
public static Product? Create(CanteenDatabase context, ProductBindingModel model)
|
||||
{
|
||||
return new Product()
|
||||
{
|
||||
Id = model.Id,
|
||||
ProductName = model.ProductName,
|
||||
Cost = model.Cost,
|
||||
Cooks = model.ProductCooks.Select(x => new ProductCook
|
||||
{
|
||||
Cook = context.Cooks.First(y => y.Id == x.Key)
|
||||
}).ToList()
|
||||
};
|
||||
}
|
||||
|
||||
public void Update(ProductBindingModel model)
|
||||
{
|
||||
ProductName = model.ProductName;
|
||||
Cost = model.Cost;
|
||||
}
|
||||
|
||||
public ProductViewModel GetViewModel => new()
|
||||
{
|
||||
Id = Id,
|
||||
ProductName = ProductName,
|
||||
Cost = Cost,
|
||||
ProductCooks = ProductCooks,
|
||||
ManagerId = ManagerId
|
||||
};
|
||||
|
||||
public void UpdateCooks(CanteenDatabase context, ProductBindingModel model)
|
||||
{
|
||||
var productCooks = context.ProductCooks.Where(record => record.ProductId == model.Id).ToList();
|
||||
if (productCooks != null && productCooks.Count > 0)
|
||||
{
|
||||
context.ProductCooks.RemoveRange(productCooks.Where(record => !model.ProductCooks.ContainsKey(record.CookId)));
|
||||
context.SaveChanges();
|
||||
}
|
||||
|
||||
var product = context.Products.First(x => x.Id == Id);
|
||||
foreach (var pc in model.ProductCooks)
|
||||
{
|
||||
context.ProductCooks.Add(new ProductCook
|
||||
{
|
||||
Product = product,
|
||||
Cook = context.Cooks.First(x => x.Id == pc.Key),
|
||||
});
|
||||
context.SaveChanges();
|
||||
}
|
||||
|
||||
_productCooks = null;
|
||||
}
|
||||
}
|
||||
}
|
25
Canteen/CanteenDatabaseImplement/Models/ProductCook.cs
Normal file
25
Canteen/CanteenDatabaseImplement/Models/ProductCook.cs
Normal file
@ -0,0 +1,25 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace CanteenDatabaseImplement.Models
|
||||
{
|
||||
public class ProductCook
|
||||
{
|
||||
public int Id { get; set; }
|
||||
|
||||
[Required]
|
||||
public int ProductId { get; set; }
|
||||
|
||||
[Required]
|
||||
public int CookId { get; set; }
|
||||
|
||||
public virtual Product Product { get; set; } = new();
|
||||
|
||||
public virtual Cook Cook { get; set; } = new();
|
||||
}
|
||||
}
|
12
Canteen/CanteenDatabaseImplement/Models/ProductLunch.cs
Normal file
12
Canteen/CanteenDatabaseImplement/Models/ProductLunch.cs
Normal file
@ -0,0 +1,12 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace CanteenDatabaseImplement.Models
|
||||
{
|
||||
public class ProductLunch
|
||||
{
|
||||
}
|
||||
}
|
12
Canteen/CanteenDatabaseImplement/Models/Role.cs
Normal file
12
Canteen/CanteenDatabaseImplement/Models/Role.cs
Normal file
@ -0,0 +1,12 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace CanteenDatabaseImplement.Models
|
||||
{
|
||||
public class Role
|
||||
{
|
||||
}
|
||||
}
|
12
Canteen/CanteenDatabaseImplement/Models/Tableware.cs
Normal file
12
Canteen/CanteenDatabaseImplement/Models/Tableware.cs
Normal file
@ -0,0 +1,12 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace CanteenDatabaseImplement.Models
|
||||
{
|
||||
public class Tableware
|
||||
{
|
||||
}
|
||||
}
|
12
Canteen/CanteenDatabaseImplement/Models/Visitor.cs
Normal file
12
Canteen/CanteenDatabaseImplement/Models/Visitor.cs
Normal file
@ -0,0 +1,12 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace CanteenDatabaseImplement.Models
|
||||
{
|
||||
public class Visitor
|
||||
{
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user