правки_и_создание_модуля_для_взаимодействия_с_пользователем #10

Closed
TabeevAlexander wants to merge 3 commits from правки_и_создание_модуля_для_взаимодействия_с_пользователем into main
12 changed files with 38 additions and 22 deletions
Showing only changes of commit 90e61af973 - Show all commits

View File

@ -18,6 +18,8 @@ namespace ServiceStationContracts.BindingModels
public int ExecutorId { get; set; }
public int? RepairId { get; set; }
public Dictionary<int, ICarModel> DefectCars { get; set; } = new();
}
}

View File

@ -20,7 +20,7 @@ namespace ServiceStationContracts.BindingModels
public int GuarantorId { get; set; }
public int TechnicalWorkId { get; set; }
public int? TechnicalWorkId { get; set; }
public Dictionary<int, ISparePartModel> WorkSpareParts { get; set; } = new();
}

View File

@ -21,6 +21,8 @@ namespace ServiceStationContracts.ViewModels
public int ExecutorId { get; set; }
public int? RepairId { get; set; }
public Dictionary<int, ICarModel> DefectCars { get; set; } = new();
}
}

View File

@ -24,8 +24,8 @@ namespace ServiceStationContracts.ViewModels
public int GuarantorId { get; set; }
public int TechnicalWorkId { get; set; }
public int? TechnicalWorkId { get; set; }
public Dictionary<int, ISparePartModel> WorkSpareParts { get; } = new();
public Dictionary<int, ISparePartModel> WorkSpareParts { get; set; } = new();
}
}

View File

@ -12,6 +12,7 @@ namespace ServiceStationDataModels.Models
string DefectType { get; }
double DefectPrice { get; }
int ExecutorId { get; }
int? RepairId { get; }
public Dictionary<int, ICarModel> DefectCars { get; }
}
}

View File

@ -16,8 +16,6 @@ namespace ServiceStationDataModels.Models
int GuarantorId { get; }
int DefectId { get; }
public Dictionary<int, ISparePartModel> RepairSpareParts { get; }
}
}

View File

@ -16,7 +16,7 @@ namespace ServiceStationDataModels.Models
int GuarantorId { get; }
int TechnicalWorkId { get; }
int? TechnicalWorkId { get; }
public Dictionary<int, ISparePartModel> WorkSpareParts { get; }
}

View File

@ -23,7 +23,7 @@ namespace ServiceStationDatabaseImplement.Implements
.ThenInclude(x => x.Car)
.ThenInclude(x => x.CarTechnicalWorks)
.ThenInclude(x => x.TechnicalWork)
.Include(x => x.Repairs)
.Include(x => x.Repair)
.Include(x => x.Executor)
.Select(x => x.GetViewModel)
.ToList();
@ -41,7 +41,7 @@ namespace ServiceStationDatabaseImplement.Implements
.ThenInclude(x => x.Car)
.ThenInclude(x => x.CarTechnicalWorks)
.ThenInclude(x => x.TechnicalWork)
.Include(x => x.Repairs)
.Include(x => x.Repair)
.Include(x => x.Executor)
.Where(x => x.ExecutorId == model.ExecutorId)
.ToList()
@ -53,7 +53,7 @@ namespace ServiceStationDatabaseImplement.Implements
.ThenInclude(x => x.Car)
.ThenInclude(x => x.CarTechnicalWorks)
.ThenInclude(x => x.TechnicalWork)
.Include(x => x.Repairs)
.Include(x => x.Repair)
.Include(x => x.Executor)
.Where(x => x.DefectType == model.DefectType)
.ToList()
@ -72,7 +72,7 @@ namespace ServiceStationDatabaseImplement.Implements
.ThenInclude(x => x.Car)
.ThenInclude(x => x.CarTechnicalWorks)
.ThenInclude(x => x.TechnicalWork)
.Include(x => x.Repairs)
.Include(x => x.Repair)
.Include(x => x.Executor)
.FirstOrDefault(x => (!string.IsNullOrEmpty(model.DefectType) && x.DefectType == model.DefectType) || (model.Id.HasValue && x.Id == model.Id))?
.GetViewModel;

View File

