add implementer in FlowerShopContracts

This commit is contained in:
DavidMakarov 2024-04-18 18:48:25 +04:00
parent 8d16b12e86
commit d0a85724da
14 changed files with 169 additions and 5 deletions

View File

@ -0,0 +1,13 @@
using FlowerShopDataModels.Models;
namespace FlowerShopContracts.BindingModels
{
public class ImplementerBindingModel : IImplementerModel
{
public int Id { get; set; }
public string ImplementerFIO { get; set; } = string.Empty;
public string Password { get; set; } = string.Empty;
public int WorkExperience { get; set; }
public int Qualification { get; set; }
}
}

View File

@ -8,6 +8,7 @@ namespace FlowerShopContracts.BindingModels
public int Id { get; set; } public int Id { get; set; }
public int FlowerId { get; set; } public int FlowerId { get; set; }
public int ClientId { get; set; } public int ClientId { get; set; }
public int ImplementerId { get; set; } = 0;
public int Count { get; set; } public int Count { get; set; }
public double Sum { get; set; } public double Sum { get; set; }
public OrderStatus Status { get; set; } = OrderStatus.Неизвестен; public OrderStatus Status { get; set; } = OrderStatus.Неизвестен;

View File

@ -0,0 +1,15 @@
using FlowerShopContracts.BindingModels;
using FlowerShopContracts.SearchModels;
using FlowerShopContracts.ViewModels;
namespace FlowerShopContracts.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);
}
}

View File

@ -0,0 +1,8 @@
namespace FlowerShopContracts.SearchModels
{
public class ImplementerSearchModel
{
public int? Id { get; set; }
public string? ImplementerFIO { get; set; }
}
}

View File

@ -1,10 +1,14 @@
namespace FlowerShopContracts.SearchModels using FlowerShopDataModels.Enums;
namespace FlowerShopContracts.SearchModels
{ {
public class OrderSearchModel public class OrderSearchModel
{ {
public int? Id { get; set; } public int? Id { get; set; }
public int? ClientId { get; set; } public int? ClientId { get; set; }
public int? ImplementerId { get; set; }
public DateTime? DateFrom { get; set; } public DateTime? DateFrom { get; set; }
public DateTime? DateTo { get; set; } public DateTime? DateTo { get; set; }
public OrderStatus Status { get; set; }
} }
} }

View File

@ -0,0 +1,16 @@
using FlowerShopContracts.BindingModels;
using FlowerShopContracts.SearchModels;
using FlowerShopContracts.ViewModels;
namespace FlowerShopContracts.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);
}
}

View File

@ -0,0 +1,18 @@
using FlowerShopDataModels.Models;
using System.ComponentModel;
namespace FlowerShopContracts.ViewModels
{
public class ImplementerViewModel : IImplementerModel
{
public int Id { get; set; }
[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; }
}
}

View File

@ -10,10 +10,13 @@ namespace FlowerShopContracts.ViewModels
public int Id { get; set; } public int Id { get; set; }
public int FlowerId { get; set; } public int FlowerId { get; set; }
public int ClientId { get; set; } public int ClientId { get; set; }
public int ImplementerId { get; set; } = 0;
[DisplayName("Изделие")] [DisplayName("Изделие")]
public string FlowerName { get; set; } = string.Empty; public string FlowerName { get; set; } = string.Empty;
[DisplayName("ФИО клиента")] [DisplayName("ФИО клиента")]
public string ClientFIO { get; set; } = string.Empty; public string ClientFIO { get; set; } = string.Empty;
[DisplayName("ФИО исполнителя")]
public string ImplementerFIO { get; set; }=string.Empty;
[DisplayName("Количество")] [DisplayName("Количество")]
public int Count { get; set; } public int Count { get; set; }
[DisplayName("Сумма")] [DisplayName("Сумма")]

View File

@ -0,0 +1,11 @@
namespace FlowerShopDataModels.Models
{
public interface IImplementerModel : IId
{
string ImplementerFIO { get; }
string Password { get; }
int WorkExperience { get; }
int Qualification { get; }
}
}

View File

