This commit is contained in:
Kate 2023-05-02 23:45:39 +03:00
parent c6d13da0f3
commit de4c8fe78f
9 changed files with 77 additions and 22 deletions

View File

@ -58,7 +58,7 @@ namespace PrecastConcretePlantFileImplement.Models
var order = new Order()
{
Id = Convert.ToInt32(element.Attribute("Id")!.Value),
ImplementerId = Convert.ToInt32(element.Element("ImplementerId")!.Value)
ImplementerId = Convert.ToInt32(element.Element("ImplementerId")!.Value),
ReinforcedId = Convert.ToInt32(element.Element("ReinforcedId")!.Value),
ClientId = Convert.ToInt32(element.Element("ClientId")!.Value),
Count = Convert.ToInt32(element.Element("Count")!.Value),

View File

@ -104,9 +104,9 @@ namespace PrecastConcretePlantBusinessLogic.BusinessLogic
{
throw new ArgumentNullException("Квалификация должна быть больше 0", nameof(model.Qualification));
}
if (model.WorkExperience <= 0)
if (model.WorkExperience < 0)
{
throw new ArgumentNullException("Стаж должен быть больше 0", nameof(model.WorkExperience));
throw new ArgumentNullException("Стаж должен быть не меньше 0", nameof(model.WorkExperience));
}
if (string.IsNullOrEmpty(model.Password))
{

View File

@ -108,6 +108,7 @@ namespace PrecastConcretePlantBusinessLogic.BusinessLogic
public bool FinishOrder(OrderBindingModel model)
{
model.DateImplement=DateTime.Now;
return StatusUpdate(model, OrderStatus.Выдан);
}
public List<OrderViewModel>? ReadList(OrderSearchModel? model)

View File

@ -82,6 +82,7 @@ namespace PrecastConcretePlantBusinessLogic.BusinessLogic
Id = order.Id
});
Thread.Sleep(implementer.Qualification * _rnd.Next(10, 100));
}
catch (InvalidOperationException ex)
@ -94,8 +95,6 @@ namespace PrecastConcretePlantBusinessLogic.BusinessLogic
_logger.LogError(ex, "Error while do work");
throw;
}
Thread.Sleep(implementer.Qualification * _rnd.Next(10, 100));
}
});
}

View File

@ -14,7 +14,7 @@ namespace PrecastConcretePlantContracts.SearchModels
public int? ImplementerId { get; set; }
public DateTime? DateFrom { get; set; }
public DateTime? DateTo { get; set; }
public List<OrderStatus>? Status { get; set; }
public List<OrderStatus>? Statuses { get; set; }
}
}

View File

@ -44,15 +44,11 @@ namespace PrecastConcretePlantDatabaseImplement.Implements
using var context = new PrecastConcretePlantDatabase();
return context.Orders
.Include(x => x.Client)
.Include(x => x.Implementer)
.FirstOrDefault(x =>
(model.Status == null || model.Status != null && model.Status.Contains(x.Status)) &&
return context.Orders.Include(x => x.Client).Include(x => x.Implementer).FirstOrDefault(x =>
(model.Statuses == null || model.Statuses != null && model.Statuses.Contains(x.Status)) &&
model.ImplementerId.HasValue && x.ImplementerId == model.ImplementerId ||
model.Id.HasValue && x.Id == model.Id
)
?.GetViewModel;
)?.GetViewModel;
}
public List<OrderViewModel> GetFilteredList(OrderSearchModel model)
@ -73,9 +69,9 @@ namespace PrecastConcretePlantDatabaseImplement.Implements
x.DateCreate.Date <= model.DateTo);
}
else if (model.Status != null)
else if (model.Statuses != null)
{
queryWhere = context.Orders.Where(x => model.Status.Contains(x.Status));
queryWhere = context.Orders.Where(x => model.Statuses.Contains(x.Status));
}
else if (model.ClientId.HasValue)
@ -120,12 +116,7 @@ namespace PrecastConcretePlantDatabaseImplement.Implements
context.Orders.Add(newOrder);
context.SaveChanges();
return context.Orders
.Include(x => x.Reinforced)
.Include(x => x.Client)
.Include(x => x.Implementer)
.FirstOrDefault(x => x.Id == newOrder.Id)
?.GetViewModel;
return newOrder.GetViewModel;
}
public OrderViewModel? Update(OrderBindingModel model)

View File

@ -11,6 +11,7 @@ namespace PrecastConcretePlantDataModels.Models
{
int ReinforcedId { get; }
int ClientId { get; }
int? ImplementerId { get; }
int Count { get; }
double Sum { get; }
OrderStatus Status { get; }

View File

@ -0,0 +1,60 @@
using PrecastConcretePlantContracts.BindingModels;
using PrecastConcretePlantContracts.ViewModels;
using PrecastConcretePlantDataModels.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace PrecastConcretePlantListImplement.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,
};
}
}

View File

@ -14,6 +14,7 @@ namespace PrecastConcretePlantListImplement.Models
{
public int ClientId { get; private set; }
public int ReinforcedId { get; private set; }
public int? ImplementerId { get; private set; }
public int Count { get; private set; }
public double Sum { get; private set; }
@ -41,7 +42,8 @@ namespace PrecastConcretePlantListImplement.Models
Sum = model.Sum,
Status = model.Status,
DateCreate = model.DateCreate,
DateImplement = model.DateImplement
DateImplement = model.DateImplement,
ImplementerId = model.ImplementerId
};
}
@ -64,6 +66,7 @@ namespace PrecastConcretePlantListImplement.Models
Sum = Sum,
Status = Status,
DateCreate = DateCreate,
ImplementerId= ImplementerId,
DateImplement = DateImplement
};
}