Compare commits

...

5 Commits

15 changed files with 837 additions and 14 deletions

View File

@ -0,0 +1,134 @@
using ServiceStationContracts.BindingModels;
using ServiceStationContracts.BusinessLogicsContracts;
using ServiceStationContracts.SearchModels;
using ServiceStationContracts.StoragesContracts;
using ServiceStationContracts.ViewModels;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ServiceStationBusinessLogic.BusinessLogics
{
public class ExecutorReportLogic : IExecutorReportLogic
{
private readonly ITechnicalWorkStorage _techWorkStorage;
private readonly IRepairStorage _repairStorage;
private readonly IWorkStorage _workStorage;
private readonly ICarStorage _carStorage;
public ExecutorReportLogic(ITechnicalWorkStorage technicalWorkStorage, IRepairStorage repairStorage, IWorkStorage workStorage, ICarStorage carStorage)
{
_techWorkStorage = technicalWorkStorage;
_repairStorage = repairStorage;
_workStorage = workStorage;
_carStorage = carStorage;
}
public List<ReportWorksViewModel> GetWorks(List<int> Ids)
{
if(Ids == null) return new List<ReportWorksViewModel>();
List<ReportWorksViewModel> allList = new List<ReportWorksViewModel>();
var works = _workStorage.GetFullList();
List<CarViewModel> cars = new List<CarViewModel>();
foreach (var carId in Ids)
{
var car = _carStorage.GetElement(new CarSearchModel
{
Id = carId,
});
if(car != null)
{
cars.Add(car);
}
}
foreach(var car in cars)
{
var rec = new ReportWorksViewModel
{
CarNumber = car.CarNumber,
WorksInfo = new List<(string, double)>()
};
foreach(var work in works)
{
var techWork = _techWorkStorage.GetElement(new TechnicalWorkSearchModel
{
Id = work.TechnicalWorkId,
});
foreach(var techCars in techWork.TechnicalWorkCars.Values)
{
if(techCars.Id == car.Id)
{
rec.WorksInfo.Add(new(work.WorkName, work.WorkPrice));
}
}
}
allList.Add(rec);
}
return allList;
}
public List<ReportCarsViewModel> GetCars(ReportBindingModel model)
{
List<ReportCarsViewModel> allList = new List<ReportCarsViewModel>();
List<TechnicalWorkViewModel> techWorkList = _techWorkStorage.GetFilteredList(new TechnicalWorkSearchModel
{
DateFrom = model.DateFrom,
DateTo = model.DateTo,
});
foreach(var techWork in techWorkList)
{
foreach(var car in techWork.TechnicalWorkCars.Values)
{
allList.Add(new ReportCarsViewModel
{
CarNumber = car.CarNumber,
CarBrand = car.CarBrand,
WorkType = techWork.WorkType,
TechnicalWorkDate = techWork.DateStartWork,
TechnicalWorkPrice = techWork.WorkPrice,
});
}
}
List<RepairViewModel> repairList = _repairStorage.GetFilteredList(new RepairSearchModel
{
DateFrom = model.DateFrom,
DateTo = model.DateTo,
});
foreach(var repair in repairList)
{
allList.Add(new ReportCarsViewModel
{
RepairName = repair.RepairName,
RepairStartDate = repair.RepairStartDate,
RepairPrice = repair.RepairPrice,
});
}
return allList;
}
public void SaveComponentsToWordFile(ReportBindingModel model)
{
throw new NotImplementedException();
}
public void SaveOrdersToPdfFile(ReportBindingModel model)
{
throw new NotImplementedException();
}
public void SaveRepairComponentToExcelFile(ReportBindingModel model)
{
throw new NotImplementedException();
}
}
}

View File

@ -14,7 +14,7 @@ namespace ServiceStationContracts.BindingModels
public string RepairName { get; set; } = string.Empty; public string RepairName { get; set; } = string.Empty;
public RepairStatus Status { get; set; } = RepairStatus.Неизвестен; public DateTime? RepairStartDate { get; set; } = DateTime.Now;
public double RepairPrice { get; set; } public double RepairPrice { get; set; }

View File

@ -0,0 +1,19 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ServiceStationContracts.BindingModels
{
public class ReportBindingModel
{
public string FileName { get; set; } = string.Empty;
public int ExecutorId { get; set; }
public DateTime? DateFrom { get; set; }
public DateTime? DateTo { get; set; }
}
}

View File

