исправила модели в бд
This commit is contained in:
parent
6559110c71
commit
4e7c734a22
@ -19,6 +19,8 @@ namespace CarCenterContracts.ViewModels
|
||||
public DateTime? InspectionDate { get; set; }
|
||||
public int AdministratorId { get; set; }
|
||||
public int? EmployeeId { get; set; }
|
||||
|
||||
public string EmployeeName { get; set; } = string.Empty;
|
||||
public Dictionary<int, ICarModel> InspectionCars { get; set; } = new();
|
||||
}
|
||||
}
|
||||
|
@ -9,7 +9,7 @@ namespace CarCenterDataBaseImplement
|
||||
{
|
||||
if (optionsBuilder.IsConfigured == false)
|
||||
{
|
||||
optionsBuilder.UseSqlServer(@"Data Source=localhost\SQLEXPRESS;Initial Catalog=CarCenterDataBaseFu;Integrated Security=True;MultipleActiveResultSets=True;;TrustServerCertificate=True");
|
||||
optionsBuilder.UseSqlServer(@"Data Source=localhost\SQLEXPRESS;Initial Catalog=CarCenterDataBase;Integrated Security=True;MultipleActiveResultSets=True;;TrustServerCertificate=True");
|
||||
}
|
||||
base.OnConfiguring(optionsBuilder);
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
@ -8,6 +8,12 @@
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="7.0.5" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="7.0.5" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="7.0.5">
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
</PackageReference>
|
||||
<PackageReference Include="PdfSharp.MigraDoc.Standard" Version="1.51.15" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
@ -81,9 +81,9 @@ namespace CarCenterDataBaseImplement.Models
|
||||
|
||||
public void UpdateCars(CarCenterDataBase context, EquipmentBindingModel model)
|
||||
{
|
||||
var equipmentCars = context.EquipmentCars.Where(rec => rec.RoomId == model.Id).ToList();
|
||||
var equipmentCars = context.EquipmentCars.Where(rec => rec.EquipmentId == model.Id).ToList();
|
||||
|
||||
if (equipmentCars != null && equipmentCars.Any())
|
||||
if (equipmentCars != null && equipmentCars.Count > 0)
|
||||
{
|
||||
context.EquipmentCars.RemoveRange(equipmentCars.Where(rec => !model.EquipmentCars.ContainsKey(rec.CarId)));
|
||||
context.SaveChanges();
|
||||
|
@ -40,7 +40,7 @@ namespace CarCenterDataBaseImplement.Models
|
||||
return _inspectionCars;
|
||||
}
|
||||
}
|
||||
public static InspectionCars Create(CarCenterDataBase context, InspectionBindingModel model)
|
||||
public static Inspection Create(CarCenterDataBase context, InspectionBindingModel model)
|
||||
{
|
||||
return new Inspection()
|
||||
{
|
||||
@ -70,14 +70,14 @@ namespace CarCenterDataBaseImplement.Models
|
||||
InspectionName = InspectionName,
|
||||
InspectionDate = InspectionDate,
|
||||
InspectionCars = InspectionCars,
|
||||
EmplFIO = Employee?.EmployeeFIO
|
||||
EmployeeName = Employee?.EmployeeFIO
|
||||
};
|
||||
|
||||
public void UpdateCars(CarCenterDataBase context, InspectionBindingModel model)
|
||||
{
|
||||
var inspectionCars = context.InspectionCars.Where(rec => rec.InspectionId == model.Id).ToList();
|
||||
|
||||
if (inspectionCars != null && inspectionCars.Any())
|
||||
if (inspectionCars != null && inspectionCars.Count > 0)
|
||||
{
|
||||
context.InspectionCars.RemoveRange(inspectionCars.Where(rec => !model.InspectionCars.ContainsKey(rec.CarId)));
|
||||
context.SaveChanges();
|
||||
|
Loading…
Reference in New Issue
Block a user