@ -25,7 +25,10 @@ namespace ServiceStationDatabaseImplement.Models
[Required]
public int ExecutorId { get; set; }
public int? RepairId { get; set; }
public virtual Executor Executor { get; set; }
public virtual Repair? Repair { get; set; }
private Dictionary<int, ICarModel>? _defectCars = null;
@ -43,8 +46,6 @@ namespace ServiceStationDatabaseImplement.Models
}
[ForeignKey("DefectId")]
public virtual List<CarDefect> Cars { get; set; } = new();
[ForeignKey("DefectId")]
public virtual List<Repair> Repairs { get; set; } = new();
public static Defect? Create(ServiceStationDatabase context, DefectBindingModel model)
{
@ -65,6 +66,11 @@ namespace ServiceStationDatabaseImplement.Models
public void Update(DefectBindingModel model)
{
if(model == null) return;
if (model.RepairId.HasValue)
{
RepairId = model.RepairId;
return;
}
DefectType = model.DefectType;
DefectPrice = model.DefectPrice;
}

View File

@ -28,13 +28,14 @@ namespace ServiceStationDatabaseImplement.Models
[Required]
public int GuarantorId { get; set; }
[Required]
public int DefectId { get; set; }
[ForeignKey("RepairId")]
public virtual List<Defect> Defects { get; set; } = new();
public virtual Guarantor Guarantor { get; set; }
private Dictionary<int, ISparePartModel>? _repairSpareParts = null;
[NotMapped]
public Dictionary<int, ISparePartModel> RepairSpareParts
{
get
@ -60,7 +61,6 @@ namespace ServiceStationDatabaseImplement.Models
Status = model.Status,
RepairPrice = model.RepairPrice,
GuarantorId = model.GuarantorId,
DefectId = model.DefectId,
SpareParts = model.RepairSpareParts.Select(x => new SparePartRepair
{
SparePart = context.SpareParts.First(y => y.Id == x.Key)
@ -83,7 +83,6 @@ namespace ServiceStationDatabaseImplement.Models
Status = Status,
RepairPrice = RepairPrice,
GuarantorId = GuarantorId,
DefectId = DefectId,
RepairSpareParts = RepairSpareParts
};

View File

@ -26,7 +26,6 @@ namespace ServiceStationDatabaseImplement.Models
[Required]
public int ExecutorId { get; set; }
public virtual Executor Executor { get; set; }
public virtual Work Work { get; set; }
private Dictionary<int, ICarModel>? _technicalWorkCars = null;
public Dictionary<int, ICarModel> TechnicalWorkCars
@ -43,6 +42,9 @@ namespace ServiceStationDatabaseImplement.Models
[ForeignKey("TechnicalWorkId")]
public virtual List<CarTechnicalWork> Cars { get; set; } = new();
[ForeignKey("TechnicalWorkId")]
public virtual List<Work> Works { get; set; } = new();
public static TechnicalWork? Create(ServiceStationDatabase context, TechnicalWorkBindingModel model)
{
if (model == null) return null;
@ -73,6 +75,7 @@ namespace ServiceStationDatabaseImplement.Models
WorkType = WorkType,
DateStartWork = DateStartWork,
WorkPrice = WorkPrice,
TechnicalWorkCars = TechnicalWorkCars,
ExecutorId = ExecutorId
};

View File

@ -28,8 +28,9 @@ namespace ServiceStationDatabaseImplement.Models
[Required]
public int GuarantorId { get; set; }
[Required]
public int TechnicalWorkId { get; set; }
public int? TechnicalWorkId { get; set; }
public virtual TechnicalWork? TechnicalWork { get; set; }
public virtual Guarantor Guarantor { get; set; }
@ -50,9 +51,6 @@ namespace ServiceStationDatabaseImplement.Models
[ForeignKey("WorkId")]
public virtual List<SparePartWork> SpareParts { get; set; } = new();
[ForeignKey("WorkId")]
public virtual List<TechnicalWork> TechnicalWorks { get; set; } = new();
public static Work? Create(ServiceStationDatabase context, WorkBindingModel model)
{
if (model == null) return null;
@ -73,6 +71,12 @@ namespace ServiceStationDatabaseImplement.Models
public void Update(WorkBindingModel model)
{
if (model == null) return;
if (model.TechnicalWorkId.HasValue)
{
TechnicalWorkId = model.TechnicalWorkId;
return;
}
WorkName = model.WorkName;
Status = model.Status;
WorkPrice = model.WorkPrice;
@ -86,6 +90,7 @@ namespace ServiceStationDatabaseImplement.Models
Status = Status,
WorkPrice = WorkPrice,
GuarantorId = GuarantorId,
WorkSpareParts = WorkSpareParts,
TechnicalWorkId = TechnicalWorkId
};