@ -0,0 +1,22 @@
using ServiceStationContracts.BindingModels;
using ServiceStationContracts.ViewModels;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ServiceStationContracts.BusinessLogicsContracts
{
public interface IExecutorReportLogic
{
List<ReportWorksViewModel> GetWorks(List<int> Ids);
List<ReportCarsViewModel> GetCars(ReportBindingModel model);
void SaveComponentsToWordFile(ReportBindingModel model);
void SaveRepairComponentToExcelFile(ReportBindingModel model);
void SaveOrdersToPdfFile(ReportBindingModel model);
}
}

View File

@ -12,5 +12,7 @@ namespace ServiceStationContracts.SearchModels
public string? RepairName { get; set; } public string? RepairName { get; set; }
public int? GuarantorId { get; set; } public int? GuarantorId { get; set; }
public int? DefectId { get; set; } public int? DefectId { get; set; }
public DateTime? DateFrom { get; set; }
public DateTime? DateTo { get; set; }
} }
} }

View File

@ -16,8 +16,8 @@ namespace ServiceStationContracts.ViewModels
[DisplayName("Наименование ремонта")] [DisplayName("Наименование ремонта")]
public string RepairName { get; set; } = string.Empty; public string RepairName { get; set; } = string.Empty;
[DisplayName("Статус ремонта")] [DisplayName("Начало ремонта")]
public RepairStatus Status { get; set; } public DateTime? RepairStartDate { get; set; } = DateTime.Now;
[DisplayName("Стоимость ремонта")] [DisplayName("Стоимость ремонта")]
public double RepairPrice { get; set; } public double RepairPrice { get; set; }

View File

@ -0,0 +1,21 @@
using ServiceStationDataModels.Enums;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ServiceStationContracts.ViewModels
{
public class ReportCarsViewModel
{
public string CarNumber { get; set; } = string.Empty;
public string CarBrand { get; set; } = string.Empty;
public string WorkType { get; set; } = string.Empty;
public DateTime? TechnicalWorkDate { get; set; } = DateTime.Now;
public double TechnicalWorkPrice { get; set; }
public string RepairName { get; set; } = string.Empty;
public DateTime? RepairStartDate { get; set; } = DateTime.Now;
public double RepairPrice { get; set; }
}
}

View File

@ -0,0 +1,14 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ServiceStationContracts.ViewModels
{
public class ReportWorksViewModel
{
public string CarNumber { get; set; } = string.Empty;
public List<(string, double)> WorksInfo { get; set; } = new();
}
}

View File

