ISEbd-21.Fedotov.I.A.LabWork06 #6
@ -0,0 +1,20 @@
|
|||||||
|
using DinerDataModels.Models;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace DinerContracts.BindingModels {
|
||||||
|
public class ImplementerBindingModel : IImplementerModel {
|
||||||
|
public string ImplementerFIO { get; set; } = string.Empty;
|
||||||
|
|
||||||
|
public string Password { get; set; } = string.Empty;
|
||||||
|
|
||||||
|
public int WorkExperience { get; set; }
|
||||||
|
|
||||||
|
public int Qualification { get; set; }
|
||||||
|
|
||||||
|
public int ID { get; set; }
|
||||||
|
}
|
||||||
|
}
|
@ -14,6 +14,8 @@ namespace DinerContracts.BindingModels
|
|||||||
|
|
||||||
public int ClientID { get; set; }
|
public int ClientID { get; set; }
|
||||||
|
|
||||||
|
public int? ImplementerID { get; set; }
|
||||||
|
|
||||||
public int Count { get; set; }
|
public int Count { get; set; }
|
||||||
|
|
||||||
public double Sum { get; set; }
|
public double Sum { get; set; }
|
||||||
@ -25,5 +27,7 @@ namespace DinerContracts.BindingModels
|
|||||||
public DateTime? DateImplement { get; set; }
|
public DateTime? DateImplement { get; set; }
|
||||||
|
|
||||||
public int ID { get; set; }
|
public int ID { get; set; }
|
||||||
|
|
||||||
|
public string ProductName { get; set; } = string.Empty;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,19 @@
|
|||||||
|
using DinerContracts.BindingModels;
|
||||||
|
using DinerContracts.SearchModels;
|
||||||
|
using DinerContracts.ViewModels;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace DinerContracts.BusinessLogicsContracts {
|
||||||
|
public interface IImplementerLogic {
|
||||||
|
List<ImplementerViewModel>? ReadList(ImplementerSearchModel? model);
|
||||||
|
ImplementerViewModel? ReadElement(ImplementerSearchModel model);
|
||||||
|
|
||||||
|
bool Create(ImplementerBindingModel model);
|
||||||
|
bool Update(ImplementerBindingModel model);
|
||||||
|
bool Delete(ImplementerBindingModel model);
|
||||||
|
}
|
||||||
|
}
|
@ -13,6 +13,8 @@ namespace DinerContracts.BusinessLogicsContacts
|
|||||||
{
|
{
|
||||||
List<OrderViewModel>? ReadList(OrderSearchModel? model);
|
List<OrderViewModel>? ReadList(OrderSearchModel? model);
|
||||||
|
|
||||||
|
OrderViewModel? ReadElement(OrderSearchModel model);
|
||||||
|
|
||||||
bool CreateOrder(OrderBindingModel model);
|
bool CreateOrder(OrderBindingModel model);
|
||||||
bool TakeOrderInWork(OrderBindingModel model);
|
bool TakeOrderInWork(OrderBindingModel model);
|
||||||
bool FinishOrder(OrderBindingModel model);
|
bool FinishOrder(OrderBindingModel model);
|
||||||
|
12
Diner/DinerContracts/BusinessLogicsContracts/IWorkProcess.cs
Normal file
12
Diner/DinerContracts/BusinessLogicsContracts/IWorkProcess.cs
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
using DinerContracts.BusinessLogicsContacts;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace DinerContracts.BusinessLogicsContracts {
|
||||||
|
public interface IWorkProcess {
|
||||||
|
void Work(IImplementerLogic implementerLogic, IOrderLogic orderLogic);
|
||||||
|
}
|
||||||
|
}
|
20
Diner/DinerContracts/SearchModels/ImplementerSearchModel.cs
Normal file
20
Diner/DinerContracts/SearchModels/ImplementerSearchModel.cs
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
using DinerDataModels.Models;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace DinerContracts.SearchModels {
|
||||||
|
public class ImplementerSearchModel {
|
||||||
|
public string? ImplementerFIO { get; set; }
|
||||||
|
|
||||||
|
public string? Password { get; set; }
|
||||||
|
|
||||||
|
public int? WorkExperience { get; set; }
|
||||||
|
|
||||||
|
public int? Qualification { get; set; }
|
||||||
|
|
||||||
|
public int? ID { get; set; }
|
||||||
|
}
|
||||||
|
}
|
@ -1,6 +1,8 @@
|
|||||||
using System;
|
using DinerDataModels.Enums;
|
||||||
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using System.Numerics;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
@ -11,6 +13,8 @@ namespace DinerContracts.SearchModels
|
|||||||
public int? ID { get; set; }
|
public int? ID { get; set; }
|
||||||
public DateTime? DateFrom { get; set; }
|
public DateTime? DateFrom { get; set; }
|
||||||
public int? ClientID { get; set; }
|
public int? ClientID { get; set; }
|
||||||
|
public int? ImplementerID { get; set; }
|
||||||
public DateTime? DateTo { get; set; }
|
public DateTime? DateTo { get; set; }
|
||||||
|
public OrderStatus Status { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,20 @@
|
|||||||
|
using DinerContracts.BindingModels;
|
||||||
|
using DinerContracts.SearchModels;
|
||||||
|
using DinerContracts.ViewModels;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace DinerContracts.StoragesContracts {
|
||||||
|
public interface IImplementerStorage {
|
||||||
|
List<ImplementerViewModel> GetFullList();
|
||||||
|
List<ImplementerViewModel> GetFilteredList(ImplementerSearchModel model);
|
||||||
|
|
||||||
|
ImplementerViewModel? GetElement(ImplementerSearchModel model);
|
||||||
|
ImplementerViewModel? Insert(ImplementerBindingModel model);
|
||||||
|
ImplementerViewModel? Update(ImplementerBindingModel model);
|
||||||
|
ImplementerViewModel? Delete(ImplementerBindingModel model);
|
||||||
|
}
|
||||||
|
}
|
26
Diner/DinerContracts/ViewModels/ImplementerViewModel.cs
Normal file
26
Diner/DinerContracts/ViewModels/ImplementerViewModel.cs
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
using DinerDataModels.Models;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.ComponentModel;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace DinerContracts.ViewModels {
|
||||||
|
public class ImplementerViewModel : IImplementerModel {
|
||||||
|
|
||||||
|
[DisplayName("ФИО исполнителя")]
|
||||||
|
public string ImplementerFIO { get; set; } = string.Empty;
|
||||||
|
|
||||||
|
[DisplayName("Пароль")]
|
||||||
|
public string Password { get; set; } = string.Empty;
|
||||||
|
|
||||||
|
[DisplayName("Стаж работы")]
|
||||||
|
public int WorkExperience { get; set; }
|
||||||
|
|
||||||
|
[DisplayName("Квалификация")]
|
||||||
|
public int Qualification { get; set; }
|
||||||
|
|
||||||
|
public int ID { get; set; }
|
||||||
|
}
|
||||||
|
}
|
@ -9,11 +9,11 @@ using System.Threading.Tasks;
|
|||||||
|
|
||||||
namespace DinerContracts.ViewModels
|
namespace DinerContracts.ViewModels
|
||||||
{
|
{
|
||||||
public class OrderViewModel : IOrderModel
|
public class OrderViewModel : IOrderModel {
|
||||||
{
|
|
||||||
|
|
||||||
public int ClientID { get; set; }
|
public int ClientID { get; set; }
|
||||||
public int SnackID { get; set; }
|
public int SnackID { get; set; }
|
||||||
|
public int? ImplementerID { get; set; }
|
||||||
|
|
||||||
[DisplayName("Количество")]
|
[DisplayName("Количество")]
|
||||||
public int Count { get; set; }
|
public int Count { get; set; }
|
||||||
@ -39,5 +39,8 @@ namespace DinerContracts.ViewModels
|
|||||||
|
|
||||||
[DisplayName("Клиент")]
|
[DisplayName("Клиент")]
|
||||||
public string ClientFIO { get; set; } = string.Empty;
|
public string ClientFIO { get; set; } = string.Empty;
|
||||||
|
|
||||||
|
[DisplayName("Исполнитель")]
|
||||||
|
public string? ImplementerFIO { get; set; } = string.Empty;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3,11 +3,11 @@ using Microsoft.EntityFrameworkCore;
|
|||||||
|
|
||||||
namespace DinerDataBaseImplement
|
namespace DinerDataBaseImplement
|
||||||
{
|
{
|
||||||
public class DinerDataBase : DbContext
|
public class DinerDatabaseBy6Work : DbContext
|
||||||
{
|
{
|
||||||
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) {
|
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) {
|
||||||
if (optionsBuilder.IsConfigured == false) {
|
if (optionsBuilder.IsConfigured == false) {
|
||||||
optionsBuilder.UseSqlServer(@"Data Source=DESKTOP-O0N00SH\SQLEXPRESS;Initial Catalog=DinerDatabase;Integrated Security=True;MultipleActiveResultSets=True;;TrustServerCertificate=True");
|
optionsBuilder.UseSqlServer(@"Data Source=DESKTOP-O0N00SH\SQLEXPRESS;Initial Catalog=DinerDatabaseBy6Work;Integrated Security=True;MultipleActiveResultSets=True;;TrustServerCertificate=True");
|
||||||
}
|
}
|
||||||
base.OnConfiguring(optionsBuilder);
|
base.OnConfiguring(optionsBuilder);
|
||||||
}
|
}
|
||||||
@ -16,5 +16,6 @@ namespace DinerDataBaseImplement
|
|||||||
public virtual DbSet<SnackFood> ProductComponents { get; set; }
|
public virtual DbSet<SnackFood> ProductComponents { get; set; }
|
||||||
public virtual DbSet<Order> Orders { get; set; }
|
public virtual DbSet<Order> Orders { get; set; }
|
||||||
public virtual DbSet<Client> Clients { get; set; }
|
public virtual DbSet<Client> Clients { get; set; }
|
||||||
|
public virtual DbSet<Implementer> Implementers { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -18,7 +18,7 @@ namespace DinerDataBaseImplement.Implements {
|
|||||||
if (newClient == null) {
|
if (newClient == null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
using var context = new DinerDataBase();
|
using var context = new DinerDatabaseBy6Work();
|
||||||
context.Clients.Add(newClient);
|
context.Clients.Add(newClient);
|
||||||
context.SaveChanges();
|
context.SaveChanges();
|
||||||
|
|
||||||
@ -29,7 +29,7 @@ namespace DinerDataBaseImplement.Implements {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public ClientViewModel? Update(ClientBindingModel model) {
|
public ClientViewModel? Update(ClientBindingModel model) {
|
||||||
using var context = new DinerDataBase();
|
using var context = new DinerDatabaseBy6Work();
|
||||||
var client = context.Clients.FirstOrDefault(x => x.ID == model.ID);
|
var client = context.Clients.FirstOrDefault(x => x.ID == model.ID);
|
||||||
if (client == null) {
|
if (client == null) {
|
||||||
return null;
|
return null;
|
||||||
@ -40,7 +40,7 @@ namespace DinerDataBaseImplement.Implements {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public ClientViewModel? Delete(ClientBindingModel model) {
|
public ClientViewModel? Delete(ClientBindingModel model) {
|
||||||
using var context = new DinerDataBase();
|
using var context = new DinerDatabaseBy6Work();
|
||||||
var element = context.Clients.FirstOrDefault(x => x.ID == model.ID);
|
var element = context.Clients.FirstOrDefault(x => x.ID == model.ID);
|
||||||
if (element != null) {
|
if (element != null) {
|
||||||
context.Clients.Remove(element);
|
context.Clients.Remove(element);
|
||||||
@ -51,7 +51,7 @@ namespace DinerDataBaseImplement.Implements {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public ClientViewModel? GetElement(ClientSearchModel model) {
|
public ClientViewModel? GetElement(ClientSearchModel model) {
|
||||||
using var context = new DinerDataBase();
|
using var context = new DinerDatabaseBy6Work();
|
||||||
if (model.ID.HasValue) {
|
if (model.ID.HasValue) {
|
||||||
return context.Clients
|
return context.Clients
|
||||||
.Include(x => x.Orders)
|
.Include(x => x.Orders)
|
||||||
@ -71,7 +71,7 @@ namespace DinerDataBaseImplement.Implements {
|
|||||||
if (string.IsNullOrEmpty(model.ClientFIO)) {
|
if (string.IsNullOrEmpty(model.ClientFIO)) {
|
||||||
return new();
|
return new();
|
||||||
}
|
}
|
||||||
using var context = new DinerDataBase();
|
using var context = new DinerDatabaseBy6Work();
|
||||||
|
|
||||||
return context.Clients
|
return context.Clients
|
||||||
.Include(x => x.Orders)
|
.Include(x => x.Orders)
|
||||||
@ -81,7 +81,7 @@ namespace DinerDataBaseImplement.Implements {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public List<ClientViewModel> GetFullList() {
|
public List<ClientViewModel> GetFullList() {
|
||||||
using var context = new DinerDataBase();
|
using var context = new DinerDatabaseBy6Work();
|
||||||
|
|
||||||
return context.Clients
|
return context.Clients
|
||||||
.Include(x => x.Orders)
|
.Include(x => x.Orders)
|
||||||
|
@ -16,7 +16,7 @@ namespace DinerDataBaseImplement.Implements
|
|||||||
{
|
{
|
||||||
public FoodViewModel? Delete(FoodBindingModel model)
|
public FoodViewModel? Delete(FoodBindingModel model)
|
||||||
{
|
{
|
||||||
using var context = new DinerDataBase();
|
using var context = new DinerDatabaseBy6Work();
|
||||||
var element = context.Components.FirstOrDefault(x => x.ID == model.ID);
|
var element = context.Components.FirstOrDefault(x => x.ID == model.ID);
|
||||||
if (element != null)
|
if (element != null)
|
||||||
{
|
{
|
||||||
@ -32,7 +32,7 @@ namespace DinerDataBaseImplement.Implements
|
|||||||
if (string.IsNullOrEmpty(model.ComponentName) && !model.ID.HasValue) {
|
if (string.IsNullOrEmpty(model.ComponentName) && !model.ID.HasValue) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
using var context = new DinerDataBase();
|
using var context = new DinerDatabaseBy6Work();
|
||||||
return context.Components
|
return context.Components
|
||||||
.FirstOrDefault(x => (!string.IsNullOrEmpty(model.ComponentName) &&
|
.FirstOrDefault(x => (!string.IsNullOrEmpty(model.ComponentName) &&
|
||||||
x.ComponentName == model.ComponentName) || model.ID.HasValue &&
|
x.ComponentName == model.ComponentName) || model.ID.HasValue &&
|
||||||
@ -45,7 +45,7 @@ namespace DinerDataBaseImplement.Implements
|
|||||||
return new();
|
return new();
|
||||||
|
|
||||||
}
|
}
|
||||||
using var context = new DinerDataBase();
|
using var context = new DinerDatabaseBy6Work();
|
||||||
return context.Components.Where(x => x.ComponentName.Contains(model.ComponentName))
|
return context.Components.Where(x => x.ComponentName.Contains(model.ComponentName))
|
||||||
.Select(x => x.GetViewModel).ToList();
|
.Select(x => x.GetViewModel).ToList();
|
||||||
|
|
||||||
@ -53,7 +53,7 @@ namespace DinerDataBaseImplement.Implements
|
|||||||
|
|
||||||
public List<FoodViewModel> GetFullList()
|
public List<FoodViewModel> GetFullList()
|
||||||
{
|
{
|
||||||
using var context = new DinerDataBase();
|
using var context = new DinerDatabaseBy6Work();
|
||||||
return context.Components.Select(x => x.GetViewModel).ToList();
|
return context.Components.Select(x => x.GetViewModel).ToList();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -63,7 +63,7 @@ namespace DinerDataBaseImplement.Implements
|
|||||||
if (newComponent == null) {
|
if (newComponent == null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
using var context = new DinerDataBase();
|
using var context = new DinerDatabaseBy6Work();
|
||||||
context.Components.Add(newComponent);
|
context.Components.Add(newComponent);
|
||||||
context.SaveChanges();
|
context.SaveChanges();
|
||||||
return newComponent.GetViewModel;
|
return newComponent.GetViewModel;
|
||||||
@ -71,7 +71,7 @@ namespace DinerDataBaseImplement.Implements
|
|||||||
|
|
||||||
public FoodViewModel? Update(FoodBindingModel model)
|
public FoodViewModel? Update(FoodBindingModel model)
|
||||||
{
|
{
|
||||||
using var context = new DinerDataBase();
|
using var context = new DinerDatabaseBy6Work();
|
||||||
var component = context.Components.FirstOrDefault(x => x.ID == model.ID);
|
var component = context.Components.FirstOrDefault(x => x.ID == model.ID);
|
||||||
if (component == null) {
|
if (component == null) {
|
||||||
return null;
|
return null;
|
||||||
|
@ -0,0 +1,89 @@
|
|||||||
|
using DinerContracts.BindingModels;
|
||||||
|
using DinerContracts.SearchModels;
|
||||||
|
using DinerContracts.StoragesContracts;
|
||||||
|
using DinerContracts.ViewModels;
|
||||||
|
using DinerDataBaseImplement.Models;
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Net.Http.Headers;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace DinerDataBaseImplement.Implements {
|
||||||
|
public class ImplementerStorage : IImplementerStorage {
|
||||||
|
|
||||||
|
public ImplementerViewModel? Insert(ImplementerBindingModel model) {
|
||||||
|
var newImplementer = Implementer.Create(model);
|
||||||
|
if (newImplementer == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
using var context = new DinerDatabaseBy6Work();
|
||||||
|
context.Implementers.Add(newImplementer);
|
||||||
|
context.SaveChanges();
|
||||||
|
|
||||||
|
return context.Implementers
|
||||||
|
.Include(x => x.Orders)
|
||||||
|
.FirstOrDefault(x => x.ID == newImplementer.ID)
|
||||||
|
?.GetViewModel;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ImplementerViewModel? Update(ImplementerBindingModel model) {
|
||||||
|
using var context = new DinerDatabaseBy6Work();
|
||||||
|
var implementer = context.Implementers.FirstOrDefault(x => x.ID == model.ID);
|
||||||
|
if (implementer == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
implementer.Update(model);
|
||||||
|
context.SaveChanges();
|
||||||
|
return implementer.GetViewModel;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ImplementerViewModel? Delete(ImplementerBindingModel model) {
|
||||||
|
using var context = new DinerDatabaseBy6Work();
|
||||||
|
var element = context.Implementers.FirstOrDefault(x => x.ID == model.ID);
|
||||||
|
if (element != null) {
|
||||||
|
context.Implementers.Remove(element);
|
||||||
|
context.SaveChanges();
|
||||||
|
return element.GetViewModel;
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ImplementerViewModel? GetElement(ImplementerSearchModel model) {
|
||||||
|
using var context = new DinerDatabaseBy6Work();
|
||||||
|
if (model.ID.HasValue) {
|
||||||
|
return context.Implementers
|
||||||
|
.Include(x => x.Orders)
|
||||||
|
.FirstOrDefault(x => model.ID.HasValue && x.ID == model.ID)
|
||||||
|
?.GetViewModel;
|
||||||
|
}
|
||||||
|
return new();
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<ImplementerViewModel> GetFilteredList(ImplementerSearchModel model) {
|
||||||
|
if (string.IsNullOrEmpty(model.ImplementerFIO)) {
|
||||||
|
return new();
|
||||||
|
}
|
||||||
|
using var context = new DinerDatabaseBy6Work();
|
||||||
|
|
||||||
|
return context.Implementers
|
||||||
|
.Include(x => x.Orders)
|
||||||
|
.Where(x => x.ImplementerFIO.Contains(model.ImplementerFIO))
|
||||||
|
.Select(x => x.GetViewModel)
|
||||||
|
.ToList();
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<ImplementerViewModel> GetFullList() {
|
||||||
|
using var context = new DinerDatabaseBy6Work();
|
||||||
|
|
||||||
|
return context.Implementers
|
||||||
|
.Include(x => x.Orders)
|
||||||
|
.Select(x => x.GetViewModel)
|
||||||
|
.ToList();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
@ -16,7 +16,7 @@ namespace DinerDataBaseImplement.Implements
|
|||||||
{
|
{
|
||||||
public OrderViewModel? Delete(OrderBindingModel model)
|
public OrderViewModel? Delete(OrderBindingModel model)
|
||||||
{
|
{
|
||||||
using var context = new DinerDataBase();
|
using var context = new DinerDatabaseBy6Work();
|
||||||
var element = context.Orders.FirstOrDefault(x => x.ID == model.ID);
|
var element = context.Orders.FirstOrDefault(x => x.ID == model.ID);
|
||||||
if (element != null)
|
if (element != null)
|
||||||
{
|
{
|
||||||
@ -32,21 +32,21 @@ namespace DinerDataBaseImplement.Implements
|
|||||||
if (!model.ID.HasValue) {
|
if (!model.ID.HasValue) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
using var context = new DinerDataBase();
|
using var context = new DinerDatabaseBy6Work();
|
||||||
return context.Orders
|
return context.Orders.Include(x => x.Snack)
|
||||||
.Include(x => x.Snack)
|
|
||||||
.Include(x => x.Client)
|
.Include(x => x.Client)
|
||||||
.FirstOrDefault(x => model.ID.HasValue && x.ID == model.ID)
|
.FirstOrDefault(x => model.ID.HasValue && x.ID == model.ID)?.GetViewModel;
|
||||||
?.GetViewModel;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<OrderViewModel> GetFilteredList(OrderSearchModel model)
|
public List<OrderViewModel> GetFilteredList(OrderSearchModel model)
|
||||||
{
|
{
|
||||||
using var context = new DinerDataBase();
|
using var context = new DinerDatabaseBy6Work();
|
||||||
if (!model.ID.HasValue && model.DateFrom.HasValue && model.DateTo.HasValue) {
|
if (!model.ID.HasValue && model.DateFrom.HasValue && model.DateTo.HasValue) {
|
||||||
return context.Orders
|
return context.Orders
|
||||||
.Include(x => x.Snack)
|
.Include(x => x.Snack)
|
||||||
.Include(x => x.Client)
|
.Include(x => x.Client)
|
||||||
|
.Include(x => x.Implementer)
|
||||||
.Where(x => x.DateCreate >= model.DateFrom && x.DateCreate <= model.DateTo)
|
.Where(x => x.DateCreate >= model.DateFrom && x.DateCreate <= model.DateTo)
|
||||||
.Select(x => x.GetViewModel)
|
.Select(x => x.GetViewModel)
|
||||||
.ToList();
|
.ToList();
|
||||||
@ -55,6 +55,7 @@ namespace DinerDataBaseImplement.Implements
|
|||||||
return context.Orders
|
return context.Orders
|
||||||
.Include(x => x.Snack)
|
.Include(x => x.Snack)
|
||||||
.Include(x => x.Client)
|
.Include(x => x.Client)
|
||||||
|
.Include(x => x.Implementer)
|
||||||
.Where(x => x.ID == model.ID)
|
.Where(x => x.ID == model.ID)
|
||||||
.Select(x => x.GetViewModel)
|
.Select(x => x.GetViewModel)
|
||||||
.ToList();
|
.ToList();
|
||||||
@ -63,21 +64,29 @@ namespace DinerDataBaseImplement.Implements
|
|||||||
return context.Orders
|
return context.Orders
|
||||||
.Include(x => x.Snack)
|
.Include(x => x.Snack)
|
||||||
.Include(x => x.Client)
|
.Include(x => x.Client)
|
||||||
|
.Include(x => x.Implementer)
|
||||||
.Where(x => x.ClientID == model.ClientID)
|
.Where(x => x.ClientID == model.ClientID)
|
||||||
.Select(x => x.GetViewModel)
|
.Select(x => x.GetViewModel)
|
||||||
.ToList();
|
.ToList();
|
||||||
}
|
}
|
||||||
return new();
|
return context.Orders
|
||||||
|
.Include(x => x.Snack)
|
||||||
|
.Include(x => x.Client)
|
||||||
|
.Include(x => x.Implementer)
|
||||||
|
.Where(x => model.Status == x.Status)
|
||||||
|
.Select(x => x.GetViewModel)
|
||||||
|
.ToList();
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<OrderViewModel> GetFullList()
|
public List<OrderViewModel> GetFullList()
|
||||||
{
|
{
|
||||||
using var context = new DinerDataBase();
|
using var context = new DinerDatabaseBy6Work();
|
||||||
return context.Orders.Include(x => x.Snack).Include(x => x.Client).Select(x => x.GetViewModel).ToList();
|
return context.Orders.Include(x => x.Snack).Include(x => x.Client).Include(x => x.Implementer)
|
||||||
|
.Select(x => x.GetViewModel).ToList();
|
||||||
}
|
}
|
||||||
public OrderViewModel? Insert(OrderBindingModel model)
|
public OrderViewModel? Insert(OrderBindingModel model)
|
||||||
{
|
{
|
||||||
using var context = new DinerDataBase();
|
using var context = new DinerDatabaseBy6Work();
|
||||||
var newOrder = Order.Create(model);
|
var newOrder = Order.Create(model);
|
||||||
if (newOrder == null) {
|
if (newOrder == null) {
|
||||||
return null;
|
return null;
|
||||||
@ -89,7 +98,7 @@ namespace DinerDataBaseImplement.Implements
|
|||||||
.FirstOrDefault(x => x.ID == newOrder.ID)?.GetViewModel;
|
.FirstOrDefault(x => x.ID == newOrder.ID)?.GetViewModel;
|
||||||
}
|
}
|
||||||
public OrderViewModel? Update(OrderBindingModel model) {
|
public OrderViewModel? Update(OrderBindingModel model) {
|
||||||
using var context = new DinerDataBase();
|
using var context = new DinerDatabaseBy6Work();
|
||||||
var order = context.Orders.FirstOrDefault(x => x.ID == model.ID);
|
var order = context.Orders.FirstOrDefault(x => x.ID == model.ID);
|
||||||
if (order == null) { return null; }
|
if (order == null) { return null; }
|
||||||
order.Update(model);
|
order.Update(model);
|
||||||
@ -97,6 +106,7 @@ namespace DinerDataBaseImplement.Implements
|
|||||||
return context.Orders
|
return context.Orders
|
||||||
.Include(x => x.Snack)
|
.Include(x => x.Snack)
|
||||||
.Include(x => x.Client)
|
.Include(x => x.Client)
|
||||||
|
.Include(x => x.Implementer)
|
||||||
.FirstOrDefault(x => x.ID == model.ID)?
|
.FirstOrDefault(x => x.ID == model.ID)?
|
||||||
.GetViewModel;
|
.GetViewModel;
|
||||||
}
|
}
|
||||||
|
@ -17,7 +17,7 @@ namespace DinerDataBaseImplement.Implements
|
|||||||
{
|
{
|
||||||
public SnackViewModel? Delete(SnackBindingModel model)
|
public SnackViewModel? Delete(SnackBindingModel model)
|
||||||
{
|
{
|
||||||
using var context = new DinerDataBase();
|
using var context = new DinerDatabaseBy6Work();
|
||||||
var element = context.Snacks
|
var element = context.Snacks
|
||||||
.Include(x => x.Components)
|
.Include(x => x.Components)
|
||||||
.Include(x => x.Orders)
|
.Include(x => x.Orders)
|
||||||
@ -36,7 +36,7 @@ namespace DinerDataBaseImplement.Implements
|
|||||||
if (string.IsNullOrEmpty(model.ProductName) && !model.ID.HasValue) {
|
if (string.IsNullOrEmpty(model.ProductName) && !model.ID.HasValue) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
using var context = new DinerDataBase();
|
using var context = new DinerDatabaseBy6Work();
|
||||||
return context.Snacks
|
return context.Snacks
|
||||||
.Include(x => x.Components)
|
.Include(x => x.Components)
|
||||||
.ThenInclude(x => x.Component)
|
.ThenInclude(x => x.Component)
|
||||||
@ -50,7 +50,7 @@ namespace DinerDataBaseImplement.Implements
|
|||||||
if (string.IsNullOrEmpty(model.ProductName)) {
|
if (string.IsNullOrEmpty(model.ProductName)) {
|
||||||
return new();
|
return new();
|
||||||
}
|
}
|
||||||
using var context = new DinerDataBase();
|
using var context = new DinerDatabaseBy6Work();
|
||||||
return context.Snacks
|
return context.Snacks
|
||||||
.Include(x => x.Components)
|
.Include(x => x.Components)
|
||||||
.ThenInclude(x => x.Component)
|
.ThenInclude(x => x.Component)
|
||||||
@ -61,7 +61,7 @@ namespace DinerDataBaseImplement.Implements
|
|||||||
|
|
||||||
public List<SnackViewModel> GetFullList()
|
public List<SnackViewModel> GetFullList()
|
||||||
{
|
{
|
||||||
using var context = new DinerDataBase();
|
using var context = new DinerDatabaseBy6Work();
|
||||||
return context.Snacks
|
return context.Snacks
|
||||||
.Include(x => x.Components)
|
.Include(x => x.Components)
|
||||||
.ThenInclude(x => x.Component).ToList()
|
.ThenInclude(x => x.Component).ToList()
|
||||||
@ -70,7 +70,7 @@ namespace DinerDataBaseImplement.Implements
|
|||||||
|
|
||||||
public SnackViewModel? Insert(SnackBindingModel model)
|
public SnackViewModel? Insert(SnackBindingModel model)
|
||||||
{
|
{
|
||||||
using var context = new DinerDataBase();
|
using var context = new DinerDatabaseBy6Work();
|
||||||
var newProduct = Snack.Create(context, model);
|
var newProduct = Snack.Create(context, model);
|
||||||
if (newProduct == null) {
|
if (newProduct == null) {
|
||||||
return null;
|
return null;
|
||||||
@ -82,7 +82,7 @@ namespace DinerDataBaseImplement.Implements
|
|||||||
|
|
||||||
public SnackViewModel? Update(SnackBindingModel model)
|
public SnackViewModel? Update(SnackBindingModel model)
|
||||||
{
|
{
|
||||||
using var context = new DinerDataBase();
|
using var context = new DinerDatabaseBy6Work();
|
||||||
using var transcation = context.Database.BeginTransaction();
|
using var transcation = context.Database.BeginTransaction();
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
260
Diner/DinerDataBaseImplement/Migrations/20240513154945_InitMigration.Designer.cs
generated
Normal file
260
Diner/DinerDataBaseImplement/Migrations/20240513154945_InitMigration.Designer.cs
generated
Normal file
@ -0,0 +1,260 @@
|
|||||||
|
// <auto-generated />
|
||||||
|
using System;
|
||||||
|
using DinerDataBaseImplement;
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||||
|
using Microsoft.EntityFrameworkCore.Metadata;
|
||||||
|
using Microsoft.EntityFrameworkCore.Migrations;
|
||||||
|
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||||
|
|
||||||
|
#nullable disable
|
||||||
|
|
||||||
|
namespace DinerDataBaseImplement.Migrations
|
||||||
|
{
|
||||||
|
[DbContext(typeof(DinerDatabaseBy6Work))]
|
||||||
|
[Migration("20240513154945_InitMigration")]
|
||||||
|
partial class InitMigration
|
||||||
|
{
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override void BuildTargetModel(ModelBuilder modelBuilder)
|
||||||
|
{
|
||||||
|
#pragma warning disable 612, 618
|
||||||
|
modelBuilder
|
||||||
|
.HasAnnotation("ProductVersion", "8.0.3")
|
||||||
|
.HasAnnotation("Relational:MaxIdentifierLength", 128);
|
||||||
|
|
||||||
|
SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder);
|
||||||
|
|
||||||
|
modelBuilder.Entity("DinerDataBaseImplement.Models.Client", b =>
|
||||||
|
{
|
||||||
|
b.Property<int>("ID")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("ID"));
|
||||||
|
|
||||||
|
b.Property<string>("ClientFIO")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("nvarchar(max)");
|
||||||
|
|
||||||
|
b.Property<string>("Email")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("nvarchar(max)");
|
||||||
|
|
||||||
|
b.Property<string>("Password")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("nvarchar(max)");
|
||||||
|
|
||||||
|
b.HasKey("ID");
|
||||||
|
|
||||||
|
b.ToTable("Clients");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("DinerDataBaseImplement.Models.Food", b =>
|
||||||
|
{
|
||||||
|
b.Property<int>("ID")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("ID"));
|
||||||
|
|
||||||
|
b.Property<string>("ComponentName")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("nvarchar(max)");
|
||||||
|
|
||||||
|
b.Property<double>("Price")
|
||||||
|
.HasColumnType("float");
|
||||||
|
|
||||||
|
b.HasKey("ID");
|
||||||
|
|
||||||
|
b.ToTable("Components");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("DinerDataBaseImplement.Models.Implementer", b =>
|
||||||
|
{
|
||||||
|
b.Property<int>("ID")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("ID"));
|
||||||
|
|
||||||
|
b.Property<string>("ImplementerFIO")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("nvarchar(max)");
|
||||||
|
|
||||||
|
b.Property<string>("Password")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("nvarchar(max)");
|
||||||
|
|
||||||
|
b.Property<int>("Qualification")
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
b.Property<int>("WorkExperience")
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
b.HasKey("ID");
|
||||||
|
|
||||||
|
b.ToTable("Implementers");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("DinerDataBaseImplement.Models.Order", b =>
|
||||||
|
{
|
||||||
|
b.Property<int>("ID")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("ID"));
|
||||||
|
|
||||||
|
b.Property<int>("ClientID")
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
b.Property<int>("Count")
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
b.Property<DateTime>("DateCreate")
|
||||||
|
.HasColumnType("datetime2");
|
||||||
|
|
||||||
|
b.Property<DateTime?>("DateImplement")
|
||||||
|
.HasColumnType("datetime2");
|
||||||
|
|
||||||
|
b.Property<int?>("ImplementerID")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
b.Property<int>("SnackID")
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
b.Property<int>("Status")
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
b.Property<double>("Sum")
|
||||||
|
.HasColumnType("float");
|
||||||
|
|
||||||
|
b.HasKey("ID");
|
||||||
|
|
||||||
|
b.HasIndex("ClientID");
|
||||||
|
|
||||||
|
b.HasIndex("ImplementerID");
|
||||||
|
|
||||||
|
b.HasIndex("SnackID");
|
||||||
|
|
||||||
|
b.ToTable("Orders");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("DinerDataBaseImplement.Models.Snack", b =>
|
||||||
|
{
|
||||||
|
b.Property<int>("ID")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("ID"));
|
||||||
|
|
||||||
|
b.Property<double>("Price")
|
||||||
|
.HasColumnType("float");
|
||||||
|
|
||||||
|
b.Property<string>("ProductName")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("nvarchar(max)");
|
||||||
|
|
||||||
|
b.HasKey("ID");
|
||||||
|
|
||||||
|
b.ToTable("Snacks");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("DinerDataBaseImplement.Models.SnackFood", b =>
|
||||||
|
{
|
||||||
|
b.Property<int>("ID")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("ID"));
|
||||||
|
|
||||||
|
b.Property<int>("ComponentID")
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
b.Property<int>("Count")
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
b.Property<int>("SnackID")
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
b.HasKey("ID");
|
||||||
|
|
||||||
|
b.HasIndex("ComponentID");
|
||||||
|
|
||||||
|
b.HasIndex("SnackID");
|
||||||
|
|
||||||
|
b.ToTable("ProductComponents");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("DinerDataBaseImplement.Models.Order", b =>
|
||||||
|
{
|
||||||
|
b.HasOne("DinerDataBaseImplement.Models.Client", "Client")
|
||||||
|
.WithMany("Orders")
|
||||||
|
.HasForeignKey("ClientID")
|
||||||
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
|
.IsRequired();
|
||||||
|
|
||||||
|
b.HasOne("DinerDataBaseImplement.Models.Implementer", "Implementer")
|
||||||
|
.WithMany("Orders")
|
||||||
|
.HasForeignKey("ImplementerID")
|
||||||
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
|
.IsRequired();
|
||||||
|
|
||||||
|
b.HasOne("DinerDataBaseImplement.Models.Snack", "Snack")
|
||||||
|
.WithMany("Orders")
|
||||||
|
.HasForeignKey("SnackID")
|
||||||
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
|
.IsRequired();
|
||||||
|
|
||||||
|
b.Navigation("Client");
|
||||||
|
|
||||||
|
b.Navigation("Implementer");
|
||||||
|
|
||||||
|
b.Navigation("Snack");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("DinerDataBaseImplement.Models.SnackFood", b =>
|
||||||
|
{
|
||||||
|
b.HasOne("DinerDataBaseImplement.Models.Food", "Component")
|
||||||
|
.WithMany("SnackFood")
|
||||||
|
.HasForeignKey("ComponentID")
|
||||||
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
|
.IsRequired();
|
||||||
|
|
||||||
|
b.HasOne("DinerDataBaseImplement.Models.Snack", "Product")
|
||||||
|
.WithMany("Components")
|
||||||
|
.HasForeignKey("SnackID")
|
||||||
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
|
.IsRequired();
|
||||||
|
|
||||||
|
b.Navigation("Component");
|
||||||
|
|
||||||
|
b.Navigation("Product");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("DinerDataBaseImplement.Models.Client", b =>
|
||||||
|
{
|
||||||
|
b.Navigation("Orders");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("DinerDataBaseImplement.Models.Food", b =>
|
||||||
|
{
|
||||||
|
b.Navigation("SnackFood");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("DinerDataBaseImplement.Models.Implementer", b =>
|
||||||
|
{
|
||||||
|
b.Navigation("Orders");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("DinerDataBaseImplement.Models.Snack", b =>
|
||||||
|
{
|
||||||
|
b.Navigation("Components");
|
||||||
|
|
||||||
|
b.Navigation("Orders");
|
||||||
|
});
|
||||||
|
#pragma warning restore 612, 618
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -40,6 +40,22 @@ namespace DinerDataBaseImplement.Migrations
|
|||||||
table.PrimaryKey("PK_Components", x => x.ID);
|
table.PrimaryKey("PK_Components", x => x.ID);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
migrationBuilder.CreateTable(
|
||||||
|
name: "Implementers",
|
||||||
|
columns: table => new
|
||||||
|
{
|
||||||
|
ID = table.Column<int>(type: "int", nullable: false)
|
||||||
|
.Annotation("SqlServer:Identity", "1, 1"),
|
||||||
|
ImplementerFIO = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
||||||
|
Password = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
||||||
|
WorkExperience = table.Column<int>(type: "int", nullable: false),
|
||||||
|
Qualification = table.Column<int>(type: "int", nullable: false)
|
||||||
|
},
|
||||||
|
constraints: table =>
|
||||||
|
{
|
||||||
|
table.PrimaryKey("PK_Implementers", x => x.ID);
|
||||||
|
});
|
||||||
|
|
||||||
migrationBuilder.CreateTable(
|
migrationBuilder.CreateTable(
|
||||||
name: "Snacks",
|
name: "Snacks",
|
||||||
columns: table => new
|
columns: table => new
|
||||||
@ -62,6 +78,7 @@ namespace DinerDataBaseImplement.Migrations
|
|||||||
.Annotation("SqlServer:Identity", "1, 1"),
|
.Annotation("SqlServer:Identity", "1, 1"),
|
||||||
SnackID = table.Column<int>(type: "int", nullable: false),
|
SnackID = table.Column<int>(type: "int", nullable: false),
|
||||||
ClientID = table.Column<int>(type: "int", nullable: false),
|
ClientID = table.Column<int>(type: "int", nullable: false),
|
||||||
|
ImplementerID = table.Column<int>(type: "int", nullable: false),
|
||||||
Count = table.Column<int>(type: "int", nullable: false),
|
Count = table.Column<int>(type: "int", nullable: false),
|
||||||
Sum = table.Column<double>(type: "float", nullable: false),
|
Sum = table.Column<double>(type: "float", nullable: false),
|
||||||
Status = table.Column<int>(type: "int", nullable: false),
|
Status = table.Column<int>(type: "int", nullable: false),
|
||||||
@ -77,6 +94,12 @@ namespace DinerDataBaseImplement.Migrations
|
|||||||
principalTable: "Clients",
|
principalTable: "Clients",
|
||||||
principalColumn: "ID",
|
principalColumn: "ID",
|
||||||
onDelete: ReferentialAction.Cascade);
|
onDelete: ReferentialAction.Cascade);
|
||||||
|
table.ForeignKey(
|
||||||
|
name: "FK_Orders_Implementers_ImplementerID",
|
||||||
|
column: x => x.ImplementerID,
|
||||||
|
principalTable: "Implementers",
|
||||||
|
principalColumn: "ID",
|
||||||
|
onDelete: ReferentialAction.Cascade);
|
||||||
table.ForeignKey(
|
table.ForeignKey(
|
||||||
name: "FK_Orders_Snacks_SnackID",
|
name: "FK_Orders_Snacks_SnackID",
|
||||||
column: x => x.SnackID,
|
column: x => x.SnackID,
|
||||||
@ -117,6 +140,11 @@ namespace DinerDataBaseImplement.Migrations
|
|||||||
table: "Orders",
|
table: "Orders",
|
||||||
column: "ClientID");
|
column: "ClientID");
|
||||||
|
|
||||||
|
migrationBuilder.CreateIndex(
|
||||||
|
name: "IX_Orders_ImplementerID",
|
||||||
|
table: "Orders",
|
||||||
|
column: "ImplementerID");
|
||||||
|
|
||||||
migrationBuilder.CreateIndex(
|
migrationBuilder.CreateIndex(
|
||||||
name: "IX_Orders_SnackID",
|
name: "IX_Orders_SnackID",
|
||||||
table: "Orders",
|
table: "Orders",
|
||||||
@ -145,6 +173,9 @@ namespace DinerDataBaseImplement.Migrations
|
|||||||
migrationBuilder.DropTable(
|
migrationBuilder.DropTable(
|
||||||
name: "Clients");
|
name: "Clients");
|
||||||
|
|
||||||
|
migrationBuilder.DropTable(
|
||||||
|
name: "Implementers");
|
||||||
|
|
||||||
migrationBuilder.DropTable(
|
migrationBuilder.DropTable(
|
||||||
name: "Components");
|
name: "Components");
|
||||||
|
|
@ -11,9 +11,9 @@ using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
|||||||
|
|
||||||
namespace DinerDataBaseImplement.Migrations
|
namespace DinerDataBaseImplement.Migrations
|
||||||
{
|
{
|
||||||
[DbContext(typeof(DinerDataBase))]
|
[DbContext(typeof(DinerDatabaseBy6Work))]
|
||||||
[Migration("20240511111831_InitMigration")]
|
[Migration("20240513162929_Migration01")]
|
||||||
partial class InitMigration
|
partial class Migration01
|
||||||
{
|
{
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
protected override void BuildTargetModel(ModelBuilder modelBuilder)
|
protected override void BuildTargetModel(ModelBuilder modelBuilder)
|
||||||
@ -70,6 +70,33 @@ namespace DinerDataBaseImplement.Migrations
|
|||||||
b.ToTable("Components");
|
b.ToTable("Components");
|
||||||
});
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("DinerDataBaseImplement.Models.Implementer", b =>
|
||||||
|
{
|
||||||
|
b.Property<int>("ID")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("ID"));
|
||||||
|
|
||||||
|
b.Property<string>("ImplementerFIO")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("nvarchar(max)");
|
||||||
|
|
||||||
|
b.Property<string>("Password")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("nvarchar(max)");
|
||||||
|
|
||||||
|
b.Property<int>("Qualification")
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
b.Property<int>("WorkExperience")
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
b.HasKey("ID");
|
||||||
|
|
||||||
|
b.ToTable("Implementers");
|
||||||
|
});
|
||||||
|
|
||||||
modelBuilder.Entity("DinerDataBaseImplement.Models.Order", b =>
|
modelBuilder.Entity("DinerDataBaseImplement.Models.Order", b =>
|
||||||
{
|
{
|
||||||
b.Property<int>("ID")
|
b.Property<int>("ID")
|
||||||
@ -90,6 +117,9 @@ namespace DinerDataBaseImplement.Migrations
|
|||||||
b.Property<DateTime?>("DateImplement")
|
b.Property<DateTime?>("DateImplement")
|
||||||
.HasColumnType("datetime2");
|
.HasColumnType("datetime2");
|
||||||
|
|
||||||
|
b.Property<int?>("ImplementerID")
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
b.Property<int>("SnackID")
|
b.Property<int>("SnackID")
|
||||||
.HasColumnType("int");
|
.HasColumnType("int");
|
||||||
|
|
||||||
@ -103,6 +133,8 @@ namespace DinerDataBaseImplement.Migrations
|
|||||||
|
|
||||||
b.HasIndex("ClientID");
|
b.HasIndex("ClientID");
|
||||||
|
|
||||||
|
b.HasIndex("ImplementerID");
|
||||||
|
|
||||||
b.HasIndex("SnackID");
|
b.HasIndex("SnackID");
|
||||||
|
|
||||||
b.ToTable("Orders");
|
b.ToTable("Orders");
|
||||||
@ -162,6 +194,10 @@ namespace DinerDataBaseImplement.Migrations
|
|||||||
.OnDelete(DeleteBehavior.Cascade)
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
.IsRequired();
|
.IsRequired();
|
||||||
|
|
||||||
|
b.HasOne("DinerDataBaseImplement.Models.Implementer", "Implementer")
|
||||||
|
.WithMany("Orders")
|
||||||
|
.HasForeignKey("ImplementerID");
|
||||||
|
|
||||||
b.HasOne("DinerDataBaseImplement.Models.Snack", "Snack")
|
b.HasOne("DinerDataBaseImplement.Models.Snack", "Snack")
|
||||||
.WithMany("Orders")
|
.WithMany("Orders")
|
||||||
.HasForeignKey("SnackID")
|
.HasForeignKey("SnackID")
|
||||||
@ -170,6 +206,8 @@ namespace DinerDataBaseImplement.Migrations
|
|||||||
|
|
||||||
b.Navigation("Client");
|
b.Navigation("Client");
|
||||||
|
|
||||||
|
b.Navigation("Implementer");
|
||||||
|
|
||||||
b.Navigation("Snack");
|
b.Navigation("Snack");
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -202,6 +240,11 @@ namespace DinerDataBaseImplement.Migrations
|
|||||||
b.Navigation("SnackFood");
|
b.Navigation("SnackFood");
|
||||||
});
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("DinerDataBaseImplement.Models.Implementer", b =>
|
||||||
|
{
|
||||||
|
b.Navigation("Orders");
|
||||||
|
});
|
||||||
|
|
||||||
modelBuilder.Entity("DinerDataBaseImplement.Models.Snack", b =>
|
modelBuilder.Entity("DinerDataBaseImplement.Models.Snack", b =>
|
||||||
{
|
{
|
||||||
b.Navigation("Components");
|
b.Navigation("Components");
|
@ -0,0 +1,59 @@
|
|||||||
|
using Microsoft.EntityFrameworkCore.Migrations;
|
||||||
|
|
||||||
|
#nullable disable
|
||||||
|
|
||||||
|
namespace DinerDataBaseImplement.Migrations
|
||||||
|
{
|
||||||
|
/// <inheritdoc />
|
||||||
|
public partial class Migration01 : Migration
|
||||||
|
{
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override void Up(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
migrationBuilder.DropForeignKey(
|
||||||
|
name: "FK_Orders_Implementers_ImplementerID",
|
||||||
|
table: "Orders");
|
||||||
|
|
||||||
|
migrationBuilder.AlterColumn<int>(
|
||||||
|
name: "ImplementerID",
|
||||||
|
table: "Orders",
|
||||||
|
type: "int",
|
||||||
|
nullable: true,
|
||||||
|
oldClrType: typeof(int),
|
||||||
|
oldType: "int");
|
||||||
|
|
||||||
|
migrationBuilder.AddForeignKey(
|
||||||
|
name: "FK_Orders_Implementers_ImplementerID",
|
||||||
|
table: "Orders",
|
||||||
|
column: "ImplementerID",
|
||||||
|
principalTable: "Implementers",
|
||||||
|
principalColumn: "ID");
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override void Down(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
migrationBuilder.DropForeignKey(
|
||||||
|
name: "FK_Orders_Implementers_ImplementerID",
|
||||||
|
table: "Orders");
|
||||||
|
|
||||||
|
migrationBuilder.AlterColumn<int>(
|
||||||
|
name: "ImplementerID",
|
||||||
|
table: "Orders",
|
||||||
|
type: "int",
|
||||||
|
nullable: false,
|
||||||
|
defaultValue: 0,
|
||||||
|
oldClrType: typeof(int),
|
||||||
|
oldType: "int",
|
||||||
|
oldNullable: true);
|
||||||
|
|
||||||
|
migrationBuilder.AddForeignKey(
|
||||||
|
name: "FK_Orders_Implementers_ImplementerID",
|
||||||
|
table: "Orders",
|
||||||
|
column: "ImplementerID",
|
||||||
|
principalTable: "Implementers",
|
||||||
|
principalColumn: "ID",
|
||||||
|
onDelete: ReferentialAction.Cascade);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
261
Diner/DinerDataBaseImplement/Migrations/20240515115440_Migration02.Designer.cs
generated
Normal file
261
Diner/DinerDataBaseImplement/Migrations/20240515115440_Migration02.Designer.cs
generated
Normal file
@ -0,0 +1,261 @@
|
|||||||
|
// <auto-generated />
|
||||||
|
using System;
|
||||||
|
using DinerDataBaseImplement;
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||||
|
using Microsoft.EntityFrameworkCore.Metadata;
|
||||||
|
using Microsoft.EntityFrameworkCore.Migrations;
|
||||||
|
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||||
|
|
||||||
|
#nullable disable
|
||||||
|
|
||||||
|
namespace DinerDataBaseImplement.Migrations
|
||||||
|
{
|
||||||
|
[DbContext(typeof(DinerDatabaseBy6Work))]
|
||||||
|
[Migration("20240515115440_Migration02")]
|
||||||
|
partial class Migration02
|
||||||
|
{
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override void BuildTargetModel(ModelBuilder modelBuilder)
|
||||||
|
{
|
||||||
|
#pragma warning disable 612, 618
|
||||||
|
modelBuilder
|
||||||
|
.HasAnnotation("ProductVersion", "8.0.3")
|
||||||
|
.HasAnnotation("Relational:MaxIdentifierLength", 128);
|
||||||
|
|
||||||
|
SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder);
|
||||||
|
|
||||||
|
modelBuilder.Entity("DinerDataBaseImplement.Models.Client", b =>
|
||||||
|
{
|
||||||
|
b.Property<int>("ID")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("ID"));
|
||||||
|
|
||||||
|
b.Property<string>("ClientFIO")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("nvarchar(max)");
|
||||||
|
|
||||||
|
b.Property<string>("Email")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("nvarchar(max)");
|
||||||
|
|
||||||
|
b.Property<string>("Password")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("nvarchar(max)");
|
||||||
|
|
||||||
|
b.HasKey("ID");
|
||||||
|
|
||||||
|
b.ToTable("Clients");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("DinerDataBaseImplement.Models.Food", b =>
|
||||||
|
{
|
||||||
|
b.Property<int>("ID")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("ID"));
|
||||||
|
|
||||||
|
b.Property<string>("ComponentName")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("nvarchar(max)");
|
||||||
|
|
||||||
|
b.Property<double>("Price")
|
||||||
|
.HasColumnType("float");
|
||||||
|
|
||||||
|
b.HasKey("ID");
|
||||||
|
|
||||||
|
b.ToTable("Components");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("DinerDataBaseImplement.Models.Implementer", b =>
|
||||||
|
{
|
||||||
|
b.Property<int>("ID")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("ID"));
|
||||||
|
|
||||||
|
b.Property<string>("ImplementerFIO")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("nvarchar(max)");
|
||||||
|
|
||||||
|
b.Property<string>("Password")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("nvarchar(max)");
|
||||||
|
|
||||||
|
b.Property<int>("Qualification")
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
b.Property<int>("WorkExperience")
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
b.HasKey("ID");
|
||||||
|
|
||||||
|
b.ToTable("Implementers");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("DinerDataBaseImplement.Models.Order", b =>
|
||||||
|
{
|
||||||
|
b.Property<int>("ID")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("ID"));
|
||||||
|
|
||||||
|
b.Property<int>("ClientID")
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
b.Property<int>("Count")
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
b.Property<DateTime>("DateCreate")
|
||||||
|
.HasColumnType("datetime2");
|
||||||
|
|
||||||
|
b.Property<DateTime?>("DateImplement")
|
||||||
|
.HasColumnType("datetime2");
|
||||||
|
|
||||||
|
b.Property<int?>("ImplementerID")
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
b.Property<string>("ProductName")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("nvarchar(max)");
|
||||||
|
|
||||||
|
b.Property<int>("SnackID")
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
b.Property<int>("Status")
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
b.Property<double>("Sum")
|
||||||
|
.HasColumnType("float");
|
||||||
|
|
||||||
|
b.HasKey("ID");
|
||||||
|
|
||||||
|
b.HasIndex("ClientID");
|
||||||
|
|
||||||
|
b.HasIndex("ImplementerID");
|
||||||
|
|
||||||
|
b.HasIndex("SnackID");
|
||||||
|
|
||||||
|
b.ToTable("Orders");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("DinerDataBaseImplement.Models.Snack", b =>
|
||||||
|
{
|
||||||
|
b.Property<int>("ID")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("ID"));
|
||||||
|
|
||||||
|
b.Property<double>("Price")
|
||||||
|
.HasColumnType("float");
|
||||||
|
|
||||||
|
b.Property<string>("ProductName")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("nvarchar(max)");
|
||||||
|
|
||||||
|
b.HasKey("ID");
|
||||||
|
|
||||||
|
b.ToTable("Snacks");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("DinerDataBaseImplement.Models.SnackFood", b =>
|
||||||
|
{
|
||||||
|
b.Property<int>("ID")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("ID"));
|
||||||
|
|
||||||
|
b.Property<int>("ComponentID")
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
b.Property<int>("Count")
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
b.Property<int>("SnackID")
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
b.HasKey("ID");
|
||||||
|
|
||||||
|
b.HasIndex("ComponentID");
|
||||||
|
|
||||||
|
b.HasIndex("SnackID");
|
||||||
|
|
||||||
|
b.ToTable("ProductComponents");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("DinerDataBaseImplement.Models.Order", b =>
|
||||||
|
{
|
||||||
|
b.HasOne("DinerDataBaseImplement.Models.Client", "Client")
|
||||||
|
.WithMany("Orders")
|
||||||
|
.HasForeignKey("ClientID")
|
||||||
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
|
.IsRequired();
|
||||||
|
|
||||||
|
b.HasOne("DinerDataBaseImplement.Models.Implementer", "Implementer")
|
||||||
|
.WithMany("Orders")
|
||||||
|
.HasForeignKey("ImplementerID");
|
||||||
|
|
||||||
|
b.HasOne("DinerDataBaseImplement.Models.Snack", "Snack")
|
||||||
|
.WithMany("Orders")
|
||||||
|
.HasForeignKey("SnackID")
|
||||||
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
|
.IsRequired();
|
||||||
|
|
||||||
|
b.Navigation("Client");
|
||||||
|
|
||||||
|
b.Navigation("Implementer");
|
||||||
|
|
||||||
|
b.Navigation("Snack");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("DinerDataBaseImplement.Models.SnackFood", b =>
|
||||||
|
{
|
||||||
|
b.HasOne("DinerDataBaseImplement.Models.Food", "Component")
|
||||||
|
.WithMany("SnackFood")
|
||||||
|
.HasForeignKey("ComponentID")
|
||||||
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
|
.IsRequired();
|
||||||
|
|
||||||
|
b.HasOne("DinerDataBaseImplement.Models.Snack", "Product")
|
||||||
|
.WithMany("Components")
|
||||||
|
.HasForeignKey("SnackID")
|
||||||
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
|
.IsRequired();
|
||||||
|
|
||||||
|
b.Navigation("Component");
|
||||||
|
|
||||||
|
b.Navigation("Product");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("DinerDataBaseImplement.Models.Client", b =>
|
||||||
|
{
|
||||||
|
b.Navigation("Orders");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("DinerDataBaseImplement.Models.Food", b =>
|
||||||
|
{
|
||||||
|
b.Navigation("SnackFood");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("DinerDataBaseImplement.Models.Implementer", b =>
|
||||||
|
{
|
||||||
|
b.Navigation("Orders");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("DinerDataBaseImplement.Models.Snack", b =>
|
||||||
|
{
|
||||||
|
b.Navigation("Components");
|
||||||
|
|
||||||
|
b.Navigation("Orders");
|
||||||
|
});
|
||||||
|
#pragma warning restore 612, 618
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,29 @@
|
|||||||
|
using Microsoft.EntityFrameworkCore.Migrations;
|
||||||
|
|
||||||
|
#nullable disable
|
||||||
|
|
||||||
|
namespace DinerDataBaseImplement.Migrations
|
||||||
|
{
|
||||||
|
/// <inheritdoc />
|
||||||
|
public partial class Migration02 : Migration
|
||||||
|
{
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override void Up(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
migrationBuilder.AddColumn<string>(
|
||||||
|
name: "ProductName",
|
||||||
|
table: "Orders",
|
||||||
|
type: "nvarchar(max)",
|
||||||
|
nullable: false,
|
||||||
|
defaultValue: "");
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override void Down(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
migrationBuilder.DropColumn(
|
||||||
|
name: "ProductName",
|
||||||
|
table: "Orders");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
257
Diner/DinerDataBaseImplement/Migrations/20240515121617_Migration03.Designer.cs
generated
Normal file
257
Diner/DinerDataBaseImplement/Migrations/20240515121617_Migration03.Designer.cs
generated
Normal file
@ -0,0 +1,257 @@
|
|||||||
|
// <auto-generated />
|
||||||
|
using System;
|
||||||
|
using DinerDataBaseImplement;
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||||
|
using Microsoft.EntityFrameworkCore.Metadata;
|
||||||
|
using Microsoft.EntityFrameworkCore.Migrations;
|
||||||
|
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||||
|
|
||||||
|
#nullable disable
|
||||||
|
|
||||||
|
namespace DinerDataBaseImplement.Migrations
|
||||||
|
{
|
||||||
|
[DbContext(typeof(DinerDatabaseBy6Work))]
|
||||||
|
[Migration("20240515121617_Migration03")]
|
||||||
|
partial class Migration03
|
||||||
|
{
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override void BuildTargetModel(ModelBuilder modelBuilder)
|
||||||
|
{
|
||||||
|
#pragma warning disable 612, 618
|
||||||
|
modelBuilder
|
||||||
|
.HasAnnotation("ProductVersion", "8.0.3")
|
||||||
|
.HasAnnotation("Relational:MaxIdentifierLength", 128);
|
||||||
|
|
||||||
|
SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder);
|
||||||
|
|
||||||
|
modelBuilder.Entity("DinerDataBaseImplement.Models.Client", b =>
|
||||||
|
{
|
||||||
|
b.Property<int>("ID")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("ID"));
|
||||||
|
|
||||||
|
b.Property<string>("ClientFIO")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("nvarchar(max)");
|
||||||
|
|
||||||
|
b.Property<string>("Email")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("nvarchar(max)");
|
||||||
|
|
||||||
|
b.Property<string>("Password")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("nvarchar(max)");
|
||||||
|
|
||||||
|
b.HasKey("ID");
|
||||||
|
|
||||||
|
b.ToTable("Clients");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("DinerDataBaseImplement.Models.Food", b =>
|
||||||
|
{
|
||||||
|
b.Property<int>("ID")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("ID"));
|
||||||
|
|
||||||
|
b.Property<string>("ComponentName")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("nvarchar(max)");
|
||||||
|
|
||||||
|
b.Property<double>("Price")
|
||||||
|
.HasColumnType("float");
|
||||||
|
|
||||||
|
b.HasKey("ID");
|
||||||
|
|
||||||
|
b.ToTable("Components");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("DinerDataBaseImplement.Models.Implementer", b =>
|
||||||
|
{
|
||||||
|
b.Property<int>("ID")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("ID"));
|
||||||
|
|
||||||
|
b.Property<string>("ImplementerFIO")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("nvarchar(max)");
|
||||||
|
|
||||||
|
b.Property<string>("Password")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("nvarchar(max)");
|
||||||
|
|
||||||
|
b.Property<int>("Qualification")
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
b.Property<int>("WorkExperience")
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
b.HasKey("ID");
|
||||||
|
|
||||||
|
b.ToTable("Implementers");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("DinerDataBaseImplement.Models.Order", b =>
|
||||||
|
{
|
||||||
|
b.Property<int>("ID")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("ID"));
|
||||||
|
|
||||||
|
b.Property<int>("ClientID")
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
b.Property<int>("Count")
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
b.Property<DateTime>("DateCreate")
|
||||||
|
.HasColumnType("datetime2");
|
||||||
|
|
||||||
|
b.Property<DateTime?>("DateImplement")
|
||||||
|
.HasColumnType("datetime2");
|
||||||
|
|
||||||
|
b.Property<int?>("ImplementerID")
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
b.Property<int>("SnackID")
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
b.Property<int>("Status")
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
b.Property<double>("Sum")
|
||||||
|
.HasColumnType("float");
|
||||||
|
|
||||||
|
b.HasKey("ID");
|
||||||
|
|
||||||
|
b.HasIndex("ClientID");
|
||||||
|
|
||||||
|
b.HasIndex("ImplementerID");
|
||||||
|
|
||||||
|
b.HasIndex("SnackID");
|
||||||
|
|
||||||
|
b.ToTable("Orders");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("DinerDataBaseImplement.Models.Snack", b =>
|
||||||
|
{
|
||||||
|
b.Property<int>("ID")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("ID"));
|
||||||
|
|
||||||
|
b.Property<double>("Price")
|
||||||
|
.HasColumnType("float");
|
||||||
|
|
||||||
|
b.Property<string>("ProductName")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("nvarchar(max)");
|
||||||
|
|
||||||
|
b.HasKey("ID");
|
||||||
|
|
||||||
|
b.ToTable("Snacks");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("DinerDataBaseImplement.Models.SnackFood", b =>
|
||||||
|
{
|
||||||
|
b.Property<int>("ID")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("ID"));
|
||||||
|
|
||||||
|
b.Property<int>("ComponentID")
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
b.Property<int>("Count")
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
b.Property<int>("SnackID")
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
b.HasKey("ID");
|
||||||
|
|
||||||
|
b.HasIndex("ComponentID");
|
||||||
|
|
||||||
|
b.HasIndex("SnackID");
|
||||||
|
|
||||||
|
b.ToTable("ProductComponents");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("DinerDataBaseImplement.Models.Order", b =>
|
||||||
|
{
|
||||||
|
b.HasOne("DinerDataBaseImplement.Models.Client", "Client")
|
||||||
|
.WithMany("Orders")
|
||||||
|
.HasForeignKey("ClientID")
|
||||||
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
|
.IsRequired();
|
||||||
|
|
||||||
|
b.HasOne("DinerDataBaseImplement.Models.Implementer", "Implementer")
|
||||||
|
.WithMany("Orders")
|
||||||
|
.HasForeignKey("ImplementerID");
|
||||||
|
|
||||||
|
b.HasOne("DinerDataBaseImplement.Models.Snack", "Snack")
|
||||||
|
.WithMany("Orders")
|
||||||
|
.HasForeignKey("SnackID")
|
||||||
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
|
.IsRequired();
|
||||||
|
|
||||||
|
b.Navigation("Client");
|
||||||
|
|
||||||
|
b.Navigation("Implementer");
|
||||||
|
|
||||||
|
b.Navigation("Snack");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("DinerDataBaseImplement.Models.SnackFood", b =>
|
||||||
|
{
|
||||||
|
b.HasOne("DinerDataBaseImplement.Models.Food", "Component")
|
||||||
|
.WithMany("SnackFood")
|
||||||
|
.HasForeignKey("ComponentID")
|
||||||
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
|
.IsRequired();
|
||||||
|
|
||||||
|
b.HasOne("DinerDataBaseImplement.Models.Snack", "Product")
|
||||||
|
.WithMany("Components")
|
||||||
|
.HasForeignKey("SnackID")
|
||||||
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
|
.IsRequired();
|
||||||
|
|
||||||
|
b.Navigation("Component");
|
||||||
|
|
||||||
|
b.Navigation("Product");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("DinerDataBaseImplement.Models.Client", b =>
|
||||||
|
{
|
||||||
|
b.Navigation("Orders");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("DinerDataBaseImplement.Models.Food", b =>
|
||||||
|
{
|
||||||
|
b.Navigation("SnackFood");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("DinerDataBaseImplement.Models.Implementer", b =>
|
||||||
|
{
|
||||||
|
b.Navigation("Orders");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("DinerDataBaseImplement.Models.Snack", b =>
|
||||||
|
{
|
||||||
|
b.Navigation("Components");
|
||||||
|
|
||||||
|
b.Navigation("Orders");
|
||||||
|
});
|
||||||
|
#pragma warning restore 612, 618
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,29 @@
|
|||||||
|
using Microsoft.EntityFrameworkCore.Migrations;
|
||||||
|
|
||||||
|
#nullable disable
|
||||||
|
|
||||||
|
namespace DinerDataBaseImplement.Migrations
|
||||||
|
{
|
||||||
|
/// <inheritdoc />
|
||||||
|
public partial class Migration03 : Migration
|
||||||
|
{
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override void Up(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
migrationBuilder.DropColumn(
|
||||||
|
name: "ProductName",
|
||||||
|
table: "Orders");
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override void Down(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
migrationBuilder.AddColumn<string>(
|
||||||
|
name: "ProductName",
|
||||||
|
table: "Orders",
|
||||||
|
type: "nvarchar(max)",
|
||||||
|
nullable: false,
|
||||||
|
defaultValue: "");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -10,8 +10,8 @@ using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
|||||||
|
|
||||||
namespace DinerDataBaseImplement.Migrations
|
namespace DinerDataBaseImplement.Migrations
|
||||||
{
|
{
|
||||||
[DbContext(typeof(DinerDataBase))]
|
[DbContext(typeof(DinerDatabaseBy6Work))]
|
||||||
partial class DinerDataBaseModelSnapshot : ModelSnapshot
|
partial class DinerDatabaseBy6WorkModelSnapshot : ModelSnapshot
|
||||||
{
|
{
|
||||||
protected override void BuildModel(ModelBuilder modelBuilder)
|
protected override void BuildModel(ModelBuilder modelBuilder)
|
||||||
{
|
{
|
||||||
@ -67,6 +67,33 @@ namespace DinerDataBaseImplement.Migrations
|
|||||||
b.ToTable("Components");
|
b.ToTable("Components");
|
||||||
});
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("DinerDataBaseImplement.Models.Implementer", b =>
|
||||||
|
{
|
||||||
|
b.Property<int>("ID")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("ID"));
|
||||||
|
|
||||||
|
b.Property<string>("ImplementerFIO")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("nvarchar(max)");
|
||||||
|
|
||||||
|
b.Property<string>("Password")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("nvarchar(max)");
|
||||||
|
|
||||||
|
b.Property<int>("Qualification")
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
b.Property<int>("WorkExperience")
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
b.HasKey("ID");
|
||||||
|
|
||||||
|
b.ToTable("Implementers");
|
||||||
|
});
|
||||||
|
|
||||||
modelBuilder.Entity("DinerDataBaseImplement.Models.Order", b =>
|
modelBuilder.Entity("DinerDataBaseImplement.Models.Order", b =>
|
||||||
{
|
{
|
||||||
b.Property<int>("ID")
|
b.Property<int>("ID")
|
||||||
@ -87,6 +114,9 @@ namespace DinerDataBaseImplement.Migrations
|
|||||||
b.Property<DateTime?>("DateImplement")
|
b.Property<DateTime?>("DateImplement")
|
||||||
.HasColumnType("datetime2");
|
.HasColumnType("datetime2");
|
||||||
|
|
||||||
|
b.Property<int?>("ImplementerID")
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
b.Property<int>("SnackID")
|
b.Property<int>("SnackID")
|
||||||
.HasColumnType("int");
|
.HasColumnType("int");
|
||||||
|
|
||||||
@ -100,6 +130,8 @@ namespace DinerDataBaseImplement.Migrations
|
|||||||
|
|
||||||
b.HasIndex("ClientID");
|
b.HasIndex("ClientID");
|
||||||
|
|
||||||
|
b.HasIndex("ImplementerID");
|
||||||
|
|
||||||
b.HasIndex("SnackID");
|
b.HasIndex("SnackID");
|
||||||
|
|
||||||
b.ToTable("Orders");
|
b.ToTable("Orders");
|
||||||
@ -159,6 +191,10 @@ namespace DinerDataBaseImplement.Migrations
|
|||||||
.OnDelete(DeleteBehavior.Cascade)
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
.IsRequired();
|
.IsRequired();
|
||||||
|
|
||||||
|
b.HasOne("DinerDataBaseImplement.Models.Implementer", "Implementer")
|
||||||
|
.WithMany("Orders")
|
||||||
|
.HasForeignKey("ImplementerID");
|
||||||
|
|
||||||
b.HasOne("DinerDataBaseImplement.Models.Snack", "Snack")
|
b.HasOne("DinerDataBaseImplement.Models.Snack", "Snack")
|
||||||
.WithMany("Orders")
|
.WithMany("Orders")
|
||||||
.HasForeignKey("SnackID")
|
.HasForeignKey("SnackID")
|
||||||
@ -167,6 +203,8 @@ namespace DinerDataBaseImplement.Migrations
|
|||||||
|
|
||||||
b.Navigation("Client");
|
b.Navigation("Client");
|
||||||
|
|
||||||
|
b.Navigation("Implementer");
|
||||||
|
|
||||||
b.Navigation("Snack");
|
b.Navigation("Snack");
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -199,6 +237,11 @@ namespace DinerDataBaseImplement.Migrations
|
|||||||
b.Navigation("SnackFood");
|
b.Navigation("SnackFood");
|
||||||
});
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("DinerDataBaseImplement.Models.Implementer", b =>
|
||||||
|
{
|
||||||
|
b.Navigation("Orders");
|
||||||
|
});
|
||||||
|
|
||||||
modelBuilder.Entity("DinerDataBaseImplement.Models.Snack", b =>
|
modelBuilder.Entity("DinerDataBaseImplement.Models.Snack", b =>
|
||||||
{
|
{
|
||||||
b.Navigation("Components");
|
b.Navigation("Components");
|
62
Diner/DinerDataBaseImplement/Models/Implementer.cs
Normal file
62
Diner/DinerDataBaseImplement/Models/Implementer.cs
Normal file
@ -0,0 +1,62 @@
|
|||||||
|
using DinerContracts.BindingModels;
|
||||||
|
using DinerContracts.ViewModels;
|
||||||
|
using DinerDataModels.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 DinerDataBaseImplement.Models {
|
||||||
|
public class Implementer : IImplementerModel {
|
||||||
|
|
||||||
|
[Required]
|
||||||
|
public string ImplementerFIO { get; set; } = string.Empty;
|
||||||
|
|
||||||
|
[Required]
|
||||||
|
public string Password { get; set; } = string.Empty;
|
||||||
|
|
||||||
|
[Required]
|
||||||
|
public int WorkExperience { get; set; }
|
||||||
|
|
||||||
|
[Required]
|
||||||
|
public int Qualification { get; set; }
|
||||||
|
|
||||||
|
public int ID { get; set; }
|
||||||
|
|
||||||
|
[ForeignKey("ImplementerID")]
|
||||||
|
public virtual List<Order> Orders { get; set; } = new();
|
||||||
|
|
||||||
|
public static Implementer? Create(ImplementerBindingModel? model) {
|
||||||
|
if (model == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return new Implementer() {
|
||||||
|
ImplementerFIO = model.ImplementerFIO,
|
||||||
|
Password = model.Password,
|
||||||
|
WorkExperience = model.WorkExperience,
|
||||||
|
Qualification = model.Qualification,
|
||||||
|
ID = model.ID
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Update(ImplementerBindingModel? model) {
|
||||||
|
if (model == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
ImplementerFIO = model.ImplementerFIO;
|
||||||
|
Password = model.Password;
|
||||||
|
Qualification = model.Qualification;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ImplementerViewModel GetViewModel => new() {
|
||||||
|
ImplementerFIO = ImplementerFIO,
|
||||||
|
Password = Password,
|
||||||
|
WorkExperience = WorkExperience,
|
||||||
|
Qualification = Qualification,
|
||||||
|
ID = ID
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
@ -1,21 +1,25 @@
|
|||||||
using DinerContracts.BindingModels;
|
using DinerContracts.BindingModels;
|
||||||
using DinerContracts.ViewModels;
|
using DinerContracts.ViewModels;
|
||||||
using DinerDataBaseImplement.Implements;
|
using DinerDataBaseImplement.Implements;
|
||||||
|
using DinerDataBaseImplement.Migrations;
|
||||||
using DinerDataModels.Enums;
|
using DinerDataModels.Enums;
|
||||||
using DinerDataModels.Models;
|
using DinerDataModels.Models;
|
||||||
using System.ComponentModel.DataAnnotations;
|
using System.ComponentModel.DataAnnotations;
|
||||||
|
using System.ComponentModel.DataAnnotations.Schema;
|
||||||
|
using System.Net.Http.Headers;
|
||||||
using System.Xml.Linq;
|
using System.Xml.Linq;
|
||||||
|
|
||||||
namespace DinerDataBaseImplement.Models
|
namespace DinerDataBaseImplement.Models
|
||||||
{
|
{
|
||||||
public class Order : IOrderModel
|
public class Order : IOrderModel
|
||||||
{
|
{
|
||||||
[Required]
|
[ForeignKey("SnackID")]
|
||||||
public int SnackID { get; set; }
|
public int SnackID { get; set; }
|
||||||
|
|
||||||
[Required]
|
[Required]
|
||||||
public int ClientID { get; set; }
|
public int ClientID { get; set; }
|
||||||
|
|
||||||
|
public int? ImplementerID { get; set; }
|
||||||
[Required]
|
[Required]
|
||||||
public int Count { get; set; }
|
public int Count { get; set; }
|
||||||
|
|
||||||
@ -34,8 +38,9 @@ namespace DinerDataBaseImplement.Models
|
|||||||
|
|
||||||
public virtual Snack Snack { get; set; }
|
public virtual Snack Snack { get; set; }
|
||||||
public virtual Client Client { get; set; }
|
public virtual Client Client { get; set; }
|
||||||
|
public virtual Implementer? Implementer { get; set; }
|
||||||
|
|
||||||
public static Order? Create(OrderBindingModel? model)
|
public static Order? Create(OrderBindingModel model)
|
||||||
{
|
{
|
||||||
if (model == null) return null;
|
if (model == null) return null;
|
||||||
return new Order()
|
return new Order()
|
||||||
@ -47,18 +52,21 @@ namespace DinerDataBaseImplement.Models
|
|||||||
Status = model.Status,
|
Status = model.Status,
|
||||||
DateCreate = model.DateCreate,
|
DateCreate = model.DateCreate,
|
||||||
DateImplement = model.DateImplement,
|
DateImplement = model.DateImplement,
|
||||||
ClientID = model.ClientID
|
ClientID = model.ClientID,
|
||||||
|
ImplementerID = model.ImplementerID,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
public void Update(OrderBindingModel? model)
|
public void Update(OrderBindingModel? model)
|
||||||
{
|
{
|
||||||
if (model == null) return;
|
if (model == null) return;
|
||||||
|
if (model.Sum != 0) {
|
||||||
Sum = model.Sum;
|
Sum = model.Sum;
|
||||||
|
}
|
||||||
Status = model.Status;
|
Status = model.Status;
|
||||||
DateImplement = model?.DateImplement;
|
DateImplement = model?.DateImplement;
|
||||||
|
ImplementerID = model?.ImplementerID;
|
||||||
}
|
}
|
||||||
public OrderViewModel GetViewModel => new()
|
public OrderViewModel GetViewModel => new() {
|
||||||
{
|
|
||||||
ID = ID,
|
ID = ID,
|
||||||
SnackID = SnackID,
|
SnackID = SnackID,
|
||||||
Count = Count,
|
Count = Count,
|
||||||
@ -66,10 +74,12 @@ namespace DinerDataBaseImplement.Models
|
|||||||
Status = Status,
|
Status = Status,
|
||||||
DateCreate = DateCreate,
|
DateCreate = DateCreate,
|
||||||
DateImplement = DateImplement,
|
DateImplement = DateImplement,
|
||||||
ProductName = Snack.ProductName,
|
|
||||||
ClientID = ClientID,
|
ClientID = ClientID,
|
||||||
ClientFIO = Client.ClientFIO
|
ImplementerID = ImplementerID,
|
||||||
|
ClientFIO = Client.ClientFIO,
|
||||||
|
ImplementerFIO = Implementer?.ImplementerFIO,
|
||||||
|
ProductName = Snack.ProductName
|
||||||
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -44,7 +44,7 @@ namespace DinerDataBaseImplement.Models
|
|||||||
|
|
||||||
[ForeignKey("SnackID")]
|
[ForeignKey("SnackID")]
|
||||||
public virtual List<Order> Orders { get; set; } = new();
|
public virtual List<Order> Orders { get; set; } = new();
|
||||||
public static Snack? Create(DinerDataBase context,SnackBindingModel model)
|
public static Snack? Create(DinerDatabaseBy6Work context,SnackBindingModel model)
|
||||||
{
|
{
|
||||||
return new Snack()
|
return new Snack()
|
||||||
{
|
{
|
||||||
@ -72,7 +72,7 @@ namespace DinerDataBaseImplement.Models
|
|||||||
ProductComponents = ProductComponents
|
ProductComponents = ProductComponents
|
||||||
};
|
};
|
||||||
|
|
||||||
public void UpdateComponents(DinerDataBase context, SnackBindingModel model) {
|
public void UpdateComponents(DinerDatabaseBy6Work context, SnackBindingModel model) {
|
||||||
var productComponents = context.ProductComponents.Where(rec => rec.SnackID == model.ID).ToList();
|
var productComponents = context.ProductComponents.Where(rec => rec.SnackID == model.ID).ToList();
|
||||||
if (ProductComponents != null && ProductComponents.Count > 0) {
|
if (ProductComponents != null && ProductComponents.Count > 0) {
|
||||||
context.ProductComponents.RemoveRange(productComponents.Where(rec => !model.ProductComponents.ContainsKey(rec.ComponentID)));
|
context.ProductComponents.RemoveRange(productComponents.Where(rec => !model.ProductComponents.ContainsKey(rec.ComponentID)));
|
||||||
|
14
Diner/DinerDataModels/Models/IImplementerModel.cs
Normal file
14
Diner/DinerDataModels/Models/IImplementerModel.cs
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace DinerDataModels.Models {
|
||||||
|
public interface IImplementerModel : IID {
|
||||||
|
string ImplementerFIO { get; }
|
||||||
|
string Password { get; }
|
||||||
|
int WorkExperience { get; }
|
||||||
|
int Qualification { get; }
|
||||||
|
}
|
||||||
|
}
|
@ -11,6 +11,8 @@ namespace DinerDataModels.Models
|
|||||||
{
|
{
|
||||||
int SnackID { get; }
|
int SnackID { get; }
|
||||||
int Count { get; }
|
int Count { get; }
|
||||||
|
int ClientID { get; }
|
||||||
|
int? ImplementerID { get; }
|
||||||
double Sum { get; }
|
double Sum { get; }
|
||||||
OrderStatus Status { get; }
|
OrderStatus Status { get; }
|
||||||
DateTime DateCreate { get; }
|
DateTime DateCreate { get; }
|
||||||
|
@ -15,12 +15,14 @@ namespace DinerListImplement
|
|||||||
public List<Snack> Snacks { get; set; }
|
public List<Snack> Snacks { get; set; }
|
||||||
public List<Order> Orders { get; set; }
|
public List<Order> Orders { get; set; }
|
||||||
public List<Client> Clients { get; set; }
|
public List<Client> Clients { get; set; }
|
||||||
|
public List<Implementer> Implementers { get; set; }
|
||||||
|
|
||||||
private DataListSingleton() {
|
private DataListSingleton() {
|
||||||
Foods = new List<Food>();
|
Foods = new List<Food>();
|
||||||
Snacks = new List<Snack>();
|
Snacks = new List<Snack>();
|
||||||
Orders = new List<Order>();
|
Orders = new List<Order>();
|
||||||
Clients = new List<Client>();
|
Clients = new List<Client>();
|
||||||
|
Implementers = new List<Implementer>();
|
||||||
}
|
}
|
||||||
public static DataListSingleton GetInstance() {
|
public static DataListSingleton GetInstance() {
|
||||||
if (_instance == null) _instance = new DataListSingleton();
|
if (_instance == null) _instance = new DataListSingleton();
|
||||||
|
@ -22,7 +22,7 @@ namespace DinerListImplement.Implements {
|
|||||||
model.ID = 1;
|
model.ID = 1;
|
||||||
foreach (var client in _source.Clients) {
|
foreach (var client in _source.Clients) {
|
||||||
if (model.ID <= client.ID) {
|
if (model.ID <= client.ID) {
|
||||||
model.ID = client.ID;
|
model.ID = client.ID + 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
var newClient = Client.Create(model);
|
var newClient = Client.Create(model);
|
||||||
|
95
Diner/DinerListImplement/Implements/ImplementerStorage.cs
Normal file
95
Diner/DinerListImplement/Implements/ImplementerStorage.cs
Normal file
@ -0,0 +1,95 @@
|
|||||||
|
using DinerContracts.BindingModels;
|
||||||
|
using DinerContracts.BusinessLogicsContracts;
|
||||||
|
using DinerContracts.SearchModels;
|
||||||
|
using DinerContracts.StoragesContracts;
|
||||||
|
using DinerContracts.ViewModels;
|
||||||
|
using DinerListImplement.Models;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace DinerListImplement.Implements {
|
||||||
|
public class ImplementerStorage : IImplementerStorage {
|
||||||
|
|
||||||
|
private readonly DataListSingleton _source;
|
||||||
|
|
||||||
|
public ImplementerStorage() {
|
||||||
|
_source = DataListSingleton.GetInstance();
|
||||||
|
}
|
||||||
|
|
||||||
|
public ImplementerViewModel? Insert(ImplementerBindingModel model) {
|
||||||
|
model.ID = 1;
|
||||||
|
foreach (var implementer in _source.Implementers) {
|
||||||
|
if (model.ID <= implementer.ID) {
|
||||||
|
model.ID = implementer.ID + 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
var newImplementer = Implementer.Create(model);
|
||||||
|
if (newImplementer == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
_source.Implementers.Add(newImplementer);
|
||||||
|
return newImplementer.GetViewModel;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ImplementerViewModel? Update(ImplementerBindingModel model) {
|
||||||
|
foreach (var implementer in _source.Implementers) {
|
||||||
|
if (implementer.ID == model.ID) {
|
||||||
|
implementer.Update(model);
|
||||||
|
return implementer.GetViewModel;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ImplementerViewModel? Delete(ImplementerBindingModel model) {
|
||||||
|
for (int i = 0; i < _source.Implementers.Count; ++i) {
|
||||||
|
if (_source.Implementers[i].ID == model.ID) {
|
||||||
|
var element = _source.Implementers[i];
|
||||||
|
_source.Implementers.RemoveAt(i);
|
||||||
|
return element.GetViewModel;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ImplementerViewModel? GetElement(ImplementerSearchModel model) {
|
||||||
|
if (string.IsNullOrEmpty(model.ImplementerFIO) && !model.ID.HasValue) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
foreach (var implementer in _source.Implementers) {
|
||||||
|
if ((!string.IsNullOrEmpty(model.ImplementerFIO) &&
|
||||||
|
implementer.ImplementerFIO == model.ImplementerFIO) ||
|
||||||
|
(model.ID.HasValue && implementer.ID == model.ID)) {
|
||||||
|
return implementer.GetViewModel;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<ImplementerViewModel> GetFilteredList(ImplementerSearchModel model) {
|
||||||
|
var result = new List<ImplementerViewModel>();
|
||||||
|
if (string.IsNullOrEmpty(model.ImplementerFIO)) {
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
foreach (var implementer in _source.Implementers) {
|
||||||
|
if (implementer.ImplementerFIO.Contains(model.ImplementerFIO)) {
|
||||||
|
result.Add(implementer.GetViewModel);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<ImplementerViewModel> GetFullList() {
|
||||||
|
var result = new List<ImplementerViewModel>();
|
||||||
|
foreach (var implementer in _source.Implementers) {
|
||||||
|
result.Add(implementer.GetViewModel);
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
50
Diner/DinerListImplement/Models/Implementer.cs
Normal file
50
Diner/DinerListImplement/Models/Implementer.cs
Normal file
@ -0,0 +1,50 @@
|
|||||||
|
using DinerContracts.BindingModels;
|
||||||
|
using DinerContracts.ViewModels;
|
||||||
|
using DinerDataModels.Models;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace DinerListImplement.Models {
|
||||||
|
public class Implementer : IImplementerModel {
|
||||||
|
public string ImplementerFIO { get; private set; } = string.Empty;
|
||||||
|
|
||||||
|
public string Password { get; private set; } = string.Empty;
|
||||||
|
|
||||||
|
public int WorkExperience { get; private set; }
|
||||||
|
|
||||||
|
public int Qualification { get; private set; }
|
||||||
|
|
||||||
|
public int ID { get; set; }
|
||||||
|
|
||||||
|
public static Implementer? Create(ImplementerBindingModel? model) {
|
||||||
|
if (model == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return new Implementer() {
|
||||||
|
ImplementerFIO = model.ImplementerFIO,
|
||||||
|
Password = model.Password,
|
||||||
|
WorkExperience = model.WorkExperience,
|
||||||
|
Qualification = model.Qualification,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
public void Update(ImplementerBindingModel? model) {
|
||||||
|
if (model == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
ImplementerFIO = model.ImplementerFIO;
|
||||||
|
Password = model.Password;
|
||||||
|
Qualification = model.Qualification;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ImplementerViewModel GetViewModel => new() {
|
||||||
|
ImplementerFIO = ImplementerFIO,
|
||||||
|
Password = Password,
|
||||||
|
WorkExperience = WorkExperience,
|
||||||
|
Qualification = Qualification,
|
||||||
|
ID = ID
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
@ -14,6 +14,10 @@ namespace DinerListImplement.Models
|
|||||||
{
|
{
|
||||||
public int SnackID { get; private set; }
|
public int SnackID { get; private set; }
|
||||||
|
|
||||||
|
public int ClientID { get; private set; }
|
||||||
|
|
||||||
|
public int? ImplementerID { get; private set; }
|
||||||
|
|
||||||
public int Count { get; set; }
|
public int Count { get; set; }
|
||||||
|
|
||||||
public double Sum { get; private set; }
|
public double Sum { get; private set; }
|
||||||
@ -26,6 +30,12 @@ namespace DinerListImplement.Models
|
|||||||
|
|
||||||
public int ID { get; private set; }
|
public int ID { get; private set; }
|
||||||
|
|
||||||
|
public string? ProductName { get; private set; }
|
||||||
|
|
||||||
|
public string? ClientFIO { get; private set; }
|
||||||
|
|
||||||
|
public string? ImplementerFIO { get; private set; }
|
||||||
|
|
||||||
public static Order? Create(OrderBindingModel? model) {
|
public static Order? Create(OrderBindingModel? model) {
|
||||||
if (model == null) return null;
|
if (model == null) return null;
|
||||||
return new Order()
|
return new Order()
|
||||||
@ -37,6 +47,8 @@ namespace DinerListImplement.Models
|
|||||||
Status = model.Status,
|
Status = model.Status,
|
||||||
DateCreate = model.DateCreate,
|
DateCreate = model.DateCreate,
|
||||||
DateImplement = model.DateImplement,
|
DateImplement = model.DateImplement,
|
||||||
|
ClientID = model.ClientID,
|
||||||
|
ImplementerID = model.ImplementerID,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
public void Update(OrderBindingModel? model) {
|
public void Update(OrderBindingModel? model) {
|
||||||
@ -52,7 +64,12 @@ namespace DinerListImplement.Models
|
|||||||
Sum = Sum,
|
Sum = Sum,
|
||||||
Status = Status,
|
Status = Status,
|
||||||
DateCreate = DateCreate,
|
DateCreate = DateCreate,
|
||||||
DateImplement = DateImplement
|
DateImplement = DateImplement,
|
||||||
|
ClientID = ClientID,
|
||||||
|
ImplementerID = ImplementerID,
|
||||||
|
ProductName = ProductName,
|
||||||
|
ClientFIO = ClientFIO,
|
||||||
|
ImplementerFIO = ImplementerFIO
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -4,6 +4,7 @@ using DinerContracts.BusinessLogicsContracts;
|
|||||||
using DinerContracts.StoragesContracts;
|
using DinerContracts.StoragesContracts;
|
||||||
using DinerDataBaseImplement.Implements;
|
using DinerDataBaseImplement.Implements;
|
||||||
using DineryBusinessLogic.BusinessLogic;
|
using DineryBusinessLogic.BusinessLogic;
|
||||||
|
using DocumentFormat.OpenXml.VariantTypes;
|
||||||
using Microsoft.OpenApi.Models;
|
using Microsoft.OpenApi.Models;
|
||||||
|
|
||||||
namespace DinerRestAPI {
|
namespace DinerRestAPI {
|
||||||
@ -17,10 +18,12 @@ namespace DinerRestAPI {
|
|||||||
builder.Services.AddTransient<IOrderStorage, OrderStorage>();
|
builder.Services.AddTransient<IOrderStorage, OrderStorage>();
|
||||||
builder.Services.AddTransient<ISnackStorage, SnackStorage>();
|
builder.Services.AddTransient<ISnackStorage, SnackStorage>();
|
||||||
builder.Services.AddTransient<IClientStorage, ClientStorage>();
|
builder.Services.AddTransient<IClientStorage, ClientStorage>();
|
||||||
|
builder.Services.AddTransient<IImplementerStorage, ImplementerStorage>();
|
||||||
|
|
||||||
builder.Services.AddTransient<IOrderLogic, OrderLogic>();
|
builder.Services.AddTransient<IOrderLogic, OrderLogic>();
|
||||||
builder.Services.AddTransient<ISnackLogic, SnackLogic>();
|
builder.Services.AddTransient<ISnackLogic, SnackLogic>();
|
||||||
builder.Services.AddTransient<IClientLogic, ClientLogic>();
|
builder.Services.AddTransient<IClientLogic, ClientLogic>();
|
||||||
|
builder.Services.AddTransient<IImplementerLogic, ImplementerLogic>();
|
||||||
|
|
||||||
// Add services to the container.
|
// Add services to the container.
|
||||||
|
|
||||||
|
89
Diner/DinerRestApi/Controllers/ImplementerController.cs
Normal file
89
Diner/DinerRestApi/Controllers/ImplementerController.cs
Normal file
@ -0,0 +1,89 @@
|
|||||||
|
using DinerContracts.BindingModels;
|
||||||
|
using DinerContracts.BusinessLogicsContacts;
|
||||||
|
using DinerContracts.BusinessLogicsContracts;
|
||||||
|
using DinerContracts.SearchModels;
|
||||||
|
using DinerContracts.ViewModels;
|
||||||
|
using DinerDataModels.Enums;
|
||||||
|
using DocumentFormat.OpenXml.Office2010.PowerPoint;
|
||||||
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
|
||||||
|
namespace DinerRestApi.Controllers {
|
||||||
|
|
||||||
|
[Route("api/[controller]/[action]")]
|
||||||
|
[ApiController]
|
||||||
|
|
||||||
|
public class ImplementerController : Controller {
|
||||||
|
|
||||||
|
private readonly ILogger _logger;
|
||||||
|
private readonly IOrderLogic _order;
|
||||||
|
private readonly IImplementerLogic _logic;
|
||||||
|
|
||||||
|
public ImplementerController(ILogger<ImplementerController> logger, IOrderLogic order, IImplementerLogic implementerLogic) {
|
||||||
|
_logger = logger;
|
||||||
|
_order = order;
|
||||||
|
_logic = implementerLogic;
|
||||||
|
}
|
||||||
|
|
||||||
|
[HttpGet]
|
||||||
|
public ImplementerViewModel? Login(string login, string password) {
|
||||||
|
try {
|
||||||
|
return _logic.ReadElement(new ImplementerSearchModel {
|
||||||
|
ImplementerFIO = login,
|
||||||
|
Password = password
|
||||||
|
});
|
||||||
|
}
|
||||||
|
catch (Exception ex) {
|
||||||
|
_logger.LogError(ex, "Ошибка авторизации сотрудников");
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[HttpGet]
|
||||||
|
public List<OrderViewModel>? GetNewOrderss() {
|
||||||
|
try {
|
||||||
|
return _order.ReadList(new OrderSearchModel {
|
||||||
|
Status = OrderStatus.Принят
|
||||||
|
});
|
||||||
|
}
|
||||||
|
catch (Exception ex) {
|
||||||
|
_logger.LogError(ex, "Ошибка получения новых заказов");
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[HttpGet]
|
||||||
|
public OrderViewModel? GetImplementerOrder(int implementerID) {
|
||||||
|
try {
|
||||||
|
return _order.ReadElement(new OrderSearchModel {
|
||||||
|
ImplementerID = implementerID
|
||||||
|
});
|
||||||
|
}
|
||||||
|
catch (Exception ex) {
|
||||||
|
_logger.LogError(ex, "Ошибка получения текущего заказа исполнителя");
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[HttpPost]
|
||||||
|
public void TakeOrderInWork(OrderBindingModel model) {
|
||||||
|
try {
|
||||||
|
_order.TakeOrderInWork(model);
|
||||||
|
}
|
||||||
|
catch (Exception ex) {
|
||||||
|
_logger.LogError(ex, $"Ошибка перевода заказа с №{model.ID} в работу");
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[HttpPost]
|
||||||
|
public void FinishOrder(OrderBindingModel model) {
|
||||||
|
try {
|
||||||
|
_order.FinishOrder(model);
|
||||||
|
}
|
||||||
|
catch (Exception ex) {
|
||||||
|
_logger.LogError(ex, $"Ошибка отметки о готовности заказа с №{model.ID}");
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -20,16 +20,20 @@ namespace DinerFileImplement
|
|||||||
|
|
||||||
private readonly string ClientFileName = "Client.xml";
|
private readonly string ClientFileName = "Client.xml";
|
||||||
|
|
||||||
|
private readonly string ImplementerFileName = "Implementer.xml";
|
||||||
|
|
||||||
public List<Food> Foods { get; set; }
|
public List<Food> Foods { get; set; }
|
||||||
public List<Order> Orders { get; private set; }
|
public List<Order> Orders { get; private set; }
|
||||||
public List<Snack> Snacks { get; private set; }
|
public List<Snack> Snacks { get; private set; }
|
||||||
public List<Client> Clients { get; private set; }
|
public List<Client> Clients { get; private set; }
|
||||||
|
public List<Implementer> Implementers { get; private set; }
|
||||||
|
|
||||||
private DataFileSingleton() {
|
private DataFileSingleton() {
|
||||||
Foods = LoadData(FoodFileName, "Food", x => Food.Create(x)!)!;
|
Foods = LoadData(FoodFileName, "Food", x => Food.Create(x)!)!;
|
||||||
Snacks = LoadData(SnackFileName, "Snack", x => Snack.Create(x)!)!;
|
Snacks = LoadData(SnackFileName, "Snack", x => Snack.Create(x)!)!;
|
||||||
Orders = LoadData(OrderFileName, "Order", x => Order.Create(x)!)!;
|
Orders = LoadData(OrderFileName, "Order", x => Order.Create(x)!)!;
|
||||||
Clients = LoadData(ClientFileName, "Client", x => Client.Create(x)!)!;
|
Clients = LoadData(ClientFileName, "Client", x => Client.Create(x)!)!;
|
||||||
|
Implementers = LoadData(ImplementerFileName, "Implementer", x => Implementer.Create(x)!)!;
|
||||||
}
|
}
|
||||||
public static DataFileSingleton GetInstance() {
|
public static DataFileSingleton GetInstance() {
|
||||||
if (instance == null) instance = new DataFileSingleton();
|
if (instance == null) instance = new DataFileSingleton();
|
||||||
@ -43,6 +47,8 @@ namespace DinerFileImplement
|
|||||||
x => x.GetXElement);
|
x => x.GetXElement);
|
||||||
public void SaveClient() => SaveData(Clients, ClientFileName, "Clients",
|
public void SaveClient() => SaveData(Clients, ClientFileName, "Clients",
|
||||||
x => x.GetXElement);
|
x => x.GetXElement);
|
||||||
|
public void SaveImplementer() => SaveData(Implementers, ImplementerFileName, "Implementers",
|
||||||
|
x => x.GetXElement);
|
||||||
|
|
||||||
private static void SaveData<T>(List<T> data, string filename, string xmlNodeName,
|
private static void SaveData<T>(List<T> data, string filename, string xmlNodeName,
|
||||||
Func<T, XElement> selectFunction)
|
Func<T, XElement> selectFunction)
|
||||||
|
75
Diner/DinerShopImplement/Implements/ImplementerStorage.cs
Normal file
75
Diner/DinerShopImplement/Implements/ImplementerStorage.cs
Normal file
@ -0,0 +1,75 @@
|
|||||||
|
using DinerContracts.BindingModels;
|
||||||
|
using DinerContracts.SearchModels;
|
||||||
|
using DinerContracts.StoragesContracts;
|
||||||
|
using DinerContracts.ViewModels;
|
||||||
|
using DinerFileImplement.Models;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace DinerFileImplement.Implements {
|
||||||
|
public class ImplementerStorage : IImplementerStorage {
|
||||||
|
|
||||||
|
private readonly DataFileSingleton _source;
|
||||||
|
|
||||||
|
private ImplementerStorage() {
|
||||||
|
_source = DataFileSingleton.GetInstance();
|
||||||
|
}
|
||||||
|
|
||||||
|
public ImplementerViewModel? Insert(ImplementerBindingModel model) {
|
||||||
|
model.ID = _source.Implementers.Count > 0 ? _source.Implementers.Max(x => x.ID) + 1 : 1;
|
||||||
|
var newImplementer = Implementer.Create(model);
|
||||||
|
if (newImplementer == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
_source.Implementers.Add(newImplementer);
|
||||||
|
_source.SaveImplementer();
|
||||||
|
return newImplementer.GetViewModel;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ImplementerViewModel? Update(ImplementerBindingModel model) {
|
||||||
|
var implementer = _source.Implementers.FirstOrDefault(x => x.ID == model.ID);
|
||||||
|
if (implementer == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
implementer.Update(model);
|
||||||
|
_source.SaveImplementer();
|
||||||
|
return implementer.GetViewModel;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ImplementerViewModel? Delete(ImplementerBindingModel model) {
|
||||||
|
var element = _source.Implementers.FirstOrDefault(x => x.ID == model.ID);
|
||||||
|
if ( element != null) {
|
||||||
|
_source.Implementers.Remove(element);
|
||||||
|
_source.SaveImplementer();
|
||||||
|
return element.GetViewModel;
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ImplementerViewModel? GetElement(ImplementerSearchModel model) {
|
||||||
|
if (string.IsNullOrEmpty(model.ImplementerFIO) && !model.ID.HasValue) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return _source.Implementers.FirstOrDefault(x => (!string.IsNullOrEmpty(model.ImplementerFIO) &&
|
||||||
|
x.ImplementerFIO == model.ImplementerFIO) ||
|
||||||
|
model.ID.HasValue && x.ID == model.ID)?.GetViewModel;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<ImplementerViewModel> GetFilteredList(ImplementerSearchModel model) {
|
||||||
|
if (string.IsNullOrEmpty(model.ImplementerFIO)) {
|
||||||
|
return new();
|
||||||
|
}
|
||||||
|
return _source.Implementers.Where(x => x.ImplementerFIO.Contains(model.ImplementerFIO))
|
||||||
|
.Select(x => x.GetViewModel).ToList();
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<ImplementerViewModel> GetFullList() {
|
||||||
|
return _source.Implementers.Select(x => x.GetViewModel).ToList();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
@ -1,4 +1,4 @@
|
|||||||
using DinerContracts.BindingModels;
|
using DinerContracts.BindingModels;
|
||||||
using DinerContracts.ViewModels;
|
using DinerContracts.ViewModels;
|
||||||
using DinerDataModels.Models;
|
using DinerDataModels.Models;
|
||||||
using System;
|
using System;
|
||||||
@ -57,6 +57,6 @@ namespace DinerFileImplement.Models {
|
|||||||
public XElement GetXElement => new("Client", new XAttribute("ID", ID),
|
public XElement GetXElement => new("Client", new XAttribute("ID", ID),
|
||||||
new XElement("ClientFIO", ClientFIO),
|
new XElement("ClientFIO", ClientFIO),
|
||||||
new XElement("Email", Email),
|
new XElement("Email", Email),
|
||||||
new XElement("Password", Password.ToString()));
|
new XElement("Password", Password));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
70
Diner/DinerShopImplement/Models/Implementer.cs
Normal file
70
Diner/DinerShopImplement/Models/Implementer.cs
Normal file
@ -0,0 +1,70 @@
|
|||||||
|
using DinerContracts.BindingModels;
|
||||||
|
using DinerContracts.ViewModels;
|
||||||
|
using DinerDataModels.Models;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using System.Xml.Linq;
|
||||||
|
|
||||||
|
namespace DinerFileImplement.Models {
|
||||||
|
public class Implementer : IImplementerModel {
|
||||||
|
public string ImplementerFIO { get; set; } = string.Empty;
|
||||||
|
public string Password { get; set; } = string.Empty;
|
||||||
|
|
||||||
|
public int WorkExperience { get; set; }
|
||||||
|
|
||||||
|
public int Qualification { get; set; }
|
||||||
|
|
||||||
|
public int ID { get; set; }
|
||||||
|
|
||||||
|
public static Implementer? Create(ImplementerBindingModel? model) {
|
||||||
|
if (model == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return new Implementer() {
|
||||||
|
ImplementerFIO = model.ImplementerFIO,
|
||||||
|
Password = model.Password,
|
||||||
|
WorkExperience = model.WorkExperience,
|
||||||
|
Qualification = model.Qualification,
|
||||||
|
ID = model.ID
|
||||||
|
};
|
||||||
|
}
|
||||||
|
public static Implementer? Create(XElement element) {
|
||||||
|
if (element == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return new Implementer() {
|
||||||
|
ImplementerFIO = element.Element("ImplementerFIO")!.Value,
|
||||||
|
Password = element.Element("Password")!.Value,
|
||||||
|
WorkExperience = Convert.ToInt32(element.Element("WorkExperience")!.Value),
|
||||||
|
Qualification = Convert.ToInt32(element.Element("Qualification")!.Value),
|
||||||
|
ID = Convert.ToInt32(element.Element("ID")!.Value)
|
||||||
|
};
|
||||||
|
}
|
||||||
|
public void Update (ImplementerBindingModel? model) {
|
||||||
|
if (model == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
ImplementerFIO = model.ImplementerFIO;
|
||||||
|
Password = model.Password;
|
||||||
|
Qualification = model.Qualification;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ImplementerViewModel GetViewModel => new() {
|
||||||
|
ImplementerFIO = ImplementerFIO,
|
||||||
|
Password = Password,
|
||||||
|
Qualification = Qualification,
|
||||||
|
WorkExperience = WorkExperience,
|
||||||
|
ID = ID
|
||||||
|
};
|
||||||
|
|
||||||
|
public XElement GetXElement => new("Implementer", new XAttribute("ID", ID),
|
||||||
|
new XElement("ImplementerFIO", ImplementerFIO),
|
||||||
|
new XElement("Password", Password),
|
||||||
|
new XElement("Qualification", Qualification.ToString()),
|
||||||
|
new XElement("WorkExperience", WorkExperience.ToString()),
|
||||||
|
new XAttribute("ID", ID));
|
||||||
|
}
|
||||||
|
}
|
@ -8,13 +8,17 @@ using System.Linq;
|
|||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using System.Xml.Linq;
|
using System.Xml.Linq;
|
||||||
|
using System.Xml.Schema;
|
||||||
|
|
||||||
namespace DinerFileImplement.Models
|
namespace DinerFileImplement.Models
|
||||||
{
|
{
|
||||||
internal class Order : IOrderModel
|
internal class Order : IOrderModel {
|
||||||
{
|
|
||||||
public int SnackID { get; private set; }
|
public int SnackID { get; private set; }
|
||||||
|
|
||||||
|
public int ClientID { get; private set; }
|
||||||
|
|
||||||
|
public int? ImplementerID { get; set; }
|
||||||
|
|
||||||
public int Count { get; set; }
|
public int Count { get; set; }
|
||||||
|
|
||||||
public double Sum { get; private set; }
|
public double Sum { get; private set; }
|
||||||
@ -27,6 +31,11 @@ namespace DinerFileImplement.Models
|
|||||||
|
|
||||||
public int ID { get; private set; }
|
public int ID { get; private set; }
|
||||||
|
|
||||||
|
public string? ProductName { get; private set; }
|
||||||
|
|
||||||
|
public string ClientFIO { get; private set; }
|
||||||
|
|
||||||
|
public string ImplementerFIO { get; private set; }
|
||||||
|
|
||||||
public static Order? Create(OrderBindingModel? model)
|
public static Order? Create(OrderBindingModel? model)
|
||||||
{
|
{
|
||||||
@ -40,6 +49,8 @@ namespace DinerFileImplement.Models
|
|||||||
Status = model.Status,
|
Status = model.Status,
|
||||||
DateCreate = model.DateCreate,
|
DateCreate = model.DateCreate,
|
||||||
DateImplement = model.DateImplement,
|
DateImplement = model.DateImplement,
|
||||||
|
ClientID = model.ClientID,
|
||||||
|
ImplementerID = model.ImplementerID
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
public static Order? Create(XElement element) {
|
public static Order? Create(XElement element) {
|
||||||
@ -54,6 +65,8 @@ namespace DinerFileImplement.Models
|
|||||||
DateCreate = Convert.ToDateTime(element.Element("DateCreate")!.Value),
|
DateCreate = Convert.ToDateTime(element.Element("DateCreate")!.Value),
|
||||||
DateImplement = string.IsNullOrEmpty(element.Element("DateImplement")!.Value) ? null :
|
DateImplement = string.IsNullOrEmpty(element.Element("DateImplement")!.Value) ? null :
|
||||||
Convert.ToDateTime(element.Element("DateImplement")!.Value),
|
Convert.ToDateTime(element.Element("DateImplement")!.Value),
|
||||||
|
ClientID = Convert.ToInt32(element.Element("ClientID")!.Value),
|
||||||
|
ImplementerID = Convert.ToInt32(element.Element("ImplementerID")!.Value)
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
public void Update(OrderBindingModel? model)
|
public void Update(OrderBindingModel? model)
|
||||||
@ -71,6 +84,10 @@ namespace DinerFileImplement.Models
|
|||||||
Status = Status,
|
Status = Status,
|
||||||
DateCreate = DateCreate,
|
DateCreate = DateCreate,
|
||||||
DateImplement = DateImplement,
|
DateImplement = DateImplement,
|
||||||
|
ClientID = ClientID,
|
||||||
|
ImplementerID = ImplementerID,
|
||||||
|
ClientFIO = ClientFIO,
|
||||||
|
ImplementerFIO = ImplementerFIO
|
||||||
};
|
};
|
||||||
public XElement GetXElement => new("Order", new XAttribute("ID", ID),
|
public XElement GetXElement => new("Order", new XAttribute("ID", ID),
|
||||||
new XElement("SnackID", SnackID),
|
new XElement("SnackID", SnackID),
|
||||||
@ -78,7 +95,11 @@ namespace DinerFileImplement.Models
|
|||||||
new XElement("Sum", Sum.ToString()),
|
new XElement("Sum", Sum.ToString()),
|
||||||
new XElement("Status", Status.ToString()),
|
new XElement("Status", Status.ToString()),
|
||||||
new XElement("DateCreate", DateCreate.ToString()),
|
new XElement("DateCreate", DateCreate.ToString()),
|
||||||
new XElement("DateImplement", DateImplement.ToString()));
|
new XElement("DateImplement", DateImplement.ToString()),
|
||||||
|
new XElement("ClientID", ClientID.ToString()),
|
||||||
|
new XElement("ImplementerID", ImplementerID.ToString()),
|
||||||
|
new XElement("ClientFIO", ClientFIO),
|
||||||
|
new XElement("ImplementerFIO", ImplementerFIO));
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
46
Diner/DinerView/FormCreateOrder.Designer.cs
generated
46
Diner/DinerView/FormCreateOrder.Designer.cs
generated
@ -26,8 +26,7 @@
|
|||||||
/// Required method for Designer support - do not modify
|
/// Required method for Designer support - do not modify
|
||||||
/// the contents of this method with the code editor.
|
/// the contents of this method with the code editor.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private void InitializeComponent()
|
private void InitializeComponent() {
|
||||||
{
|
|
||||||
labelProduct = new Label();
|
labelProduct = new Label();
|
||||||
comboBoxProduct = new ComboBox();
|
comboBoxProduct = new ComboBox();
|
||||||
labelCount = new Label();
|
labelCount = new Label();
|
||||||
@ -36,12 +35,14 @@
|
|||||||
textBoxSum = new TextBox();
|
textBoxSum = new TextBox();
|
||||||
buttonCancel = new Button();
|
buttonCancel = new Button();
|
||||||
buttonSave = new Button();
|
buttonSave = new Button();
|
||||||
|
labelClient = new Label();
|
||||||
|
comboBoxClient = new ComboBox();
|
||||||
SuspendLayout();
|
SuspendLayout();
|
||||||
//
|
//
|
||||||
// labelProduct
|
// labelProduct
|
||||||
//
|
//
|
||||||
labelProduct.AutoSize = true;
|
labelProduct.AutoSize = true;
|
||||||
labelProduct.Location = new Point(12, 9);
|
labelProduct.Location = new Point(12, 39);
|
||||||
labelProduct.Name = "labelProduct";
|
labelProduct.Name = "labelProduct";
|
||||||
labelProduct.Size = new Size(37, 15);
|
labelProduct.Size = new Size(37, 15);
|
||||||
labelProduct.TabIndex = 0;
|
labelProduct.TabIndex = 0;
|
||||||
@ -52,7 +53,7 @@
|
|||||||
comboBoxProduct.BackColor = SystemColors.ButtonShadow;
|
comboBoxProduct.BackColor = SystemColors.ButtonShadow;
|
||||||
comboBoxProduct.DropDownStyle = ComboBoxStyle.DropDownList;
|
comboBoxProduct.DropDownStyle = ComboBoxStyle.DropDownList;
|
||||||
comboBoxProduct.FormattingEnabled = true;
|
comboBoxProduct.FormattingEnabled = true;
|
||||||
comboBoxProduct.Location = new Point(93, 6);
|
comboBoxProduct.Location = new Point(93, 36);
|
||||||
comboBoxProduct.Name = "comboBoxProduct";
|
comboBoxProduct.Name = "comboBoxProduct";
|
||||||
comboBoxProduct.Size = new Size(289, 23);
|
comboBoxProduct.Size = new Size(289, 23);
|
||||||
comboBoxProduct.TabIndex = 3;
|
comboBoxProduct.TabIndex = 3;
|
||||||
@ -61,7 +62,7 @@
|
|||||||
// labelCount
|
// labelCount
|
||||||
//
|
//
|
||||||
labelCount.AutoSize = true;
|
labelCount.AutoSize = true;
|
||||||
labelCount.Location = new Point(12, 37);
|
labelCount.Location = new Point(12, 67);
|
||||||
labelCount.Name = "labelCount";
|
labelCount.Name = "labelCount";
|
||||||
labelCount.Size = new Size(75, 15);
|
labelCount.Size = new Size(75, 15);
|
||||||
labelCount.TabIndex = 4;
|
labelCount.TabIndex = 4;
|
||||||
@ -69,7 +70,7 @@
|
|||||||
//
|
//
|
||||||
// textBoxCount
|
// textBoxCount
|
||||||
//
|
//
|
||||||
textBoxCount.Location = new Point(93, 34);
|
textBoxCount.Location = new Point(93, 64);
|
||||||
textBoxCount.Name = "textBoxCount";
|
textBoxCount.Name = "textBoxCount";
|
||||||
textBoxCount.Size = new Size(289, 23);
|
textBoxCount.Size = new Size(289, 23);
|
||||||
textBoxCount.TabIndex = 5;
|
textBoxCount.TabIndex = 5;
|
||||||
@ -78,7 +79,7 @@
|
|||||||
// label1
|
// label1
|
||||||
//
|
//
|
||||||
label1.AutoSize = true;
|
label1.AutoSize = true;
|
||||||
label1.Location = new Point(12, 66);
|
label1.Location = new Point(12, 96);
|
||||||
label1.Name = "label1";
|
label1.Name = "label1";
|
||||||
label1.Size = new Size(48, 15);
|
label1.Size = new Size(48, 15);
|
||||||
label1.TabIndex = 6;
|
label1.TabIndex = 6;
|
||||||
@ -86,7 +87,7 @@
|
|||||||
//
|
//
|
||||||
// textBoxSum
|
// textBoxSum
|
||||||
//
|
//
|
||||||
textBoxSum.Location = new Point(93, 63);
|
textBoxSum.Location = new Point(93, 93);
|
||||||
textBoxSum.Name = "textBoxSum";
|
textBoxSum.Name = "textBoxSum";
|
||||||
textBoxSum.ReadOnly = true;
|
textBoxSum.ReadOnly = true;
|
||||||
textBoxSum.Size = new Size(289, 23);
|
textBoxSum.Size = new Size(289, 23);
|
||||||
@ -94,7 +95,7 @@
|
|||||||
//
|
//
|
||||||
// buttonCancel
|
// buttonCancel
|
||||||
//
|
//
|
||||||
buttonCancel.Location = new Point(307, 92);
|
buttonCancel.Location = new Point(307, 122);
|
||||||
buttonCancel.Name = "buttonCancel";
|
buttonCancel.Name = "buttonCancel";
|
||||||
buttonCancel.Size = new Size(75, 23);
|
buttonCancel.Size = new Size(75, 23);
|
||||||
buttonCancel.TabIndex = 8;
|
buttonCancel.TabIndex = 8;
|
||||||
@ -104,7 +105,7 @@
|
|||||||
//
|
//
|
||||||
// buttonSave
|
// buttonSave
|
||||||
//
|
//
|
||||||
buttonSave.Location = new Point(226, 92);
|
buttonSave.Location = new Point(226, 122);
|
||||||
buttonSave.Name = "buttonSave";
|
buttonSave.Name = "buttonSave";
|
||||||
buttonSave.Size = new Size(75, 23);
|
buttonSave.Size = new Size(75, 23);
|
||||||
buttonSave.TabIndex = 9;
|
buttonSave.TabIndex = 9;
|
||||||
@ -112,11 +113,32 @@
|
|||||||
buttonSave.UseVisualStyleBackColor = true;
|
buttonSave.UseVisualStyleBackColor = true;
|
||||||
buttonSave.Click += buttonSave_Click;
|
buttonSave.Click += buttonSave_Click;
|
||||||
//
|
//
|
||||||
|
// labelClient
|
||||||
|
//
|
||||||
|
labelClient.AutoSize = true;
|
||||||
|
labelClient.Location = new Point(12, 9);
|
||||||
|
labelClient.Name = "labelClient";
|
||||||
|
labelClient.Size = new Size(49, 15);
|
||||||
|
labelClient.TabIndex = 10;
|
||||||
|
labelClient.Text = "Клиент:";
|
||||||
|
//
|
||||||
|
// comboBoxClient
|
||||||
|
//
|
||||||
|
comboBoxClient.BackColor = SystemColors.ButtonShadow;
|
||||||
|
comboBoxClient.DropDownStyle = ComboBoxStyle.DropDownList;
|
||||||
|
comboBoxClient.FormattingEnabled = true;
|
||||||
|
comboBoxClient.Location = new Point(93, 7);
|
||||||
|
comboBoxClient.Name = "comboBoxClient";
|
||||||
|
comboBoxClient.Size = new Size(289, 23);
|
||||||
|
comboBoxClient.TabIndex = 11;
|
||||||
|
//
|
||||||
// FormCreateOrder
|
// FormCreateOrder
|
||||||
//
|
//
|
||||||
AutoScaleDimensions = new SizeF(7F, 15F);
|
AutoScaleDimensions = new SizeF(7F, 15F);
|
||||||
AutoScaleMode = AutoScaleMode.Font;
|
AutoScaleMode = AutoScaleMode.Font;
|
||||||
ClientSize = new Size(394, 122);
|
ClientSize = new Size(394, 156);
|
||||||
|
Controls.Add(comboBoxClient);
|
||||||
|
Controls.Add(labelClient);
|
||||||
Controls.Add(buttonSave);
|
Controls.Add(buttonSave);
|
||||||
Controls.Add(buttonCancel);
|
Controls.Add(buttonCancel);
|
||||||
Controls.Add(textBoxSum);
|
Controls.Add(textBoxSum);
|
||||||
@ -142,5 +164,7 @@
|
|||||||
private TextBox textBoxSum;
|
private TextBox textBoxSum;
|
||||||
private Button buttonCancel;
|
private Button buttonCancel;
|
||||||
private Button buttonSave;
|
private Button buttonSave;
|
||||||
|
private Label labelClient;
|
||||||
|
private ComboBox comboBoxClient;
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,5 +1,6 @@
|
|||||||
using DinerContracts.BindingModels;
|
using DinerContracts.BindingModels;
|
||||||
using DinerContracts.BusinessLogicsContacts;
|
using DinerContracts.BusinessLogicsContacts;
|
||||||
|
using DinerContracts.BusinessLogicsContracts;
|
||||||
using DinerContracts.SearchModels;
|
using DinerContracts.SearchModels;
|
||||||
using DinerDataModels.Enums;
|
using DinerDataModels.Enums;
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
@ -20,13 +21,15 @@ namespace DinerView
|
|||||||
private readonly ILogger _logger;
|
private readonly ILogger _logger;
|
||||||
private readonly ISnackLogic _logicSnack;
|
private readonly ISnackLogic _logicSnack;
|
||||||
private readonly IOrderLogic _logicOrder;
|
private readonly IOrderLogic _logicOrder;
|
||||||
|
private readonly IClientLogic _clientLogic;
|
||||||
|
|
||||||
public FormCreateOrder(ILogger<FormCreateOrder> logger, ISnackLogic logicSnack, IOrderLogic logicOrder)
|
public FormCreateOrder(ILogger<FormCreateOrder> logger, ISnackLogic logicSnack, IOrderLogic logicOrder, IClientLogic clientLogic)
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
_logger = logger;
|
_logger = logger;
|
||||||
_logicSnack = logicSnack;
|
_logicSnack = logicSnack;
|
||||||
_logicOrder = logicOrder;
|
_logicOrder = logicOrder;
|
||||||
|
_clientLogic = clientLogic;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void CalcSum()
|
private void CalcSum()
|
||||||
@ -71,6 +74,10 @@ namespace DinerView
|
|||||||
{
|
{
|
||||||
MessageBox.Show("Выберите изделие", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
MessageBox.Show("Выберите изделие", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
if (comboBoxClient.SelectedValue == null) {
|
||||||
|
MessageBox.Show("Выбирите клиента", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
_logger.LogInformation("Создание заказа");
|
_logger.LogInformation("Создание заказа");
|
||||||
try
|
try
|
||||||
@ -79,7 +86,9 @@ namespace DinerView
|
|||||||
{
|
{
|
||||||
SnackID = Convert.ToInt32(comboBoxProduct.SelectedValue),
|
SnackID = Convert.ToInt32(comboBoxProduct.SelectedValue),
|
||||||
Count = Convert.ToInt32(textBoxCount.Text),
|
Count = Convert.ToInt32(textBoxCount.Text),
|
||||||
|
ProductName = comboBoxProduct.SelectedValue.ToString(),
|
||||||
Sum = Convert.ToDouble(textBoxSum.Text),
|
Sum = Convert.ToDouble(textBoxSum.Text),
|
||||||
|
ClientID = Convert.ToInt32(comboBoxClient.SelectedValue)
|
||||||
|
|
||||||
});
|
});
|
||||||
if (!operationResult) throw new Exception("Ошибка при создании заказа. Дополнительная информация в логах.");
|
if (!operationResult) throw new Exception("Ошибка при создании заказа. Дополнительная информация в логах.");
|
||||||
@ -113,9 +122,17 @@ namespace DinerView
|
|||||||
comboBoxProduct.DataSource = list;
|
comboBoxProduct.DataSource = list;
|
||||||
comboBoxProduct.SelectedItem = null;
|
comboBoxProduct.SelectedItem = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var listClient = _clientLogic.ReadList(null);
|
||||||
|
if (listClient != null) {
|
||||||
|
comboBoxClient.DisplayMember = "ClientFIO";
|
||||||
|
comboBoxClient.ValueMember = "ID";
|
||||||
|
comboBoxClient.DataSource = listClient;
|
||||||
|
comboBoxClient.SelectedItem = null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
catch (Exception ex) {
|
catch (Exception ex) {
|
||||||
_logger.LogError(ex, "Ошибка загрузки списка снэков");
|
_logger.LogError(ex, "Ошибка загрузки списка снэков или клиентов");
|
||||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
157
Diner/DinerView/FormImplementer.Designer.cs
generated
Normal file
157
Diner/DinerView/FormImplementer.Designer.cs
generated
Normal file
@ -0,0 +1,157 @@
|
|||||||
|
namespace DinerView {
|
||||||
|
partial class FormImplementer {
|
||||||
|
/// <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() {
|
||||||
|
labelFIO = new Label();
|
||||||
|
labelPassword = new Label();
|
||||||
|
labelWorkExperience = new Label();
|
||||||
|
labelQualification = new Label();
|
||||||
|
textBoxFIO = new TextBox();
|
||||||
|
textBoxPaassword = new TextBox();
|
||||||
|
textBoxWorkExperience = new TextBox();
|
||||||
|
textBoxQualification = new TextBox();
|
||||||
|
buttonSave = new Button();
|
||||||
|
buttonCancel = new Button();
|
||||||
|
SuspendLayout();
|
||||||
|
//
|
||||||
|
// labelFIO
|
||||||
|
//
|
||||||
|
labelFIO.AutoSize = true;
|
||||||
|
labelFIO.Location = new Point(12, 19);
|
||||||
|
labelFIO.Name = "labelFIO";
|
||||||
|
labelFIO.Size = new Size(37, 15);
|
||||||
|
labelFIO.TabIndex = 1;
|
||||||
|
labelFIO.Text = "ФИО:";
|
||||||
|
//
|
||||||
|
// labelPassword
|
||||||
|
//
|
||||||
|
labelPassword.AutoSize = true;
|
||||||
|
labelPassword.Location = new Point(12, 50);
|
||||||
|
labelPassword.Name = "labelPassword";
|
||||||
|
labelPassword.Size = new Size(49, 15);
|
||||||
|
labelPassword.TabIndex = 2;
|
||||||
|
labelPassword.Text = "Пароль";
|
||||||
|
//
|
||||||
|
// labelWorkExperience
|
||||||
|
//
|
||||||
|
labelWorkExperience.AutoSize = true;
|
||||||
|
labelWorkExperience.Location = new Point(12, 88);
|
||||||
|
labelWorkExperience.Name = "labelWorkExperience";
|
||||||
|
labelWorkExperience.Size = new Size(82, 15);
|
||||||
|
labelWorkExperience.TabIndex = 3;
|
||||||
|
labelWorkExperience.Text = "Стаж работы:";
|
||||||
|
//
|
||||||
|
// labelQualification
|
||||||
|
//
|
||||||
|
labelQualification.AutoSize = true;
|
||||||
|
labelQualification.Location = new Point(180, 88);
|
||||||
|
labelQualification.Name = "labelQualification";
|
||||||
|
labelQualification.Size = new Size(88, 15);
|
||||||
|
labelQualification.TabIndex = 4;
|
||||||
|
labelQualification.Text = "Квалификация";
|
||||||
|
//
|
||||||
|
// textBoxFIO
|
||||||
|
//
|
||||||
|
textBoxFIO.Location = new Point(67, 16);
|
||||||
|
textBoxFIO.Name = "textBoxFIO";
|
||||||
|
textBoxFIO.Size = new Size(305, 23);
|
||||||
|
textBoxFIO.TabIndex = 5;
|
||||||
|
//
|
||||||
|
// textBoxPaassword
|
||||||
|
//
|
||||||
|
textBoxPaassword.Location = new Point(67, 47);
|
||||||
|
textBoxPaassword.Name = "textBoxPaassword";
|
||||||
|
textBoxPaassword.Size = new Size(305, 23);
|
||||||
|
textBoxPaassword.TabIndex = 6;
|
||||||
|
//
|
||||||
|
// textBoxWorkExperience
|
||||||
|
//
|
||||||
|
textBoxWorkExperience.Location = new Point(100, 85);
|
||||||
|
textBoxWorkExperience.Name = "textBoxWorkExperience";
|
||||||
|
textBoxWorkExperience.Size = new Size(69, 23);
|
||||||
|
textBoxWorkExperience.TabIndex = 7;
|
||||||
|
//
|
||||||
|
// textBoxQualification
|
||||||
|
//
|
||||||
|
textBoxQualification.Location = new Point(274, 85);
|
||||||
|
textBoxQualification.Name = "textBoxQualification";
|
||||||
|
textBoxQualification.Size = new Size(98, 23);
|
||||||
|
textBoxQualification.TabIndex = 8;
|
||||||
|
//
|
||||||
|
// buttonSave
|
||||||
|
//
|
||||||
|
buttonSave.Location = new Point(216, 124);
|
||||||
|
buttonSave.Name = "buttonSave";
|
||||||
|
buttonSave.Size = new Size(75, 23);
|
||||||
|
buttonSave.TabIndex = 10;
|
||||||
|
buttonSave.Text = "Сохранить";
|
||||||
|
buttonSave.UseVisualStyleBackColor = true;
|
||||||
|
buttonSave.Click += buttonSave_Click;
|
||||||
|
//
|
||||||
|
// buttonCancel
|
||||||
|
//
|
||||||
|
buttonCancel.Location = new Point(297, 124);
|
||||||
|
buttonCancel.Name = "buttonCancel";
|
||||||
|
buttonCancel.Size = new Size(75, 23);
|
||||||
|
buttonCancel.TabIndex = 9;
|
||||||
|
buttonCancel.Text = "Отмена";
|
||||||
|
buttonCancel.UseVisualStyleBackColor = true;
|
||||||
|
buttonCancel.Click += buttonCancel_Click;
|
||||||
|
//
|
||||||
|
// FormImplementer
|
||||||
|
//
|
||||||
|
AutoScaleDimensions = new SizeF(7F, 15F);
|
||||||
|
AutoScaleMode = AutoScaleMode.Font;
|
||||||
|
ClientSize = new Size(394, 159);
|
||||||
|
Controls.Add(buttonSave);
|
||||||
|
Controls.Add(buttonCancel);
|
||||||
|
Controls.Add(textBoxQualification);
|
||||||
|
Controls.Add(textBoxWorkExperience);
|
||||||
|
Controls.Add(textBoxPaassword);
|
||||||
|
Controls.Add(textBoxFIO);
|
||||||
|
Controls.Add(labelQualification);
|
||||||
|
Controls.Add(labelWorkExperience);
|
||||||
|
Controls.Add(labelPassword);
|
||||||
|
Controls.Add(labelFIO);
|
||||||
|
Name = "FormImplementer";
|
||||||
|
Text = "Implementer";
|
||||||
|
Load += FormImplementer_Load;
|
||||||
|
ResumeLayout(false);
|
||||||
|
PerformLayout();
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
private Label labelFIO;
|
||||||
|
private Label labelPassword;
|
||||||
|
private Label labelWorkExperience;
|
||||||
|
private Label labelQualification;
|
||||||
|
private TextBox textBoxFIO;
|
||||||
|
private TextBox textBoxPaassword;
|
||||||
|
private TextBox textBoxWorkExperience;
|
||||||
|
private TextBox textBoxQualification;
|
||||||
|
private Button buttonSave;
|
||||||
|
private Button buttonCancel;
|
||||||
|
}
|
||||||
|
}
|
100
Diner/DinerView/FormImplementer.cs
Normal file
100
Diner/DinerView/FormImplementer.cs
Normal file
@ -0,0 +1,100 @@
|
|||||||
|
using DinerContracts.BindingModels;
|
||||||
|
using DinerContracts.BusinessLogicsContracts;
|
||||||
|
using DinerContracts.SearchModels;
|
||||||
|
using Microsoft.CodeAnalysis.CSharp.Syntax;
|
||||||
|
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 DinerView {
|
||||||
|
public partial class FormImplementer : Form {
|
||||||
|
|
||||||
|
private readonly ILogger _logger;
|
||||||
|
|
||||||
|
private readonly IImplementerLogic _logic;
|
||||||
|
|
||||||
|
private int? _ID;
|
||||||
|
|
||||||
|
public int ID {
|
||||||
|
set { _ID = value; }
|
||||||
|
}
|
||||||
|
public FormImplementer(ILogger<FormImplementer> logger, IImplementerLogic logic) {
|
||||||
|
InitializeComponent();
|
||||||
|
_logger = logger;
|
||||||
|
_logic = logic;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void FormImplementer_Load(object sender, EventArgs e) {
|
||||||
|
if (_ID.HasValue) {
|
||||||
|
try {
|
||||||
|
_logger.LogInformation("Получение исполнителя");
|
||||||
|
var view = _logic.ReadElement(new ImplementerSearchModel {
|
||||||
|
ID = _ID.Value
|
||||||
|
});
|
||||||
|
if (view != null) {
|
||||||
|
textBoxFIO.Text = view.ImplementerFIO;
|
||||||
|
textBoxPaassword.Text = view.Password;
|
||||||
|
textBoxQualification.Text = view.Qualification.ToString();
|
||||||
|
textBoxWorkExperience.Text = view.WorkExperience.ToString();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex) {
|
||||||
|
_logger.LogError(ex, "Ошибка получения исполнителя");
|
||||||
|
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void buttonSave_Click(object sender, EventArgs e) {
|
||||||
|
if (string.IsNullOrEmpty(textBoxFIO.Text)) {
|
||||||
|
MessageBox.Show("Заполните ФИО", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (string.IsNullOrEmpty(textBoxPaassword.Text)) {
|
||||||
|
MessageBox.Show("Придумайте пароль", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (string.IsNullOrEmpty(textBoxQualification.Text)) {
|
||||||
|
MessageBox.Show("Укажите квалификацию", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (string.IsNullOrEmpty(textBoxWorkExperience.Text)) {
|
||||||
|
MessageBox.Show("Укажите стаж работы", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
_logger.LogInformation("Сохранение исполнителя");
|
||||||
|
try {
|
||||||
|
var model = new ImplementerBindingModel {
|
||||||
|
ID = _ID ?? 0,
|
||||||
|
ImplementerFIO = textBoxFIO.Text,
|
||||||
|
Password = textBoxPaassword.Text,
|
||||||
|
Qualification = Convert.ToInt32(textBoxQualification.Text),
|
||||||
|
WorkExperience = Convert.ToInt32(textBoxWorkExperience.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();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
120
Diner/DinerView/FormImplementer.resx
Normal file
120
Diner/DinerView/FormImplementer.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>
|
115
Diner/DinerView/FormImplementers.Designer.cs
generated
Normal file
115
Diner/DinerView/FormImplementers.Designer.cs
generated
Normal file
@ -0,0 +1,115 @@
|
|||||||
|
namespace DinerView {
|
||||||
|
partial class FormImplementers {
|
||||||
|
/// <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();
|
||||||
|
buttonCange = new Button();
|
||||||
|
buttonDelete = new Button();
|
||||||
|
buttonUpdate = new Button();
|
||||||
|
((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit();
|
||||||
|
SuspendLayout();
|
||||||
|
//
|
||||||
|
// dataGridView
|
||||||
|
//
|
||||||
|
dataGridView.AllowUserToAddRows = false;
|
||||||
|
dataGridView.AllowUserToDeleteRows = false;
|
||||||
|
dataGridView.BackgroundColor = SystemColors.ButtonHighlight;
|
||||||
|
dataGridView.BorderStyle = BorderStyle.None;
|
||||||
|
dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
||||||
|
dataGridView.Dock = DockStyle.Left;
|
||||||
|
dataGridView.Location = new Point(0, 0);
|
||||||
|
dataGridView.Name = "dataGridView";
|
||||||
|
dataGridView.RowHeadersVisible = false;
|
||||||
|
dataGridView.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
|
||||||
|
dataGridView.Size = new Size(468, 450);
|
||||||
|
dataGridView.TabIndex = 1;
|
||||||
|
//
|
||||||
|
// buttonAdd
|
||||||
|
//
|
||||||
|
buttonAdd.Location = new Point(509, 12);
|
||||||
|
buttonAdd.Name = "buttonAdd";
|
||||||
|
buttonAdd.Size = new Size(95, 35);
|
||||||
|
buttonAdd.TabIndex = 2;
|
||||||
|
buttonAdd.Text = "Добавить";
|
||||||
|
buttonAdd.UseVisualStyleBackColor = true;
|
||||||
|
buttonAdd.Click += buttonAdd_Click;
|
||||||
|
//
|
||||||
|
// buttonCange
|
||||||
|
//
|
||||||
|
buttonCange.Location = new Point(509, 53);
|
||||||
|
buttonCange.Name = "buttonCange";
|
||||||
|
buttonCange.Size = new Size(95, 35);
|
||||||
|
buttonCange.TabIndex = 3;
|
||||||
|
buttonCange.Text = "Изменить";
|
||||||
|
buttonCange.UseVisualStyleBackColor = true;
|
||||||
|
buttonCange.Click += buttonCange_Click;
|
||||||
|
//
|
||||||
|
// buttonDelete
|
||||||
|
//
|
||||||
|
buttonDelete.Location = new Point(509, 94);
|
||||||
|
buttonDelete.Name = "buttonDelete";
|
||||||
|
buttonDelete.Size = new Size(95, 35);
|
||||||
|
buttonDelete.TabIndex = 4;
|
||||||
|
buttonDelete.Text = "Удалить";
|
||||||
|
buttonDelete.UseVisualStyleBackColor = true;
|
||||||
|
buttonDelete.Click += buttonDelete_Click;
|
||||||
|
//
|
||||||
|
// buttonUpdate
|
||||||
|
//
|
||||||
|
buttonUpdate.Location = new Point(509, 135);
|
||||||
|
buttonUpdate.Name = "buttonUpdate";
|
||||||
|
buttonUpdate.Size = new Size(95, 35);
|
||||||
|
buttonUpdate.TabIndex = 5;
|
||||||
|
buttonUpdate.Text = "Обновить";
|
||||||
|
buttonUpdate.UseVisualStyleBackColor = true;
|
||||||
|
buttonUpdate.Click += buttonUpdate_Click;
|
||||||
|
//
|
||||||
|
// FormImplementers
|
||||||
|
//
|
||||||
|
AutoScaleDimensions = new SizeF(7F, 15F);
|
||||||
|
AutoScaleMode = AutoScaleMode.Font;
|
||||||
|
BackColor = SystemColors.ActiveBorder;
|
||||||
|
ClientSize = new Size(635, 450);
|
||||||
|
Controls.Add(buttonUpdate);
|
||||||
|
Controls.Add(buttonDelete);
|
||||||
|
Controls.Add(buttonCange);
|
||||||
|
Controls.Add(buttonAdd);
|
||||||
|
Controls.Add(dataGridView);
|
||||||
|
Name = "FormImplementers";
|
||||||
|
Text = "Исполнители";
|
||||||
|
Load += FormImplementers_Load;
|
||||||
|
((System.ComponentModel.ISupportInitialize)dataGridView).EndInit();
|
||||||
|
ResumeLayout(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
private DataGridView dataGridView;
|
||||||
|
private Button buttonAdd;
|
||||||
|
private Button buttonCange;
|
||||||
|
private Button buttonDelete;
|
||||||
|
private Button buttonUpdate;
|
||||||
|
}
|
||||||
|
}
|
91
Diner/DinerView/FormImplementers.cs
Normal file
91
Diner/DinerView/FormImplementers.cs
Normal file
@ -0,0 +1,91 @@
|
|||||||
|
using DinerContracts.BindingModels;
|
||||||
|
using DinerContracts.BusinessLogicsContracts;
|
||||||
|
using Microsoft.EntityFrameworkCore.Diagnostics;
|
||||||
|
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 DinerView {
|
||||||
|
public partial class FormImplementers : Form {
|
||||||
|
|
||||||
|
private readonly ILogger _logger;
|
||||||
|
private readonly IImplementerLogic _logic;
|
||||||
|
|
||||||
|
public FormImplementers(ILogger<FormImplementers> logger, IImplementerLogic logic) {
|
||||||
|
InitializeComponent();
|
||||||
|
_logger = logger;
|
||||||
|
_logic = logic;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void FormImplementers_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["ImplementerFIO"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
|
||||||
|
}
|
||||||
|
_logger.LogInformation("Загрузка клиентов");
|
||||||
|
}
|
||||||
|
catch (Exception ex) {
|
||||||
|
_logger.LogError(ex, "Ошибка загрузки клиентов");
|
||||||
|
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void buttonUpdate_Click(object sender, EventArgs e) {
|
||||||
|
LoadData();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void buttonAdd_Click(object sender, EventArgs e) {
|
||||||
|
var service = Program.ServiceProvider?.GetService(typeof(FormImplementer));
|
||||||
|
if (service is FormImplementer form) {
|
||||||
|
if (form.ShowDialog() == DialogResult.OK) {
|
||||||
|
LoadData();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void buttonCange_Click(object sender, EventArgs e) {
|
||||||
|
if (dataGridView.SelectedRows.Count == 1) {
|
||||||
|
var service = Program.ServiceProvider?.GetService(typeof(FormImplementer));
|
||||||
|
if (service is FormImplementer form) {
|
||||||
|
form.ID = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["ID"].Value);
|
||||||
|
if (form.ShowDialog() == DialogResult.OK) {
|
||||||
|
LoadData();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void buttonDelete_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 ImplementerBindingModel { ID = id})) {
|
||||||
|
throw new Exception("Ошибка при удалении. Дополнительная информация в логах");
|
||||||
|
}
|
||||||
|
LoadData();
|
||||||
|
}
|
||||||
|
catch (Exception ex) {
|
||||||
|
_logger.LogError(ex, "Ошибка удаления компонента");
|
||||||
|
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
120
Diner/DinerView/FormImplementers.resx
Normal file
120
Diner/DinerView/FormImplementers.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>
|
80
Diner/DinerView/FormMain.Designer.cs
generated
80
Diner/DinerView/FormMain.Designer.cs
generated
@ -31,17 +31,17 @@
|
|||||||
toolStripMenuItemMenu = new ToolStripMenuItem();
|
toolStripMenuItemMenu = new ToolStripMenuItem();
|
||||||
toolStripMenuItemFoods = new ToolStripMenuItem();
|
toolStripMenuItemFoods = new ToolStripMenuItem();
|
||||||
toolStripMenuItemSnacks = new ToolStripMenuItem();
|
toolStripMenuItemSnacks = new ToolStripMenuItem();
|
||||||
|
toolStripMenuItemClient = new ToolStripMenuItem();
|
||||||
|
toolStripMenuItemImplementer = new ToolStripMenuItem();
|
||||||
toolStripMenuItemReport = new ToolStripMenuItem();
|
toolStripMenuItemReport = new ToolStripMenuItem();
|
||||||
FoodsToolStripMenuItem = new ToolStripMenuItem();
|
FoodsToolStripMenuItem = new ToolStripMenuItem();
|
||||||
FoodSnacksToolStripMenuItem = new ToolStripMenuItem();
|
FoodSnacksToolStripMenuItem = new ToolStripMenuItem();
|
||||||
ordersToolStripMenuItem = new ToolStripMenuItem();
|
ordersToolStripMenuItem = new ToolStripMenuItem();
|
||||||
|
toolStripMenuItemStartOfWork = new ToolStripMenuItem();
|
||||||
dataGridView = new DataGridView();
|
dataGridView = new DataGridView();
|
||||||
buttonCreateOrder = new Button();
|
buttonCreateOrder = new Button();
|
||||||
buttonInWork = new Button();
|
|
||||||
buttonIsReady = new Button();
|
|
||||||
buttonIsDelivery = new Button();
|
buttonIsDelivery = new Button();
|
||||||
buttonUpdateList = new Button();
|
buttonUpdateList = new Button();
|
||||||
toolStripMenuItemClient = new ToolStripMenuItem();
|
|
||||||
menuStrip.SuspendLayout();
|
menuStrip.SuspendLayout();
|
||||||
((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit();
|
((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit();
|
||||||
SuspendLayout();
|
SuspendLayout();
|
||||||
@ -49,16 +49,16 @@
|
|||||||
// menuStrip
|
// menuStrip
|
||||||
//
|
//
|
||||||
menuStrip.BackColor = SystemColors.Control;
|
menuStrip.BackColor = SystemColors.Control;
|
||||||
menuStrip.Items.AddRange(new ToolStripItem[] { toolStripMenuItemMenu, toolStripMenuItemReport });
|
menuStrip.Items.AddRange(new ToolStripItem[] { toolStripMenuItemMenu, toolStripMenuItemReport, toolStripMenuItemStartOfWork });
|
||||||
menuStrip.Location = new Point(0, 0);
|
menuStrip.Location = new Point(0, 0);
|
||||||
menuStrip.Name = "menuStrip";
|
menuStrip.Name = "menuStrip";
|
||||||
menuStrip.Size = new Size(951, 24);
|
menuStrip.Size = new Size(1114, 24);
|
||||||
menuStrip.TabIndex = 0;
|
menuStrip.TabIndex = 0;
|
||||||
menuStrip.Text = "Справочник";
|
menuStrip.Text = "Справочник";
|
||||||
//
|
//
|
||||||
// toolStripMenuItemMenu
|
// toolStripMenuItemMenu
|
||||||
//
|
//
|
||||||
toolStripMenuItemMenu.DropDownItems.AddRange(new ToolStripItem[] { toolStripMenuItemFoods, toolStripMenuItemSnacks, toolStripMenuItemClient });
|
toolStripMenuItemMenu.DropDownItems.AddRange(new ToolStripItem[] { toolStripMenuItemFoods, toolStripMenuItemSnacks, toolStripMenuItemClient, toolStripMenuItemImplementer });
|
||||||
toolStripMenuItemMenu.Name = "toolStripMenuItemMenu";
|
toolStripMenuItemMenu.Name = "toolStripMenuItemMenu";
|
||||||
toolStripMenuItemMenu.Size = new Size(94, 20);
|
toolStripMenuItemMenu.Size = new Size(94, 20);
|
||||||
toolStripMenuItemMenu.Text = "Справочники";
|
toolStripMenuItemMenu.Text = "Справочники";
|
||||||
@ -66,17 +66,31 @@
|
|||||||
// toolStripMenuItemFoods
|
// toolStripMenuItemFoods
|
||||||
//
|
//
|
||||||
toolStripMenuItemFoods.Name = "toolStripMenuItemFoods";
|
toolStripMenuItemFoods.Name = "toolStripMenuItemFoods";
|
||||||
toolStripMenuItemFoods.Size = new Size(180, 22);
|
toolStripMenuItemFoods.Size = new Size(149, 22);
|
||||||
toolStripMenuItemFoods.Text = "Продукты";
|
toolStripMenuItemFoods.Text = "Продукты";
|
||||||
toolStripMenuItemFoods.Click += toolStripMenuItemFoods_Click;
|
toolStripMenuItemFoods.Click += toolStripMenuItemFoods_Click;
|
||||||
//
|
//
|
||||||
// toolStripMenuItemSnacks
|
// toolStripMenuItemSnacks
|
||||||
//
|
//
|
||||||
toolStripMenuItemSnacks.Name = "toolStripMenuItemSnacks";
|
toolStripMenuItemSnacks.Name = "toolStripMenuItemSnacks";
|
||||||
toolStripMenuItemSnacks.Size = new Size(180, 22);
|
toolStripMenuItemSnacks.Size = new Size(149, 22);
|
||||||
toolStripMenuItemSnacks.Text = "Снэки";
|
toolStripMenuItemSnacks.Text = "Снэки";
|
||||||
toolStripMenuItemSnacks.Click += toolStripMenuItemSnacks_Click;
|
toolStripMenuItemSnacks.Click += toolStripMenuItemSnacks_Click;
|
||||||
//
|
//
|
||||||
|
// toolStripMenuItemClient
|
||||||
|
//
|
||||||
|
toolStripMenuItemClient.Name = "toolStripMenuItemClient";
|
||||||
|
toolStripMenuItemClient.Size = new Size(149, 22);
|
||||||
|
toolStripMenuItemClient.Text = "Клиенты";
|
||||||
|
toolStripMenuItemClient.Click += toolStripMenuItemClient_Click;
|
||||||
|
//
|
||||||
|
// toolStripMenuItemImplementer
|
||||||
|
//
|
||||||
|
toolStripMenuItemImplementer.Name = "toolStripMenuItemImplementer";
|
||||||
|
toolStripMenuItemImplementer.Size = new Size(149, 22);
|
||||||
|
toolStripMenuItemImplementer.Text = "Исполнители";
|
||||||
|
toolStripMenuItemImplementer.Click += toolStripMenuItemImplementer_Click;
|
||||||
|
//
|
||||||
// toolStripMenuItemReport
|
// toolStripMenuItemReport
|
||||||
//
|
//
|
||||||
toolStripMenuItemReport.DropDownItems.AddRange(new ToolStripItem[] { FoodsToolStripMenuItem, FoodSnacksToolStripMenuItem, ordersToolStripMenuItem });
|
toolStripMenuItemReport.DropDownItems.AddRange(new ToolStripItem[] { FoodsToolStripMenuItem, FoodSnacksToolStripMenuItem, ordersToolStripMenuItem });
|
||||||
@ -105,6 +119,13 @@
|
|||||||
ordersToolStripMenuItem.Text = "Список заказов";
|
ordersToolStripMenuItem.Text = "Список заказов";
|
||||||
ordersToolStripMenuItem.Click += ordersToolStripMenuItem_Click;
|
ordersToolStripMenuItem.Click += ordersToolStripMenuItem_Click;
|
||||||
//
|
//
|
||||||
|
// toolStripMenuItemStartOfWork
|
||||||
|
//
|
||||||
|
toolStripMenuItemStartOfWork.Name = "toolStripMenuItemStartOfWork";
|
||||||
|
toolStripMenuItemStartOfWork.Size = new Size(92, 20);
|
||||||
|
toolStripMenuItemStartOfWork.Text = "Запуск работ";
|
||||||
|
toolStripMenuItemStartOfWork.Click += toolStripMenuItemStartOfWork_Click;
|
||||||
|
//
|
||||||
// dataGridView
|
// dataGridView
|
||||||
//
|
//
|
||||||
dataGridView.AllowUserToAddRows = false;
|
dataGridView.AllowUserToAddRows = false;
|
||||||
@ -119,12 +140,12 @@
|
|||||||
dataGridView.ReadOnly = true;
|
dataGridView.ReadOnly = true;
|
||||||
dataGridView.RowHeadersVisible = false;
|
dataGridView.RowHeadersVisible = false;
|
||||||
dataGridView.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
|
dataGridView.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
|
||||||
dataGridView.Size = new Size(726, 426);
|
dataGridView.Size = new Size(889, 426);
|
||||||
dataGridView.TabIndex = 0;
|
dataGridView.TabIndex = 0;
|
||||||
//
|
//
|
||||||
// buttonCreateOrder
|
// buttonCreateOrder
|
||||||
//
|
//
|
||||||
buttonCreateOrder.Location = new Point(732, 36);
|
buttonCreateOrder.Location = new Point(895, 40);
|
||||||
buttonCreateOrder.Name = "buttonCreateOrder";
|
buttonCreateOrder.Name = "buttonCreateOrder";
|
||||||
buttonCreateOrder.Size = new Size(212, 39);
|
buttonCreateOrder.Size = new Size(212, 39);
|
||||||
buttonCreateOrder.TabIndex = 2;
|
buttonCreateOrder.TabIndex = 2;
|
||||||
@ -132,29 +153,9 @@
|
|||||||
buttonCreateOrder.UseVisualStyleBackColor = true;
|
buttonCreateOrder.UseVisualStyleBackColor = true;
|
||||||
buttonCreateOrder.Click += buttonCreateOrder_Click;
|
buttonCreateOrder.Click += buttonCreateOrder_Click;
|
||||||
//
|
//
|
||||||
// buttonInWork
|
|
||||||
//
|
|
||||||
buttonInWork.Location = new Point(732, 81);
|
|
||||||
buttonInWork.Name = "buttonInWork";
|
|
||||||
buttonInWork.Size = new Size(212, 39);
|
|
||||||
buttonInWork.TabIndex = 3;
|
|
||||||
buttonInWork.Text = "Отдать на выполнение";
|
|
||||||
buttonInWork.UseVisualStyleBackColor = true;
|
|
||||||
buttonInWork.Click += buttonInWork_Click;
|
|
||||||
//
|
|
||||||
// buttonIsReady
|
|
||||||
//
|
|
||||||
buttonIsReady.Location = new Point(732, 126);
|
|
||||||
buttonIsReady.Name = "buttonIsReady";
|
|
||||||
buttonIsReady.Size = new Size(212, 39);
|
|
||||||
buttonIsReady.TabIndex = 4;
|
|
||||||
buttonIsReady.Text = "Заказ готов";
|
|
||||||
buttonIsReady.UseVisualStyleBackColor = true;
|
|
||||||
buttonIsReady.Click += buttonIsReady_Click;
|
|
||||||
//
|
|
||||||
// buttonIsDelivery
|
// buttonIsDelivery
|
||||||
//
|
//
|
||||||
buttonIsDelivery.Location = new Point(732, 171);
|
buttonIsDelivery.Location = new Point(895, 100);
|
||||||
buttonIsDelivery.Name = "buttonIsDelivery";
|
buttonIsDelivery.Name = "buttonIsDelivery";
|
||||||
buttonIsDelivery.Size = new Size(212, 39);
|
buttonIsDelivery.Size = new Size(212, 39);
|
||||||
buttonIsDelivery.TabIndex = 5;
|
buttonIsDelivery.TabIndex = 5;
|
||||||
@ -164,7 +165,7 @@
|
|||||||
//
|
//
|
||||||
// buttonUpdateList
|
// buttonUpdateList
|
||||||
//
|
//
|
||||||
buttonUpdateList.Location = new Point(732, 216);
|
buttonUpdateList.Location = new Point(895, 159);
|
||||||
buttonUpdateList.Name = "buttonUpdateList";
|
buttonUpdateList.Name = "buttonUpdateList";
|
||||||
buttonUpdateList.Size = new Size(212, 39);
|
buttonUpdateList.Size = new Size(212, 39);
|
||||||
buttonUpdateList.TabIndex = 6;
|
buttonUpdateList.TabIndex = 6;
|
||||||
@ -172,23 +173,14 @@
|
|||||||
buttonUpdateList.UseVisualStyleBackColor = true;
|
buttonUpdateList.UseVisualStyleBackColor = true;
|
||||||
buttonUpdateList.Click += buttonUpdateList_Click;
|
buttonUpdateList.Click += buttonUpdateList_Click;
|
||||||
//
|
//
|
||||||
// toolStripMenuItemClient
|
|
||||||
//
|
|
||||||
toolStripMenuItemClient.Name = "toolStripMenuItemClient";
|
|
||||||
toolStripMenuItemClient.Size = new Size(180, 22);
|
|
||||||
toolStripMenuItemClient.Text = "Клиенты";
|
|
||||||
toolStripMenuItemClient.Click += toolStripMenuItemClient_Click;
|
|
||||||
//
|
|
||||||
// FormMain
|
// FormMain
|
||||||
//
|
//
|
||||||
AutoScaleDimensions = new SizeF(7F, 15F);
|
AutoScaleDimensions = new SizeF(7F, 15F);
|
||||||
AutoScaleMode = AutoScaleMode.Font;
|
AutoScaleMode = AutoScaleMode.Font;
|
||||||
BackColor = SystemColors.ScrollBar;
|
BackColor = SystemColors.ScrollBar;
|
||||||
ClientSize = new Size(951, 450);
|
ClientSize = new Size(1114, 450);
|
||||||
Controls.Add(buttonUpdateList);
|
Controls.Add(buttonUpdateList);
|
||||||
Controls.Add(buttonIsDelivery);
|
Controls.Add(buttonIsDelivery);
|
||||||
Controls.Add(buttonIsReady);
|
|
||||||
Controls.Add(buttonInWork);
|
|
||||||
Controls.Add(buttonCreateOrder);
|
Controls.Add(buttonCreateOrder);
|
||||||
Controls.Add(dataGridView);
|
Controls.Add(dataGridView);
|
||||||
Controls.Add(menuStrip);
|
Controls.Add(menuStrip);
|
||||||
@ -211,8 +203,6 @@
|
|||||||
private ToolStripMenuItem toolStripMenuItemFoods;
|
private ToolStripMenuItem toolStripMenuItemFoods;
|
||||||
private ToolStripMenuItem toolStripMenuItemSnacks;
|
private ToolStripMenuItem toolStripMenuItemSnacks;
|
||||||
private Button buttonCreateOrder;
|
private Button buttonCreateOrder;
|
||||||
private Button buttonInWork;
|
|
||||||
private Button buttonIsReady;
|
|
||||||
private Button buttonIsDelivery;
|
private Button buttonIsDelivery;
|
||||||
private Button buttonUpdateList;
|
private Button buttonUpdateList;
|
||||||
private ToolStripMenuItem toolStripMenuItemReport;
|
private ToolStripMenuItem toolStripMenuItemReport;
|
||||||
@ -220,5 +210,7 @@
|
|||||||
private ToolStripMenuItem FoodSnacksToolStripMenuItem;
|
private ToolStripMenuItem FoodSnacksToolStripMenuItem;
|
||||||
private ToolStripMenuItem ordersToolStripMenuItem;
|
private ToolStripMenuItem ordersToolStripMenuItem;
|
||||||
private ToolStripMenuItem toolStripMenuItemClient;
|
private ToolStripMenuItem toolStripMenuItemClient;
|
||||||
|
private ToolStripMenuItem toolStripMenuItemStartOfWork;
|
||||||
|
private ToolStripMenuItem toolStripMenuItemImplementer;
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,6 +1,7 @@
|
|||||||
using DinerContracts.BindingModels;
|
using DinerContracts.BindingModels;
|
||||||
using DinerContracts.BusinessLogicsContacts;
|
using DinerContracts.BusinessLogicsContacts;
|
||||||
using DinerContracts.BusinessLogicsContracts;
|
using DinerContracts.BusinessLogicsContracts;
|
||||||
|
using DinerDataBaseImplement.Models;
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
@ -19,11 +20,13 @@ namespace DinerView
|
|||||||
private readonly ILogger _logger;
|
private readonly ILogger _logger;
|
||||||
private readonly IOrderLogic _orderLogic;
|
private readonly IOrderLogic _orderLogic;
|
||||||
private readonly IReportLogic _reportLogic;
|
private readonly IReportLogic _reportLogic;
|
||||||
public FormMain(ILogger<FormMain> logger, IOrderLogic orderLogic, IReportLogic reportLogic) {
|
private readonly IWorkProcess _workProcess;
|
||||||
|
public FormMain(ILogger<FormMain> logger, IOrderLogic orderLogic, IReportLogic reportLogic, IWorkProcess workProcess) {
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
_logger = logger;
|
_logger = logger;
|
||||||
_orderLogic = orderLogic;
|
_orderLogic = orderLogic;
|
||||||
_reportLogic = reportLogic;
|
_reportLogic = reportLogic;
|
||||||
|
_workProcess = workProcess;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void FormMain_Load(object sender, EventArgs e) {
|
private void FormMain_Load(object sender, EventArgs e) {
|
||||||
@ -38,8 +41,10 @@ namespace DinerView
|
|||||||
dataGridView.DataSource = list;
|
dataGridView.DataSource = list;
|
||||||
dataGridView.Columns["SnackID"].Visible = false;
|
dataGridView.Columns["SnackID"].Visible = false;
|
||||||
dataGridView.Columns["ClientID"].Visible = false;
|
dataGridView.Columns["ClientID"].Visible = false;
|
||||||
dataGridView.Columns["ID"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
|
dataGridView.Columns["ImplementerID"].Visible = false;
|
||||||
|
dataGridView.Columns["ID"].AutoSizeMode = DataGridViewAutoSizeColumnMode.ColumnHeader;
|
||||||
dataGridView.Columns["Sum"].AutoSizeMode = DataGridViewAutoSizeColumnMode.ColumnHeader;
|
dataGridView.Columns["Sum"].AutoSizeMode = DataGridViewAutoSizeColumnMode.ColumnHeader;
|
||||||
|
dataGridView.Columns["ImplementerFIO"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
|
||||||
}
|
}
|
||||||
_logger.LogInformation("Загрузка заказов");
|
_logger.LogInformation("Загрузка заказов");
|
||||||
}
|
}
|
||||||
@ -160,5 +165,18 @@ namespace DinerView
|
|||||||
form.ShowDialog();
|
form.ShowDialog();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void toolStripMenuItemImplementer_Click(object sender, EventArgs e) {
|
||||||
|
var service = Program.ServiceProvider?.GetService(typeof(FormImplementers));
|
||||||
|
if (service is FormImplementers form) {
|
||||||
|
form.ShowDialog();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void toolStripMenuItemStartOfWork_Click(object sender, EventArgs e) {
|
||||||
|
_workProcess.Work((Program.ServiceProvider?.GetService(typeof(IImplementerLogic)) as IImplementerLogic)!, _orderLogic);
|
||||||
|
MessageBox.Show("Процесс обработки запущен", "Сообщение",
|
||||||
|
MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -39,14 +39,17 @@ namespace DinerView
|
|||||||
});
|
});
|
||||||
services.AddTransient<IFoodStorage, FoodStorage>();
|
services.AddTransient<IFoodStorage, FoodStorage>();
|
||||||
services.AddTransient<IOrderStorage, OrderStorage>();
|
services.AddTransient<IOrderStorage, OrderStorage>();
|
||||||
|
services.AddTransient<IImplementerStorage, ImplementerStorage>();
|
||||||
services.AddTransient<ISnackStorage, SnackStorage>();
|
services.AddTransient<ISnackStorage, SnackStorage>();
|
||||||
services.AddTransient<IClientStorage, ClientStorage>();
|
services.AddTransient<IClientStorage, ClientStorage>();
|
||||||
|
|
||||||
services.AddTransient<IClientLogic, ClientLogic>();
|
services.AddTransient<IClientLogic, ClientLogic>();
|
||||||
services.AddTransient<IFoodLogic, FoodLogic>();
|
services.AddTransient<IFoodLogic, FoodLogic>();
|
||||||
services.AddTransient<IOrderLogic, OrderLogic>();
|
services.AddTransient<IOrderLogic, OrderLogic>();
|
||||||
|
services.AddTransient<IImplementerLogic, ImplementerLogic>();
|
||||||
services.AddTransient<ISnackLogic, SnackLogic>();
|
services.AddTransient<ISnackLogic, SnackLogic>();
|
||||||
services.AddTransient<IReportLogic, ReportLogic>();
|
services.AddTransient<IReportLogic, ReportLogic>();
|
||||||
|
services.AddTransient<IWorkProcess, WorkModelling>();
|
||||||
|
|
||||||
services.AddTransient<AbstractSaveToExcel, SaveToExcel>();
|
services.AddTransient<AbstractSaveToExcel, SaveToExcel>();
|
||||||
services.AddTransient<AbstractSaveToWord, SaveToWord>();
|
services.AddTransient<AbstractSaveToWord, SaveToWord>();
|
||||||
@ -62,6 +65,8 @@ namespace DinerView
|
|||||||
services.AddTransient<FormReportSnackFoods>();
|
services.AddTransient<FormReportSnackFoods>();
|
||||||
services.AddTransient<FormReportOrders>();
|
services.AddTransient<FormReportOrders>();
|
||||||
services.AddTransient<FormClient>();
|
services.AddTransient<FormClient>();
|
||||||
|
services.AddTransient<FormImplementers>();
|
||||||
|
services.AddTransient<FormImplementer>();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -55,7 +55,7 @@ namespace DineryBusinessLogic.BusinessLogic {
|
|||||||
if (model == null) {
|
if (model == null) {
|
||||||
throw new ArgumentNullException(nameof(model));
|
throw new ArgumentNullException(nameof(model));
|
||||||
}
|
}
|
||||||
_logger.LogInformation($"ReadElement. Login:{model.ClientFIO}.ID:{model.ID}");
|
_logger.LogInformation($"ReadElement. Login:{model.Email}.ID:{model.ID}");
|
||||||
var element = _storage.GetElement(model);
|
var element = _storage.GetElement(model);
|
||||||
if (element == null) {
|
if (element == null) {
|
||||||
_logger.LogWarning("ReadElement. element not found");
|
_logger.LogWarning("ReadElement. element not found");
|
||||||
@ -69,7 +69,7 @@ namespace DineryBusinessLogic.BusinessLogic {
|
|||||||
_logger.LogInformation($"ReadList. CLientID:{model?.ID}");
|
_logger.LogInformation($"ReadList. CLientID:{model?.ID}");
|
||||||
var list = model == null ? _storage.GetFullList() : _storage.GetFilteredList(model);
|
var list = model == null ? _storage.GetFullList() : _storage.GetFilteredList(model);
|
||||||
if (list == null) {
|
if (list == null) {
|
||||||
_logger.LogWarning("ReadList. return nell list");
|
_logger.LogWarning("ReadList. return null list");
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
_logger.LogInformation($"ReadList. Count:{list.Count}");
|
_logger.LogInformation($"ReadList. Count:{list.Count}");
|
||||||
@ -98,9 +98,9 @@ namespace DineryBusinessLogic.BusinessLogic {
|
|||||||
}
|
}
|
||||||
_logger.LogInformation($"Client. ID:{model.ID}.FIO:{model.ClientFIO}.Email:{model.Email}.Password:{model.Password}");
|
_logger.LogInformation($"Client. ID:{model.ID}.FIO:{model.ClientFIO}.Email:{model.Email}.Password:{model.Password}");
|
||||||
var element = _storage.GetElement(new ClientSearchModel {
|
var element = _storage.GetElement(new ClientSearchModel {
|
||||||
ClientFIO = model.ClientFIO,
|
Email = model.Email,
|
||||||
});
|
});
|
||||||
if (element != null && element.ClientFIO == model.ClientFIO) {
|
if (element != null && element.Email == model.Email) {
|
||||||
throw new InvalidOperationException("Клиент с таким логином уже есть");
|
throw new InvalidOperationException("Клиент с таким логином уже есть");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
111
Diner/DineryBusinessLogic/BusinessLogic/ImplementerLogic.cs
Normal file
111
Diner/DineryBusinessLogic/BusinessLogic/ImplementerLogic.cs
Normal file
@ -0,0 +1,111 @@
|
|||||||
|
using DinerContracts.BindingModels;
|
||||||
|
using DinerContracts.BusinessLogicsContracts;
|
||||||
|
using DinerContracts.SearchModels;
|
||||||
|
using DinerContracts.StoragesContracts;
|
||||||
|
using DinerContracts.ViewModels;
|
||||||
|
using Microsoft.Extensions.Logging;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Reflection.Metadata.Ecma335;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace DineryBusinessLogic.BusinessLogic {
|
||||||
|
public class ImplementerLogic : IImplementerLogic {
|
||||||
|
|
||||||
|
private readonly ILogger _logger;
|
||||||
|
private readonly IImplementerStorage _storage;
|
||||||
|
|
||||||
|
public ImplementerLogic(ILogger<ImplementerLogic> logger, IImplementerStorage storage) {
|
||||||
|
_logger = logger;
|
||||||
|
_storage = storage;
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool Create(ImplementerBindingModel model) {
|
||||||
|
CheckModel(model);
|
||||||
|
if (_storage.Insert(model) == null) {
|
||||||
|
_logger.LogWarning("Insert operation failed");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool Delete(ImplementerBindingModel model) {
|
||||||
|
CheckModel(model, false);
|
||||||
|
_logger.LogInformation($"Delete. ID:{model.ID}");
|
||||||
|
if (_storage.Delete(model) == null) {
|
||||||
|
_logger.LogWarning("Delete operation failed");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool Update(ImplementerBindingModel model) {
|
||||||
|
CheckModel(model);
|
||||||
|
if (_storage.Update(model) == null) {
|
||||||
|
_logger.LogWarning("Update operation failde");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ImplementerViewModel? ReadElement(ImplementerSearchModel model) {
|
||||||
|
if (model == null) {
|
||||||
|
throw new ArgumentNullException(nameof(model));
|
||||||
|
}
|
||||||
|
_logger.LogInformation($"ReadElement. FIO:{model.ImplementerFIO}.ID:{model.ID}");
|
||||||
|
var element = _storage.GetElement(model);
|
||||||
|
if (element == null) {
|
||||||
|
_logger.LogWarning("ReadElement. element not fount");
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
_logger.LogInformation($"ReadElement. find.ID:{element.ID}");
|
||||||
|
return element;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<ImplementerViewModel>? ReadList(ImplementerSearchModel? model) {
|
||||||
|
_logger.LogInformation($"ReadList. ImplementerID:{model?.ID}");
|
||||||
|
var list = model == null ? _storage.GetFullList() : _storage.GetFilteredList(model);
|
||||||
|
if (list == null) {
|
||||||
|
_logger.LogWarning("ReadList. return null list");
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
_logger.LogInformation($"ReadList. Count:{list.Count}");
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private void CheckModel(ImplementerBindingModel model, bool withParams = true) {
|
||||||
|
if (model == null) {
|
||||||
|
throw new ArgumentNullException(nameof(model));
|
||||||
|
}
|
||||||
|
if (!withParams) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (string.IsNullOrEmpty(model.ImplementerFIO)) {
|
||||||
|
throw new ArgumentNullException("Нет ФИО исполнителя", nameof(model.ImplementerFIO));
|
||||||
|
}
|
||||||
|
if (string.IsNullOrEmpty(model.Password)) {
|
||||||
|
throw new ArgumentNullException("Нет пароля");
|
||||||
|
}
|
||||||
|
if (string.IsNullOrEmpty((model.WorkExperience).ToString())) {
|
||||||
|
throw new ArgumentNullException("Не указан стаж");
|
||||||
|
}
|
||||||
|
if (string.IsNullOrEmpty((model.Qualification).ToString())) {
|
||||||
|
throw new ArgumentNullException("Нет квалификации");
|
||||||
|
}
|
||||||
|
if (string.IsNullOrEmpty((model.ID).ToString())) {
|
||||||
|
throw new ArgumentNullException("Нет ID пользователя", nameof(model.ID));
|
||||||
|
}
|
||||||
|
_logger.LogInformation($"Implementer. ID:{model.ID}.ImplementerFIO:{model.ImplementerFIO}.WorkExperience:{model.WorkExperience}." +
|
||||||
|
$"Qualification:{model.Qualification}");
|
||||||
|
var element = _storage.GetElement(new ImplementerSearchModel {
|
||||||
|
ImplementerFIO = model.ImplementerFIO
|
||||||
|
});
|
||||||
|
if (element != null && element.ImplementerFIO == model.ImplementerFIO) {
|
||||||
|
throw new InvalidOperationException("Исполнитель с таким ФИО уже есть");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -45,6 +45,20 @@ namespace DineryBusinessLogic.BusinessLogic
|
|||||||
return StatusUpdate(model, OrderStatus.Готов);
|
return StatusUpdate(model, OrderStatus.Готов);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public OrderViewModel? ReadElement(OrderSearchModel model) {
|
||||||
|
if (model == null) {
|
||||||
|
throw new ArgumentNullException(nameof(model));
|
||||||
|
}
|
||||||
|
_logger.LogInformation($"ReadElement. ImplementerLogin:{model.ImplementerID}.ID:{model.ID}");
|
||||||
|
var element = _orderStorage.GetElement(model);
|
||||||
|
if (element == null) {
|
||||||
|
_logger.LogWarning("ReadElement. element not found");
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
_logger.LogInformation($"ReadElement. findID:{element.ID}");
|
||||||
|
return element;
|
||||||
|
}
|
||||||
|
|
||||||
public List<OrderViewModel>? ReadList(OrderSearchModel? model)
|
public List<OrderViewModel>? ReadList(OrderSearchModel? model)
|
||||||
{
|
{
|
||||||
_logger.LogInformation("ReadList. ID:{ID}", model?.ID);
|
_logger.LogInformation("ReadList. ID:{ID}", model?.ID);
|
||||||
@ -72,13 +86,17 @@ namespace DineryBusinessLogic.BusinessLogic
|
|||||||
if (model.ClientID < 0) {
|
if (model.ClientID < 0) {
|
||||||
throw new ArgumentNullException("Некорректный идентификатор у клиента", nameof(model.ClientID));
|
throw new ArgumentNullException("Некорректный идентификатор у клиента", nameof(model.ClientID));
|
||||||
}
|
}
|
||||||
|
if (model.ImplementerID < 0) {
|
||||||
|
throw new ArgumentNullException("Некорректный идентификатор у исполнителя", nameof(model.ImplementerID));
|
||||||
|
}
|
||||||
_logger.LogInformation("Order. SnackID:{SnackID}. Count:{Count}. Sum:{Sum}. Status:{Status}. " +
|
_logger.LogInformation("Order. SnackID:{SnackID}. Count:{Count}. Sum:{Sum}. Status:{Status}. " +
|
||||||
"DateCreate:{DateCreate}. DateImplement:{DateImplement}. ID:{ID}, ClientId: {ClientId}",
|
"DateCreate:{DateCreate}. DateImplement:{DateImplement}. ID:{ID}. ClientId: {ClientId}. " +
|
||||||
|
"ImplementerID: {ImplementerId}",
|
||||||
model.SnackID, model.Count, model.Sum, model.Status, model.DateCreate, model.DateImplement, model.ID,
|
model.SnackID, model.Count, model.Sum, model.Status, model.DateCreate, model.DateImplement, model.ID,
|
||||||
model.ClientID);
|
model.ClientID, model.ImplementerID);
|
||||||
}
|
}
|
||||||
private bool StatusUpdate(OrderBindingModel model, OrderStatus newOrderStatus) {
|
private bool StatusUpdate(OrderBindingModel model, OrderStatus newOrderStatus) {
|
||||||
CheckModel(model, false);
|
|
||||||
var viewModel = _orderStorage.GetElement(new OrderSearchModel { ID = model.ID });
|
var viewModel = _orderStorage.GetElement(new OrderSearchModel { ID = model.ID });
|
||||||
if (viewModel == null)
|
if (viewModel == null)
|
||||||
{
|
{
|
||||||
@ -89,12 +107,18 @@ namespace DineryBusinessLogic.BusinessLogic
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
model.Status = newOrderStatus;
|
model.Status = newOrderStatus;
|
||||||
|
if (viewModel.ImplementerID.HasValue) {
|
||||||
|
model.ImplementerID = viewModel.ImplementerID;
|
||||||
|
}
|
||||||
if (model.Status == OrderStatus.Готов) {
|
if (model.Status == OrderStatus.Готов) {
|
||||||
model.DateImplement = DateTime.Now;
|
model.DateImplement = DateTime.Now;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
model.DateImplement = viewModel.DateImplement;
|
model.DateImplement = viewModel.DateImplement;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
CheckModel(model, false);
|
||||||
|
|
||||||
if (_orderStorage.Update(model) == null) {
|
if (_orderStorage.Update(model) == null) {
|
||||||
_logger.LogWarning("Update operarion failed");
|
_logger.LogWarning("Update operarion failed");
|
||||||
return false;
|
return false;
|
||||||
|
125
Diner/DineryBusinessLogic/BusinessLogic/WorkModelling.cs
Normal file
125
Diner/DineryBusinessLogic/BusinessLogic/WorkModelling.cs
Normal file
@ -0,0 +1,125 @@
|
|||||||
|
using DinerContracts.BindingModels;
|
||||||
|
using DinerContracts.BusinessLogicsContacts;
|
||||||
|
using DinerContracts.BusinessLogicsContracts;
|
||||||
|
using DinerContracts.SearchModels;
|
||||||
|
using DinerContracts.ViewModels;
|
||||||
|
using DinerDataModels.Enums;
|
||||||
|
using DocumentFormat.OpenXml.Office2010.Excel;
|
||||||
|
using Microsoft.Extensions.Logging;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace DineryBusinessLogic.BusinessLogic {
|
||||||
|
public class WorkModelling : IWorkProcess {
|
||||||
|
|
||||||
|
private readonly ILogger _logger;
|
||||||
|
|
||||||
|
private readonly Random _rnd;
|
||||||
|
|
||||||
|
private IOrderLogic? _orderLogic;
|
||||||
|
|
||||||
|
public WorkModelling(ILogger<WorkModelling> logger) {
|
||||||
|
_logger = logger;
|
||||||
|
_rnd = new Random(1000);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Work(IImplementerLogic implementerLogic, IOrderLogic orderLogic) {
|
||||||
|
_orderLogic = orderLogic;
|
||||||
|
var implementers = implementerLogic.ReadList(null);
|
||||||
|
if (implementers == null) {
|
||||||
|
_logger.LogWarning("DoWork. Implementers is null");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
var orders = _orderLogic.ReadList(new OrderSearchModel {
|
||||||
|
Status = OrderStatus.Принят
|
||||||
|
});
|
||||||
|
if (orders == null || orders.Count == 0) {
|
||||||
|
_logger.LogWarning("DoWork. Orders is null or empty");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
_logger.LogDebug($"DoWork for {orders.Count} orders");
|
||||||
|
foreach (var implementer in implementers) {
|
||||||
|
Task.Run(() => WorkerWorkAsync(implementer, orders));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Иммитация работы исполнителя
|
||||||
|
private async Task WorkerWorkAsync(ImplementerViewModel implementer, List<OrderViewModel> orders) {
|
||||||
|
if (_orderLogic == null || implementer == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
await RunOrderInWork(implementer, orders);
|
||||||
|
await Task.Run(async () => {
|
||||||
|
foreach (var order in orders) {
|
||||||
|
try {
|
||||||
|
_logger.LogDebug($"DoWork. Worker {implementer.ID} try get order {order.ID}");
|
||||||
|
// пытаемся назначить заказ на исполнителя
|
||||||
|
var notOccupied = _orderLogic.TakeOrderInWork(new OrderBindingModel {
|
||||||
|
ID = order.ID,
|
||||||
|
ImplementerID = implementer.ID
|
||||||
|
});
|
||||||
|
// делаем работу
|
||||||
|
if (notOccupied) {
|
||||||
|
await Task.Delay(implementer.WorkExperience * _rnd.Next(100, 1000) * order.Count);
|
||||||
|
|
||||||
|
_logger.LogDebug("DoWork. Worker {Id} finish order { Order}", implementer.ID, order.ID);
|
||||||
|
|
||||||
|
_orderLogic.FinishOrder(new OrderBindingModel { ID = order.ID, ImplementerID = implementer.ID });
|
||||||
|
|
||||||
|
await Task.Delay(implementer.Qualification * _rnd.Next(10, 100));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// кто-то мог уже перехватить заказ, игнорируем ошибку
|
||||||
|
catch (InvalidOperationException ex) {
|
||||||
|
_logger.LogWarning(ex, "Error try get work");
|
||||||
|
}
|
||||||
|
// заканчиваем выполнение имитации в случае иной ошибки
|
||||||
|
catch (Exception ex) {
|
||||||
|
_logger.LogError(ex, "Error while do work");
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
// отдыхаем
|
||||||
|
Thread.Sleep(implementer.Qualification * _rnd.Next(10, 100));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// Ищем заказ, которые уже в работе(вдруг исполнителя прервали)
|
||||||
|
private async Task RunOrderInWork(ImplementerViewModel implementer, List<OrderViewModel> orders) {
|
||||||
|
if (_orderLogic == null || implementer == null || orders == null || orders.Count == 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
var runOrder = await Task.Run(() => _orderLogic.ReadElement(new OrderSearchModel {
|
||||||
|
ImplementerID = implementer.ID,
|
||||||
|
Status = OrderStatus.Выполняется
|
||||||
|
}));
|
||||||
|
if (runOrder == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
_logger.LogDebug($"DoWork. Worker {implementer.ID} back to order {runOrder.ID}");
|
||||||
|
// доделываем работу
|
||||||
|
Thread.Sleep(implementer.WorkExperience * _rnd.Next(100, 300) * runOrder.Count);
|
||||||
|
_logger.LogDebug($"DoWork. Worker{implementer.ID} finish order {runOrder.ID}");
|
||||||
|
_orderLogic.FinishOrder(new OrderBindingModel {
|
||||||
|
ID = runOrder.ID
|
||||||
|
});
|
||||||
|
// отдыхаем
|
||||||
|
Thread.Sleep(implementer.Qualification * _rnd.Next(10, 100));
|
||||||
|
}
|
||||||
|
// заказа может не быть, просто игнорируем ошибку
|
||||||
|
catch (InvalidOperationException ex) {
|
||||||
|
_logger.LogWarning(ex, "Error try get work");
|
||||||
|
}
|
||||||
|
// а может возникнуть иная ошибка, тогда просто заканчиваем выполнение имитации
|
||||||
|
catch (Exception ex) {
|
||||||
|
_logger.LogError(ex, "Error while do work");
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user