мердж изменений #19
@ -0,0 +1,8 @@
|
||||
using BlacksmithWorkshopDataModels.Models;
|
||||
|
||||
namespace BlacksmithWorkshopFileImplement.Models
|
||||
{
|
||||
public class Implementer : IImplementerModel
|
||||
{
|
||||
}
|
||||
}
|
@ -9,13 +9,15 @@ namespace BlacksmithWorkshopListImplement
|
||||
public List<Order> Orders { get; set; }
|
||||
public List<Manufacture> Manufactures { get; set; }
|
||||
public List<Client> Clients { get; set; }
|
||||
private DataListSingleton()
|
||||
public List<Implementer> Implementers { get; set; }
|
||||
private DataListSingleton()
|
||||
{
|
||||
Components = new List<Component>();
|
||||
Orders = new List<Order>();
|
||||
Manufactures = new List<Manufacture>();
|
||||
Clients = new List<Client>();
|
||||
}
|
||||
Implementers = new List<Implementer>();
|
||||
}
|
||||
public static DataListSingleton GetInstance()
|
||||
{
|
||||
if (_instance == null)
|
||||
|
@ -0,0 +1,119 @@
|
||||
using BlacksmithWorkshopContracts.BindingModels;
|
||||
using BlacksmithWorkshopContracts.SearchModels;
|
||||
using BlacksmithWorkshopContracts.StoragesContracts;
|
||||
using BlacksmithWorkshopContracts.ViewModels;
|
||||
using BlacksmithWorkshopListImplement.Models;
|
||||
|
||||
namespace BlacksmithWorkshopListImplement.Implements
|
||||
{
|
||||
public class ImplementerStorage : IImplementerStorage
|
||||
{
|
||||
private readonly DataListSingleton _source;
|
||||
public ImplementerStorage()
|
||||
{
|
||||
_source = DataListSingleton.GetInstance();
|
||||
}
|
||||
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)
|
||||
{
|
||||
foreach (var implementer in _source.Implementers)
|
||||
{
|
||||
if (model.Id.HasValue && implementer.Id == model.Id)
|
||||
{
|
||||
return implementer.GetViewModel;
|
||||
}
|
||||
if (model.ImplementerFIO != null && model.Password != null && implementer.ImplementerFIO.Equals(model.ImplementerFIO) && implementer.Password.Equals(model.Password))
|
||||
{
|
||||
return implementer.GetViewModel;
|
||||
}
|
||||
if (model.ImplementerFIO != null && implementer.ImplementerFIO.Equals(model.ImplementerFIO))
|
||||
{
|
||||
return implementer.GetViewModel;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
public List<ImplementerViewModel> GetFilteredList(ImplementerSearchModel model)
|
||||
{
|
||||
var result = new List<ImplementerViewModel>();
|
||||
if (!model.Id.HasValue && string.IsNullOrEmpty(model.ImplementerFIO))
|
||||
{
|
||||
return result;
|
||||
}
|
||||
if (model.Id.HasValue)
|
||||
{
|
||||
foreach (var implementer in _source.Implementers)
|
||||
{
|
||||
if (implementer.Id == model.Id)
|
||||
{
|
||||
result.Add(implementer.GetViewModel);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
else
|
||||
{
|
||||
foreach (var implementer in _source.Implementers)
|
||||
{
|
||||
if (implementer.ImplementerFIO == 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;
|
||||
}
|
||||
|
||||
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 res = Implementer.Create(model);
|
||||
if (res != null)
|
||||
{
|
||||
_source.Implementers.Add(res);
|
||||
}
|
||||
return res?.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;
|
||||
}
|
||||
}
|
||||
}
|
@ -79,7 +79,22 @@ namespace BlacksmithWorkshopListImplement.Implements
|
||||
}
|
||||
}
|
||||
}
|
||||
return result;
|
||||
else if (model.Status.HasValue)//далее ищем по статусу
|
||||
{
|
||||
foreach (var order in _source.Orders)
|
||||
{
|
||||
if (order.Status == model.Status)
|
||||
{
|
||||
OrderViewModel vm = order.GetViewModel;
|
||||
var manufacture = _source.Manufactures.Find(x => x.Id == order.ManufactureId);
|
||||
vm.ManufactureName = manufacture?.ManufactureName ?? string.Empty;
|
||||
var client = _source.Clients.Find(x => x.Id == order.ClientId);
|
||||
vm.ClientFIO = client?.ClientFIO ?? string.Empty;
|
||||
result.Add(vm);
|
||||
}
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
public OrderViewModel? GetElement(OrderSearchModel model)
|
||||
{
|
||||
@ -98,7 +113,34 @@ namespace BlacksmithWorkshopListImplement.Implements
|
||||
vm.ClientFIO = client?.ClientFIO ?? string.Empty;
|
||||
return vm;
|
||||
}
|
||||
}
|
||||
else if (model.ImplementerId.HasValue && order.ImplementerId == model.ImplementerId)
|
||||
{
|
||||
OrderViewModel vm = order.GetViewModel;
|
||||
var manufacture = _source.Manufactures.Find(x => x.Id == order.ManufactureId);
|
||||
vm.ManufactureName = manufacture?.ManufactureName ?? string.Empty;
|
||||
var client = _source.Clients.Find(x => x.Id == order.ClientId);
|
||||
vm.ClientFIO = client?.ClientFIO ?? string.Empty;
|
||||
return vm;
|
||||
}
|
||||
else if (model.ImplementerId.HasValue && !model.Status.HasValue)
|
||||
{
|
||||
OrderViewModel vm = order.GetViewModel;
|
||||
var manufacture = _source.Manufactures.Find(x => x.Id == order.ManufactureId);
|
||||
vm.ManufactureName = manufacture?.ManufactureName ?? string.Empty;
|
||||
var client = _source.Clients.Find(x => x.Id == order.ClientId);
|
||||
vm.ClientFIO = client?.ClientFIO ?? string.Empty;
|
||||
return vm;
|
||||
}
|
||||
else if (model.ImplementerId.HasValue && model.Status.HasValue)
|
||||
{
|
||||
OrderViewModel vm = order.GetViewModel;
|
||||
var manufacture = _source.Manufactures.Find(x => x.Id == order.ManufactureId);
|
||||
vm.ManufactureName = manufacture?.ManufactureName ?? string.Empty;
|
||||
var client = _source.Clients.Find(x => x.Id == order.ClientId);
|
||||
vm.ClientFIO = client?.ClientFIO ?? string.Empty;
|
||||
return vm;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
public OrderViewModel? Insert(OrderBindingModel model)
|
||||
|
@ -0,0 +1,48 @@
|
||||
using BlacksmithWorkshopContracts.BindingModels;
|
||||
using BlacksmithWorkshopContracts.ViewModels;
|
||||
using BlacksmithWorkshopDataModels.Models;
|
||||
|
||||
namespace BlacksmithWorkshopListImplement.Models
|
||||
{
|
||||
public class Implementer : IImplementerModel
|
||||
{
|
||||
public int Id { get; private set; }
|
||||
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 static Implementer? Create(ImplementerBindingModel model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return new()
|
||||
{
|
||||
Id = model.Id,
|
||||
Password = model.Password,
|
||||
Qualification = model.Qualification,
|
||||
ImplementerFIO = model.ImplementerFIO,
|
||||
WorkExperience = model.WorkExperience,
|
||||
};
|
||||
}
|
||||
public void Update(ImplementerBindingModel model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
Password = model.Password;
|
||||
Qualification = model.Qualification;
|
||||
ImplementerFIO = model.ImplementerFIO;
|
||||
WorkExperience = model.WorkExperience;
|
||||
}
|
||||
public ImplementerViewModel GetViewModel => new()
|
||||
{
|
||||
Id = Id,
|
||||
Password = Password,
|
||||
Qualification = Qualification,
|
||||
ImplementerFIO = ImplementerFIO,
|
||||
};
|
||||
}
|
||||
}
|
@ -16,9 +16,8 @@ namespace BlacksmithWorkshopListImplement.Models
|
||||
public DateTime DateCreate { get; private set; } = DateTime.Now;
|
||||
public DateTime? DateImplement { get; private set; }
|
||||
public int ClientId { get; private set; }
|
||||
//TODO
|
||||
public int? ImplementerId => throw new NotImplementedException();
|
||||
public static Order? Create(OrderBindingModel? model)
|
||||
public int? ImplementerId { get; private set; }
|
||||
public static Order? Create(OrderBindingModel? model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
@ -33,7 +32,8 @@ namespace BlacksmithWorkshopListImplement.Models
|
||||
Status = model.Status,
|
||||
DateCreate = model.DateCreate,
|
||||
DateImplement = model.DateImplement,
|
||||
ClientId = model.ClientId
|
||||
ClientId = model.ClientId,
|
||||
ImplementerId = model.ImplementerId
|
||||
};
|
||||
}
|
||||
public void Update(OrderBindingModel? model)
|
||||
@ -43,6 +43,10 @@ namespace BlacksmithWorkshopListImplement.Models
|
||||
return;
|
||||
}
|
||||
Status = model.Status;
|
||||
if (model.ImplementerId != null)
|
||||
{
|
||||
ImplementerId = model.ImplementerId;
|
||||
}
|
||||
if (model.DateImplement != null)
|
||||
{
|
||||
DateImplement = model.DateImplement;
|
||||
@ -57,6 +61,7 @@ namespace BlacksmithWorkshopListImplement.Models
|
||||
Status = Status,
|
||||
DateCreate = DateCreate,
|
||||
DateImplement = DateImplement,
|
||||
};
|
||||
ImplementerFIO = DataListSingleton.GetInstance().Implementers.SingleOrDefault(x => x.Id == ImplementerId)?.ImplementerFIO ?? string.Empty
|
||||
};
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user