@ -10,7 +10,7 @@ namespace ServiceStationDataModels.Models
{ {
string RepairName { get; } string RepairName { get; }
Enums.RepairStatus Status { get; } DateTime? RepairStartDate { get; }
double RepairPrice { get; } double RepairPrice { get; }

View File

@ -29,9 +29,23 @@ namespace ServiceStationDatabaseImplement.Implements
public List<RepairViewModel> GetFilteredList(RepairSearchModel model) public List<RepairViewModel> GetFilteredList(RepairSearchModel model)
{ {
if (string.IsNullOrEmpty(model.RepairName) && !model.GuarantorId.HasValue) return new(); if (string.IsNullOrEmpty(model.RepairName) && !model.GuarantorId.HasValue && !model.DateFrom.HasValue && !model.DateTo.HasValue) return new();
using var context = new ServiceStationDatabase(); using var context = new ServiceStationDatabase();
if(model.DateTo.HasValue && model.DateTo.HasValue && model.GuarantorId.HasValue)
{
return context.Repairs
.Include(x => x.SpareParts)
.ThenInclude(x => x.SparePart)
.ThenInclude(x => x.SparePartWorks)
.ThenInclude(x => x.Work)
.Include(x => x.Guarantor)
.Where(x => x.RepairStartDate >= model.DateFrom && x.RepairStartDate <= model.DateTo || x.GuarantorId == model.GuarantorId)
.ToList()
.Select(x => x.GetViewModel)
.ToList();
}
if (model.GuarantorId.HasValue) if (model.GuarantorId.HasValue)
{ {
return context.Repairs return context.Repairs

View File

@ -36,7 +36,7 @@ namespace ServiceStationDatabaseImplement.Implements
} }
using var context = new ServiceStationDatabase(); using var context = new ServiceStationDatabase();
if(model.DateTo.HasValue && model.DateTo.HasValue) if(model.DateTo.HasValue && model.DateTo.HasValue && model.ExecutorId.HasValue)
{ {
return context.TechnicalWorks return context.TechnicalWorks
.Include(x => x.Cars) .Include(x => x.Cars)
@ -44,7 +44,7 @@ namespace ServiceStationDatabaseImplement.Implements
.ThenInclude(x => x.CarDefects) .ThenInclude(x => x.CarDefects)
.ThenInclude(x => x.Defect) .ThenInclude(x => x.Defect)
.Include(x => x.Executor) .Include(x => x.Executor)
.Where(x => x.DateStartWork >= model.DateFrom && x.DateStartWork <= model.DateTo && x.ExecutorId == model.ExecutorId) .Where(x => x.DateStartWork >= model.DateFrom && x.DateStartWork <= model.DateTo || x.ExecutorId == model.ExecutorId)
.Select(x => x.GetViewModel) .Select(x => x.GetViewModel)
.ToList(); .ToList();
} }

View File

@ -0,0 +1,558 @@
// <auto-generated />
using System;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using ServiceStationDatabaseImplement;
#nullable disable
namespace ServiceStationDatabaseImplement.Migrations
{
[DbContext(typeof(ServiceStationDatabase))]
[Migration("20240430202710_CorrectionMigration")]
partial class CorrectionMigration
{
/// <inheritdoc />
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("ProductVersion", "7.0.18")
.HasAnnotation("Relational:MaxIdentifierLength", 128);
SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder);
modelBuilder.Entity("ServiceStationDatabaseImplement.Models.Car", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<string>("CarBrand")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("CarNumber")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<int>("ExecutorId")
.HasColumnType("int");
b.HasKey("Id");
b.HasIndex("ExecutorId");
b.ToTable("Cars");
});
modelBuilder.Entity("ServiceStationDatabaseImplement.Models.CarDefect", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<int>("CarId")
.HasColumnType("int");
b.Property<int>("DefectId")
.HasColumnType("int");
b.HasKey("Id");
b.HasIndex("CarId");
b.HasIndex("DefectId");
b.ToTable("CarDefects");
});
modelBuilder.Entity("ServiceStationDatabaseImplement.Models.CarTechnicalWork", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<int>("CarId")
.HasColumnType("int");
b.Property<int>("TechnicalWorkId")
.HasColumnType("int");
b.HasKey("Id");
b.HasIndex("CarId");
b.HasIndex("TechnicalWorkId");
b.ToTable("CarTechnicalWorks");
});
modelBuilder.Entity("ServiceStationDatabaseImplement.Models.Defect", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<double>("DefectPrice")
.HasColumnType("float");
b.Property<string>("DefectType")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<int>("ExecutorId")
.HasColumnType("int");
b.Property<int?>("RepairId")
.HasColumnType("int");
b.HasKey("Id");
b.HasIndex("ExecutorId");
b.HasIndex("RepairId");
b.ToTable("Defects");
});
modelBuilder.Entity("ServiceStationDatabaseImplement.Models.Executor", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<string>("ExecutorEmail")
.HasColumnType("nvarchar(max)");
b.Property<string>("ExecutorFIO")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("ExecutorNumber")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("ExecutorPassword")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.HasKey("Id");
b.ToTable("Executors");
});
modelBuilder.Entity("ServiceStationDatabaseImplement.Models.Guarantor", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<string>("GuarantorEmail")
.HasColumnType("nvarchar(max)");
b.Property<string>("GuarantorFIO")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("GuarantorNumber")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("GuarantorPassword")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.HasKey("Id");
b.ToTable("Guarantors");
});
modelBuilder.Entity("ServiceStationDatabaseImplement.Models.Repair", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<int>("GuarantorId")
.HasColumnType("int");
b.Property<string>("RepairName")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<double>("RepairPrice")
.HasColumnType("float");
b.Property<DateTime?>("RepairStartDate")
.HasColumnType("datetime2");
b.HasKey("Id");
b.HasIndex("GuarantorId");
b.ToTable("Repairs");
});
modelBuilder.Entity("ServiceStationDatabaseImplement.Models.SparePart", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<int>("GuarantorId")
.HasColumnType("int");
b.Property<string>("SparePartName")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<double>("SparePartPrice")
.HasColumnType("float");
b.HasKey("Id");
b.HasIndex("GuarantorId");
b.ToTable("SpareParts");
});
modelBuilder.Entity("ServiceStationDatabaseImplement.Models.SparePartRepair", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<int>("RepairId")
.HasColumnType("int");
b.Property<int>("SparePartId")
.HasColumnType("int");
b.HasKey("Id");
b.HasIndex("RepairId");
b.HasIndex("SparePartId");
b.ToTable("SparePartRepairs");
});
modelBuilder.Entity("ServiceStationDatabaseImplement.Models.SparePartWork", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<int>("SparePartId")
.HasColumnType("int");
b.Property<int>("WorkId")
.HasColumnType("int");
b.HasKey("Id");
b.HasIndex("SparePartId");
b.HasIndex("WorkId");
b.ToTable("SparePartWorks");
});
modelBuilder.Entity("ServiceStationDatabaseImplement.Models.TechnicalWork", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<DateTime?>("DateStartWork")
.HasColumnType("datetime2");
b.Property<int>("ExecutorId")
.HasColumnType("int");
b.Property<double>("WorkPrice")
.HasColumnType("float");
b.Property<string>("WorkType")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.HasKey("Id");
b.HasIndex("ExecutorId");
b.ToTable("TechnicalWorks");
});
modelBuilder.Entity("ServiceStationDatabaseImplement.Models.Work", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<int>("GuarantorId")
.HasColumnType("int");
b.Property<int>("Status")
.HasColumnType("int");
b.Property<int?>("TechnicalWorkId")
.HasColumnType("int");
b.Property<string>("WorkName")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<double>("WorkPrice")
.HasColumnType("float");
b.HasKey("Id");
b.HasIndex("GuarantorId");
b.HasIndex("TechnicalWorkId");
b.ToTable("Works");
});
modelBuilder.Entity("ServiceStationDatabaseImplement.Models.Car", b =>
{
b.HasOne("ServiceStationDatabaseImplement.Models.Executor", "Executor")
.WithMany("Cars")
.HasForeignKey("ExecutorId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Executor");
});
modelBuilder.Entity("ServiceStationDatabaseImplement.Models.CarDefect", b =>
{
b.HasOne("ServiceStationDatabaseImplement.Models.Car", "Car")
.WithMany("CarDefects")
.HasForeignKey("CarId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("ServiceStationDatabaseImplement.Models.Defect", "Defect")
.WithMany("Cars")
.HasForeignKey("DefectId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Car");
b.Navigation("Defect");
});
modelBuilder.Entity("ServiceStationDatabaseImplement.Models.CarTechnicalWork", b =>
{
b.HasOne("ServiceStationDatabaseImplement.Models.Car", "Car")
.WithMany("CarTechnicalWorks")
.HasForeignKey("CarId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("ServiceStationDatabaseImplement.Models.TechnicalWork", "TechnicalWork")
.WithMany("Cars")
.HasForeignKey("TechnicalWorkId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Car");
b.Navigation("TechnicalWork");
});
modelBuilder.Entity("ServiceStationDatabaseImplement.Models.Defect", b =>
{
b.HasOne("ServiceStationDatabaseImplement.Models.Executor", "Executor")
.WithMany("Defects")
.HasForeignKey("ExecutorId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("ServiceStationDatabaseImplement.Models.Repair", "Repair")
.WithMany("Defects")
.HasForeignKey("RepairId");
b.Navigation("Executor");
b.Navigation("Repair");
});
modelBuilder.Entity("ServiceStationDatabaseImplement.Models.Repair", b =>
{
b.HasOne("ServiceStationDatabaseImplement.Models.Guarantor", "Guarantor")
.WithMany("Repairs")
.HasForeignKey("GuarantorId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Guarantor");
});
modelBuilder.Entity("ServiceStationDatabaseImplement.Models.SparePart", b =>
{
b.HasOne("ServiceStationDatabaseImplement.Models.Guarantor", "Guarantor")
.WithMany("SpareParts")
.HasForeignKey("GuarantorId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Guarantor");
});
modelBuilder.Entity("ServiceStationDatabaseImplement.Models.SparePartRepair", b =>
{
b.HasOne("ServiceStationDatabaseImplement.Models.Repair", "Repair")
.WithMany("SpareParts")
.HasForeignKey("RepairId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("ServiceStationDatabaseImplement.Models.SparePart", "SparePart")
.WithMany("SparePartRepairs")
.HasForeignKey("SparePartId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Repair");
b.Navigation("SparePart");
});
modelBuilder.Entity("ServiceStationDatabaseImplement.Models.SparePartWork", b =>
{
b.HasOne("ServiceStationDatabaseImplement.Models.SparePart", "SparePart")
.WithMany("SparePartWorks")
.HasForeignKey("SparePartId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("ServiceStationDatabaseImplement.Models.Work", "Work")
.WithMany("SpareParts")
.HasForeignKey("WorkId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("SparePart");
b.Navigation("Work");
});
modelBuilder.Entity("ServiceStationDatabaseImplement.Models.TechnicalWork", b =>
{
b.HasOne("ServiceStationDatabaseImplement.Models.Executor", "Executor")
.WithMany("TechnicalWorks")
.HasForeignKey("ExecutorId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Executor");
});
modelBuilder.Entity("ServiceStationDatabaseImplement.Models.Work", b =>
{
b.HasOne("ServiceStationDatabaseImplement.Models.Guarantor", "Guarantor")
.WithMany("Works")
.HasForeignKey("GuarantorId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("ServiceStationDatabaseImplement.Models.TechnicalWork", "TechnicalWork")
.WithMany("Works")
.HasForeignKey("TechnicalWorkId");
b.Navigation("Guarantor");
b.Navigation("TechnicalWork");
});
modelBuilder.Entity("ServiceStationDatabaseImplement.Models.Car", b =>
{
b.Navigation("CarDefects");
b.Navigation("CarTechnicalWorks");
});
modelBuilder.Entity("ServiceStationDatabaseImplement.Models.Defect", b =>
{
b.Navigation("Cars");
});
modelBuilder.Entity("ServiceStationDatabaseImplement.Models.Executor", b =>
{
b.Navigation("Cars");
b.Navigation("Defects");
b.Navigation("TechnicalWorks");
});
modelBuilder.Entity("ServiceStationDatabaseImplement.Models.Guarantor", b =>
{
b.Navigation("Repairs");
b.Navigation("SpareParts");
b.Navigation("Works");
});
modelBuilder.Entity("ServiceStationDatabaseImplement.Models.Repair", b =>
{
b.Navigation("Defects");
b.Navigation("SpareParts");
});
modelBuilder.Entity("ServiceStationDatabaseImplement.Models.SparePart", b =>
{
b.Navigation("SparePartRepairs");
b.Navigation("SparePartWorks");
});
modelBuilder.Entity("ServiceStationDatabaseImplement.Models.TechnicalWork", b =>
{
b.Navigation("Cars");
b.Navigation("Works");
});
modelBuilder.Entity("ServiceStationDatabaseImplement.Models.Work", b =>
{
b.Navigation("SpareParts");
});
#pragma warning restore 612, 618
}
}
}

View File

@ -0,0 +1,40 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace ServiceStationDatabaseImplement.Migrations
{
/// <inheritdoc />
public partial class CorrectionMigration : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropColumn(
name: "Status",
table: "Repairs");
migrationBuilder.AddColumn<DateTime>(
name: "RepairStartDate",
table: "Repairs",
type: "datetime2",
nullable: true);
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropColumn(
name: "RepairStartDate",
table: "Repairs");
migrationBuilder.AddColumn<int>(
name: "Status",
table: "Repairs",
type: "int",
nullable: false,
defaultValue: 0);
}
}
}

View File

@ -198,8 +198,8 @@ namespace ServiceStationDatabaseImplement.Migrations
b.Property<double>("RepairPrice") b.Property<double>("RepairPrice")
.HasColumnType("float"); .HasColumnType("float");
b.Property<int>("Status") b.Property<DateTime?>("RepairStartDate")
.HasColumnType("int"); .HasColumnType("datetime2");
b.HasKey("Id"); b.HasKey("Id");

View File

@ -19,8 +19,7 @@ namespace ServiceStationDatabaseImplement.Models
[Required] [Required]
public string RepairName { get; set; } = string.Empty; public string RepairName { get; set; } = string.Empty;
[Required] public DateTime? RepairStartDate { get; set; } = DateTime.Now;
public RepairStatus Status { get; set; }
[Required] [Required]
public double RepairPrice { get; set; } public double RepairPrice { get; set; }
@ -58,7 +57,7 @@ namespace ServiceStationDatabaseImplement.Models
{ {
Id = model.Id, Id = model.Id,
RepairName = model.RepairName, RepairName = model.RepairName,
Status = model.Status, RepairStartDate = model.RepairStartDate,
RepairPrice = model.RepairPrice, RepairPrice = model.RepairPrice,
GuarantorId = model.GuarantorId, GuarantorId = model.GuarantorId,
SpareParts = model.RepairSpareParts.Select(x => new SparePartRepair SpareParts = model.RepairSpareParts.Select(x => new SparePartRepair
@ -72,7 +71,7 @@ namespace ServiceStationDatabaseImplement.Models
{ {
if (model == null) return; if (model == null) return;
RepairName = model.RepairName; RepairName = model.RepairName;
Status = model.Status; RepairStartDate = model.RepairStartDate;
RepairPrice = model.RepairPrice; RepairPrice = model.RepairPrice;
} }
@ -80,7 +79,7 @@ namespace ServiceStationDatabaseImplement.Models
{ {
Id = Id, Id = Id,
RepairName = RepairName, RepairName = RepairName,
Status = Status, RepairStartDate = RepairStartDate,
RepairPrice = RepairPrice, RepairPrice = RepairPrice,
GuarantorId = GuarantorId, GuarantorId = GuarantorId,
RepairSpareParts = RepairSpareParts RepairSpareParts = RepairSpareParts