@ -6,6 +6,7 @@ namespace FlowerShopDataModels.Models
{ {
int FlowerId { get; } int FlowerId { get; }
int ClientId { get; } int ClientId { get; }
int ImplementerId { get; }
int Count { get; } int Count { get; }
double Sum { get; } double Sum { get; }
OrderStatus Status { get; } OrderStatus Status { get; }

View File

@ -9,12 +9,14 @@ namespace FlowerShopListImplement
public List<Order> Orders { get; set; } public List<Order> Orders { get; set; }
public List<Flower> Flowers { get; set; } public List<Flower> Flowers { get; set; }
public List<Client> Clients { get; set; } public List<Client> Clients { get; set; }
public List<Implementer> Implementers { get; set; }
private DataListSingleton() private DataListSingleton()
{ {
Components = new List<Component>(); Components = new List<Component>();
Orders = new List<Order>(); Orders = new List<Order>();
Flowers = new List<Flower>(); Flowers = new List<Flower>();
Clients = new List<Client>(); Clients = new List<Client>();
Implementers = new List<Implementer>();
} }
public static DataListSingleton GetInstance() public static DataListSingleton GetInstance()
{ {

View File

@ -40,6 +40,17 @@ namespace FlowerShopListImplement.Implements
} }
return result; return result;
} }
else if (model.ImplementerId.HasValue)
{
foreach (var order in _source.Orders)
{
if (order.Id == model.Id && order.ImplementerId == model.ImplementerId)
{
result.Add(AttachNames(order.GetViewModel));
}
}
return result;
}
foreach (var order in _source.Orders) foreach (var order in _source.Orders)
{ {
if (order.Id == model.Id && order.DateCreate >= model.DateFrom && order.DateCreate <= model.DateTo) if (order.Id == model.Id && order.DateCreate >= model.DateFrom && order.DateCreate <= model.DateTo)
@ -124,6 +135,14 @@ namespace FlowerShopListImplement.Implements
model.ClientFIO = client.ClientFIO; model.ClientFIO = client.ClientFIO;
return model; return model;
} }
}
foreach (var implementer in _source.Implementers)
{
if (implementer.Id == model.ImplementerId)
{
model.ImplementerFIO = implementer.ImplementerFIO;
return model;
}
} }
return model; return model;
} }

View File

@ -0,0 +1,49 @@
using FlowerShopContracts.BindingModels;
using FlowerShopContracts.ViewModels;
using FlowerShopDataModels.Models;
namespace FlowerShopListImplement.Models
{
public class Implementer : IImplementerModel
{
public int Id { get; private set; }
public string ImplementerFIO { get; private set; }
public string Password { get; private set; }
public int WorkExperience { get; private set; }
public int Qualification { get; private set; }
public static Implementer? Create(ImplementerBindingModel? model)
{
if (model == null)
{
return null;
}
return new Implementer()
{
Id = model.Id,
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;
WorkExperience = model.WorkExperience;
Qualification = model.Qualification;
}
public ImplementerViewModel GetViewModel => new()
{
Id = Id,
ImplementerFIO = ImplementerFIO,
Password = Password,
WorkExperience = WorkExperience,
Qualification = Qualification,
};
}
}

View File

@ -10,6 +10,7 @@ namespace FlowerShopListImplement.Models
public int Id { get; private set; } public int Id { get; private set; }
public int FlowerId { get; private set; } public int FlowerId { get; private set; }
public int ClientId { 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; }
public OrderStatus Status { get; set; } public OrderStatus Status { get; set; }
@ -26,6 +27,7 @@ namespace FlowerShopListImplement.Models
Id = model.Id, Id = model.Id,
FlowerId = model.FlowerId, FlowerId = model.FlowerId,
ClientId = model.ClientId, ClientId = model.ClientId,
ImplementerId = model.ImplementerId,
Count = model.Count, Count = model.Count,
Sum = model.Sum, Sum = model.Sum,
Status = model.Status, Status = model.Status,
@ -42,6 +44,7 @@ namespace FlowerShopListImplement.Models
Id = model.Id; Id = model.Id;
FlowerId = model.FlowerId; FlowerId = model.FlowerId;
ClientId = model.ClientId; ClientId = model.ClientId;
ImplementerId = model.ImplementerId;
Count = model.Count; Count = model.Count;
Sum = model.Sum; Sum = model.Sum;
Status = model.Status; Status = model.Status;
@ -53,6 +56,7 @@ namespace FlowerShopListImplement.Models
Id = Id, Id = Id,
FlowerId = FlowerId, FlowerId = FlowerId,
ClientId = ClientId, ClientId = ClientId,
ImplementerId = ImplementerId,
Count = Count, Count = Count,
Sum = Sum, Sum = Sum,
Status = Status, Status = Status,