Исполнитель: обновил круд
This commit is contained in:
parent
810311ae2e
commit
8a9302f04e
@ -58,6 +58,7 @@ namespace VeterinaryBusinessLogic.BusinessLogic
|
||||
}
|
||||
return true;
|
||||
}
|
||||
// dateImplement
|
||||
private void CheckModel(PurchaseBindingModel model, bool withParams = true)
|
||||
{
|
||||
if (model == null)
|
||||
|
@ -10,6 +10,7 @@ namespace VeterinaryContracts.BindingModels
|
||||
public int Count { get; set; }
|
||||
public double Sum { get; set; }
|
||||
public DateTime DateCreate { get; set; }
|
||||
public DateTime DateImplement { get; set; }
|
||||
public Dictionary<int, IPetModel> PurchasePet { get; set; } = new();
|
||||
}
|
||||
}
|
||||
|
@ -6,5 +6,6 @@
|
||||
public int? OwnerId { get; set; }
|
||||
public int? DrugId { get; set; }
|
||||
public DateTime? DateCreate { get; set; }
|
||||
public DateTime? DateImplement { get; set;}
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,4 @@
|
||||
using System.ComponentModel;
|
||||
using VeterinaryDataModels.Enums;
|
||||
using VeterinaryDataModels.Models;
|
||||
|
||||
namespace VeterinaryContracts.ViewModels
|
||||
@ -17,6 +16,8 @@ namespace VeterinaryContracts.ViewModels
|
||||
public double Sum { get; set; }
|
||||
[DisplayName("Дата покупки")]
|
||||
public DateTime DateCreate { get; set; }
|
||||
[DisplayName("Дата завершения покупки")]
|
||||
public DateTime DateImplement { get; set; }
|
||||
public Dictionary<int, IPetModel> PurchasePet { get; set; } = new();
|
||||
}
|
||||
}
|
||||
|
@ -7,6 +7,7 @@
|
||||
int Count { get; }
|
||||
double Sum { get; }
|
||||
DateTime DateCreate { get; }
|
||||
Dictionary<int, IPetModel> PurchasePet { get; }
|
||||
DateTime DateImplement { get; }
|
||||
Dictionary<int, IPetModel> PurchasePet { get; }
|
||||
}
|
||||
}
|
||||
|
@ -22,7 +22,6 @@ namespace VeterinaryDatabaseImplement.Implements
|
||||
return context.Purchases.Include(x => x.Owner).Include(x => x.Pets).ThenInclude(x => x.Pet).Include(x => x.Drug)
|
||||
.Where(x => ((!model.Id.HasValue || x.Id == model.Id) &&
|
||||
(!model.DateCreate.HasValue || x.DateCreate >= model.DateCreate) &&
|
||||
(!model.DateImplement.HasValue || x.DateImplement >= model.DateImplement) &&
|
||||
(!model.OwnerId.HasValue || x.OwnerId <= model.OwnerId) &&
|
||||
(!model.DrugId.HasValue || x.DrugId == model.DrugId)))
|
||||
.Select(x => x.GetViewModel)
|
||||
|
@ -2,7 +2,6 @@
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using VeterinaryContracts.BindingModels;
|
||||
using VeterinaryContracts.ViewModels;
|
||||
using VeterinaryDataModels.Enums;
|
||||
using VeterinaryDataModels.Models;
|
||||
|
||||
namespace VeterinaryDatabaseImplement.Models
|
||||
@ -21,10 +20,9 @@ namespace VeterinaryDatabaseImplement.Models
|
||||
[Required]
|
||||
public double Sum { get; private set; }
|
||||
[Required]
|
||||
public PurchaseStatus Status { get; private set; }
|
||||
[Required]
|
||||
public DateTime DateCreate { get; private set; }
|
||||
public DateTime DateImplement { get; private set; }
|
||||
[Required]
|
||||
public DateTime DateImplement { get; private set; }
|
||||
private Dictionary<int, IPetModel>? _purchasePet = null;
|
||||
[NotMapped]
|
||||
public Dictionary<int, IPetModel> PurchasePet
|
||||
@ -51,9 +49,7 @@ namespace VeterinaryDatabaseImplement.Models
|
||||
Sum = model.Sum,
|
||||
OwnerId = model.OwnerId,
|
||||
DrugId = model.DrugId,
|
||||
Status = model.Status,
|
||||
DateCreate = model.DateCreate,
|
||||
DateImplement = model.DateImplement,
|
||||
Pets = model.PurchasePet.Select(x => new PurchasePet
|
||||
{
|
||||
Pet = context.Pets.First(y => y.Id == x.Key),
|
||||
@ -67,7 +63,6 @@ namespace VeterinaryDatabaseImplement.Models
|
||||
{
|
||||
return;
|
||||
}
|
||||
Status = model.Status;
|
||||
DateImplement = model.DateImplement;
|
||||
}
|
||||
public PurchaseViewModel GetViewModel => new()
|
||||
@ -77,7 +72,6 @@ namespace VeterinaryDatabaseImplement.Models
|
||||
Sum = Sum,
|
||||
OwnerId = OwnerId,
|
||||
DrugId = DrugId,
|
||||
Status = Status,
|
||||
DateCreate = DateCreate,
|
||||
DateImplement = DateImplement
|
||||
};
|
||||
|
@ -3,7 +3,6 @@ using System.ComponentModel.DataAnnotations;
|
||||
using VeterinaryContracts.BindingModels;
|
||||
using VeterinaryContracts.ViewModels;
|
||||
using VeterinaryDataModels.Models;
|
||||
using VeterinaryDataModels.Enums;
|
||||
|
||||
namespace VeterinaryDatabaseImplement.Models
|
||||
{
|
||||
@ -17,9 +16,7 @@ namespace VeterinaryDatabaseImplement.Models
|
||||
public int? DoctorId { get; private set; }
|
||||
public virtual Doctor? Doctor { get; private set; }
|
||||
[Required]
|
||||
public string VisitName { get; private set; }
|
||||
[Required]
|
||||
public VisitStatus Status { get; private set; }
|
||||
public string VisitName { get; private set; } = string.Empty;
|
||||
[Required]
|
||||
public DateTime DateVisit { get; private set; }
|
||||
private Dictionary<int, IPetModel>? _visitPet = null;
|
||||
@ -48,7 +45,7 @@ namespace VeterinaryDatabaseImplement.Models
|
||||
Id = model.Id,
|
||||
OwnerId = model.OwnerId,
|
||||
DoctorId = model.DoctorId,
|
||||
Status = model.Status,
|
||||
VisitName = model.VisitName,
|
||||
DateVisit = model.DateVisit,
|
||||
Pets = model.VisitPet.Select(x => new VisitPet
|
||||
{
|
||||
@ -63,14 +60,14 @@ namespace VeterinaryDatabaseImplement.Models
|
||||
{
|
||||
return;
|
||||
}
|
||||
Status = model.Status;
|
||||
VisitName = model.VisitName;
|
||||
}
|
||||
public VisitViewModel GetViewModel => new()
|
||||
{
|
||||
Id = Id,
|
||||
OwnerId = OwnerId,
|
||||
VisitName = VisitName,
|
||||
DoctorId = DoctorId,
|
||||
Status = Status,
|
||||
DateVisit = DateVisit
|
||||
};
|
||||
}
|
||||
|
@ -52,7 +52,7 @@ namespace VeterinaryRestApi.Controllers
|
||||
{
|
||||
try
|
||||
{
|
||||
return _visit.CreateVisit(model);
|
||||
return _visit.Create(model);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user