Реализация_слоя_бизнес_логики_исполнитель #7
@ -1,7 +1,17 @@
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using ServiceStationContracts.BusinessLogicsContracts;
|
||||
using ServiceStationContracts.StoragesContracts;
|
||||
using ServiceStationDatabaseImplement.Implements;
|
||||
using NLog.Extensions.Logging;
|
||||
|
||||
|
||||
namespace ServiceStation
|
||||
{
|
||||
internal static class Program
|
||||
{
|
||||
private static ServiceProvider? _serviceProvider;
|
||||
public static ServiceProvider? ServiceProvider => _serviceProvider;
|
||||
/// <summary>
|
||||
/// The main entry point for the application.
|
||||
/// </summary>
|
||||
@ -11,7 +21,23 @@ namespace ServiceStation
|
||||
// To customize application configuration such as set high DPI settings or default font,
|
||||
// see https://aka.ms/applicationconfiguration.
|
||||
ApplicationConfiguration.Initialize();
|
||||
var services = new ServiceCollection();
|
||||
ConfigureServices(services);
|
||||
_serviceProvider = services.BuildServiceProvider();
|
||||
Application.Run(new Form1());
|
||||
}
|
||||
private static void ConfigureServices(ServiceCollection services)
|
||||
{
|
||||
services.AddLogging(option =>
|
||||
{
|
||||
option.SetMinimumLevel(LogLevel.Information);
|
||||
option.AddNLog("nlog.config");
|
||||
});
|
||||
services.AddTransient<IExecutorStorage, ExecutorStorage>();
|
||||
services.AddTransient<IGuarantorStorage, GuarantorStorage>();
|
||||
//services.AddTransient<IExecutorLogic, ExecutorL>();
|
||||
//services.AddTransient<IGuarantorLogic, GuarantorLogic>();
|
||||
|
||||
}
|
||||
}
|
||||
}
|
@ -8,4 +8,20 @@
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="7.0.18">
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
</PackageReference>
|
||||
<PackageReference Include="NLog" Version="5.3.1" />
|
||||
<PackageReference Include="NLog.Extensions.Logging" Version="5.3.9" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\ServiceStationBusinessLogic\ServiceStationBusinessLogic.csproj" />
|
||||
<ProjectReference Include="..\ServiceStationContracts\ServiceStationContracts.csproj" />
|
||||
<ProjectReference Include="..\ServiceStationDatabaseImplement\ServiceStationDatabaseImplement.csproj" />
|
||||
<ProjectReference Include="..\ServiceStationDataModels\ServiceStationDataModels.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
@ -0,0 +1,113 @@
|
||||
|
||||
using Microsoft.Extensions.Logging;
|
||||
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 CarLogic : ICarLogic
|
||||
{
|
||||
private readonly ILogger _logger;
|
||||
private readonly ICarStorage _carStorage;
|
||||
|
||||
public CarLogic(ILogger logger, ICarStorage carStorage)
|
||||
{
|
||||
_logger = logger;
|
||||
_carStorage = carStorage;
|
||||
}
|
||||
|
||||
public List<CarViewModel>? ReadList(CarSearchModel? model)
|
||||
{
|
||||
_logger.LogInformation("ReadList. Car:{CarNumber}. Id:{Id}", model?.CarNumber, model?.Id);
|
||||
var list = model == null ? _carStorage.GetFullList() : _carStorage.GetFilteredList(model);
|
||||
if(list == null)
|
||||
{
|
||||
_logger.LogWarning("ReadList return null list");
|
||||
return null;
|
||||
}
|
||||
_logger.LogInformation("ReadList. Count:{Count}", list.Count);
|
||||
return list;
|
||||
}
|
||||
public CarViewModel? ReadElement(CarSearchModel? model)
|
||||
{
|
||||
if(model == null) throw new ArgumentNullException(nameof(model));
|
||||
_logger.LogInformation("ReadElement. CarNumber:{CarNumber}. Id:{Id}", model?.CarNumber, model?.Id);
|
||||
var element = _carStorage.GetElement(model);
|
||||
if(element == null)
|
||||
{
|
||||
_logger.LogWarning("ReadElement element is not found");
|
||||
return null;
|
||||
}
|
||||
_logger.LogInformation("ReadElement fing. Id:{Id}", element.Id);
|
||||
return element;
|
||||
}
|
||||
|
||||
public bool Create(CarBindingModel model)
|
||||
{
|
||||
CheckModel(model);
|
||||
if(_carStorage.Insert(model) == null)
|
||||
{
|
||||
_logger.LogWarning("Insert operation failed");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
public bool Update(CarBindingModel model)
|
||||
{
|
||||
CheckModel(model);
|
||||
if(_carStorage.Update(model) == null)
|
||||
{
|
||||
_logger.LogWarning("Update operation failed");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
public bool Delete(CarBindingModel model)
|
||||
{
|
||||
CheckModel(model, false);
|
||||
if(_carStorage.Delete(model) == null)
|
||||
{
|
||||
_logger.LogWarning("Delete operation failed");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private void CheckModel(CarBindingModel model, bool withParams = true)
|
||||
{
|
||||
if(model == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(model));
|
||||
}
|
||||
if (!withParams)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (string.IsNullOrEmpty(model.CarBrand))
|
||||
{
|
||||
throw new ArgumentNullException("Нет названия бренда машины", nameof(model.CarBrand));
|
||||
}
|
||||
if (string.IsNullOrEmpty(model.CarNumber))
|
||||
{
|
||||
throw new ArgumentNullException("Нет номера машины", nameof(model.CarNumber));
|
||||
}
|
||||
_logger.LogInformation("Car. CarBrand:{CarBrand}. CarNumber:{CarNumber}. Id:{Id}", model.CarBrand, model.CarNumber, model.Id);
|
||||
var element = _carStorage.GetElement(new CarSearchModel
|
||||
{
|
||||
CarNumber = model.CarNumber
|
||||
});
|
||||
if(element != null && element.Id != model.Id)
|
||||
{
|
||||
throw new InvalidOperationException("Машина с таким номером уже есть");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,115 @@
|
||||
using Microsoft.Extensions.Logging;
|
||||
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 DefectLogic : IDefectLogic
|
||||
{
|
||||
private readonly ILogger _logger;
|
||||
private readonly IDefectStorage _defectStorage;
|
||||
|
||||
public DefectLogic(ILogger logger, IDefectStorage defectStorage)
|
||||
{
|
||||
_logger = logger;
|
||||
_defectStorage = defectStorage;
|
||||
}
|
||||
|
||||
public List<DefectViewModel>? ReadList(DefectSearchModel? model)
|
||||
{
|
||||
_logger.LogInformation("ReadList. DefectType:{DefectType}. Id:{Id}", model?.DefectType, model?.Id);
|
||||
var list = model == null ? _defectStorage.GetFullList() : _defectStorage.GetFilteredList(model);
|
||||
if (list == null)
|
||||
{
|
||||
_logger.LogWarning("ReadList return null list");
|
||||
return null;
|
||||
}
|
||||
_logger.LogInformation("ReadList. Count:{Count}", list.Count);
|
||||
return list;
|
||||
}
|
||||
public DefectViewModel? ReadElement(DefectSearchModel? model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(model));
|
||||
}
|
||||
_logger.LogInformation("ReadElement. DefectType:{DefectType}. Id:{Id}", model.DefectType, model?.Id);
|
||||
var element = _defectStorage.GetElement(model);
|
||||
if (element == null)
|
||||
{
|
||||
_logger.LogWarning("ReadElement element is not found");
|
||||
return null;
|
||||
}
|
||||
_logger.LogInformation("ReadElement find. Id:{Id}", element.Id);
|
||||
return element;
|
||||
}
|
||||
|
||||
public bool Create(DefectBindingModel model)
|
||||
{
|
||||
CheckModel(model);
|
||||
if (_defectStorage.Insert(model) == null)
|
||||
{
|
||||
_logger.LogWarning("Insert operation failed");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
public bool Update(DefectBindingModel model)
|
||||
{
|
||||
CheckModel(model);
|
||||
if (_defectStorage.Update(model) == null)
|
||||
{
|
||||
_logger.LogWarning("Update operation failed");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
public bool Delete(DefectBindingModel model)
|
||||
{
|
||||
CheckModel(model, false);
|
||||
if (_defectStorage.Delete(model) == null)
|
||||
{
|
||||
_logger.LogWarning("Delete operation failed");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private void CheckModel(DefectBindingModel model, bool withParams = true)
|
||||
{
|
||||
if(model == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(model));
|
||||
}
|
||||
if (!withParams)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (string.IsNullOrEmpty(model.DefectType))
|
||||
{
|
||||
throw new ArgumentNullException("Нет названия неисправности", nameof(model.DefectType));
|
||||
}
|
||||
if(model.DefectPrice <= 0)
|
||||
{
|
||||
throw new ArgumentNullException("Цена дефекта должна быть больше нуля", nameof(model.DefectPrice));
|
||||
}
|
||||
_logger.LogInformation("Defect. DefectType:{DefectType}. DefectPrice:{DefectPrice}. Id:{Id}", model.DefectType, model.DefectPrice, model.Id);
|
||||
var element = _defectStorage.GetElement(new DefectSearchModel
|
||||
{
|
||||
DefectType = model.DefectType
|
||||
});
|
||||
if(element != null && element.Id != model.Id)
|
||||
{
|
||||
throw new InvalidOperationException("Такая неисправность уже есть");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,121 @@
|
||||
using Microsoft.Extensions.Logging;
|
||||
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 ExecutorLogic : IExecutorLogic
|
||||
{
|
||||
private readonly ILogger _logger;
|
||||
private readonly IExecutorStorage _executorStorage;
|
||||
|
||||
public ExecutorLogic(ILogger logger, IExecutorStorage executorStorage)
|
||||
{
|
||||
_logger = logger;
|
||||
_executorStorage = executorStorage;
|
||||
}
|
||||
|
||||
public List<ExecutorViewModel>? ReadList(ExecutorSearchModel? model)
|
||||
{
|
||||
_logger.LogInformation("ReadList. ExecutorFIO:{ExecutorFIO}. Id:{Id}", model?.ExecutorFIO, model?.Id);
|
||||
var list = model == null ? _executorStorage.GetFullList() : _executorStorage.GetFilteredList(model);
|
||||
if (list == null)
|
||||
{
|
||||
_logger.LogWarning("ReadList return null list");
|
||||
return null;
|
||||
}
|
||||
_logger.LogInformation("ReadList. Count:{Count}", list.Count);
|
||||
return list;
|
||||
|
||||
}
|
||||
public ExecutorViewModel? ReadElement(ExecutorSearchModel? model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(model));
|
||||
}
|
||||
_logger.LogInformation("ReadElement. ExecutorFIO:{ExecutorFIO}. Id:{Id}", model.ExecutorFIO, model?.Id);
|
||||
var element = _executorStorage.GetElement(model);
|
||||
if (element == null)
|
||||
{
|
||||
_logger.LogWarning("ReadElement element is not found");
|
||||
return null;
|
||||
}
|
||||
_logger.LogInformation("ReadElement find. Id:{Id}", element.Id);
|
||||
return element;
|
||||
}
|
||||
|
||||
public bool Create(ExecutorBindingModel model)
|
||||
{
|
||||
CheckModel(model);
|
||||
if (_executorStorage.Insert(model) == null)
|
||||
{
|
||||
_logger.LogWarning("Insert operation failed");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
public bool Update(ExecutorBindingModel model)
|
||||
{
|
||||
CheckModel(model);
|
||||
if (_executorStorage.Update(model) == null)
|
||||
{
|
||||
_logger.LogWarning("Update operation failed");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
|
||||
}
|
||||
public bool Delete(ExecutorBindingModel model)
|
||||
{
|
||||
CheckModel(model, false);
|
||||
if (_executorStorage.Delete(model) == null)
|
||||
{
|
||||
_logger.LogWarning("Delete operation failed");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private void CheckModel(ExecutorBindingModel model, bool withParams = true)
|
||||
{
|
||||
if(model == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(model));
|
||||
}
|
||||
if(!withParams)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (string.IsNullOrEmpty(model.ExecutorFIO))
|
||||
{
|
||||
throw new ArgumentNullException("Нет ФИО исполнителя", nameof(model.ExecutorFIO));
|
||||
}
|
||||
if (string.IsNullOrEmpty(model.ExecutorPassword))
|
||||
{
|
||||
throw new ArgumentNullException("Нет пароля исполнителя", nameof(model.ExecutorPassword));
|
||||
}
|
||||
if (string.IsNullOrEmpty(model.ExecutorNumber))
|
||||
{
|
||||
throw new ArgumentNullException("Нет номера исполнителя", nameof(model.ExecutorNumber));
|
||||
}
|
||||
_logger.LogInformation("Executor. ExecutorFIO:{ExecutorFIO}. ExecutorPassword:{ExecutorPassword}. ExecutorNumber:{ExecutorNumber}", model.ExecutorFIO, model.ExecutorPassword, model.ExecutorNumber);
|
||||
var element = _executorStorage.GetElement(new ExecutorSearchModel
|
||||
{
|
||||
ExecutorNumber = model.ExecutorNumber
|
||||
});
|
||||
if(element != null && element.Id != model.Id)
|
||||
{
|
||||
throw new InvalidOperationException("Исполнитель с таким номером уже есть");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,115 @@
|
||||
using Microsoft.Extensions.Logging;
|
||||
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 TechnicalWorkLogic : ITechnicalWorkLogic
|
||||
{
|
||||
private ILogger _logger;
|
||||
private ITechnicalWorkStorage _technicalWorkStorage;
|
||||
|
||||
public TechnicalWorkLogic(ILogger logger, ITechnicalWorkStorage technicalWorkStorage)
|
||||
{
|
||||
_logger = logger;
|
||||
_technicalWorkStorage = technicalWorkStorage;
|
||||
}
|
||||
|
||||
public List<TechnicalWorkViewModel>? ReadList(TechnicalWorkSearchModel? model)
|
||||
{
|
||||
_logger.LogInformation("ReadList. WorkType:{WorkType}. Id:{Id}", model?.WorkType, model?.Id);
|
||||
var list = model == null ? _technicalWorkStorage.GetFullList() : _technicalWorkStorage.GetFilteredList(model);
|
||||
if (list == null)
|
||||
{
|
||||
_logger.LogWarning("ReadList return null list");
|
||||
return null;
|
||||
}
|
||||
_logger.LogInformation("ReadList. Count:{Count}", list.Count);
|
||||
return list;
|
||||
}
|
||||
public TechnicalWorkViewModel? ReadElement(TechnicalWorkSearchModel? model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(model));
|
||||
}
|
||||
_logger.LogInformation("ReadElement. WorkType:{WorkType}. Id:{Id}", model.WorkType, model?.Id);
|
||||
var element = _technicalWorkStorage.GetElement(model);
|
||||
if (element == null)
|
||||
{
|
||||
_logger.LogWarning("ReadElement element is not found");
|
||||
return null;
|
||||
}
|
||||
_logger.LogInformation("ReadElement find. Id:{Id}", element.Id);
|
||||
return element;
|
||||
}
|
||||
|
||||
public bool Create(TechnicalWorkBindingModel model)
|
||||
{
|
||||
CheckModel(model);
|
||||
if (_technicalWorkStorage.Insert(model) == null)
|
||||
{
|
||||
_logger.LogWarning("Insert operation failed");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
public bool Update(TechnicalWorkBindingModel model)
|
||||
{
|
||||
CheckModel(model);
|
||||
if (_technicalWorkStorage.Update(model) == null)
|
||||
{
|
||||
_logger.LogWarning("Update operation failed");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
public bool Delete(TechnicalWorkBindingModel model)
|
||||
{
|
||||
CheckModel(model, false);
|
||||
if (_technicalWorkStorage.Delete(model) == null)
|
||||
{
|
||||
_logger.LogWarning("Delete operation failed");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private void CheckModel(TechnicalWorkBindingModel model, bool withParams = true)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(model));
|
||||
}
|
||||
if (!withParams)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (string.IsNullOrEmpty(model.WorkType))
|
||||
{
|
||||
throw new ArgumentNullException("Нет названия ТО", nameof(model.WorkType));
|
||||
}
|
||||
if(model.WorkPrice <= 0)
|
||||
{
|
||||
throw new ArgumentNullException("Цена ТО должна быть больше 0", nameof(model.WorkPrice));
|
||||
}
|
||||
_logger.LogInformation("TechnicalWork. WorkType:{WorkType}. WorkPrice:{WorkPrice}. Id:{Id}", model.WorkType, model.WorkType, model.Id);
|
||||
var element = _technicalWorkStorage.GetElement(new TechnicalWorkSearchModel
|
||||
{
|
||||
WorkType = model.WorkType
|
||||
});
|
||||
if (element != null && element.Id != model.Id)
|
||||
{
|
||||
throw new InvalidOperationException("ТО с таким названием уже есть");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -10,6 +10,7 @@ namespace ServiceStationContracts.SearchModels
|
||||
{
|
||||
public int? Id { get; set; }
|
||||
public string? ExecutorFIO { get; set; }
|
||||
public string? ExecutorNumber { get; set; }
|
||||
public string? ExecutorEmail { get; set; }
|
||||
}
|
||||
}
|
||||
|
@ -23,7 +23,7 @@ namespace ServiceStationDatabaseImplement.Implements
|
||||
.ThenInclude(x => x.Car)
|
||||
.ThenInclude(x => x.CarTechnicalWorks)
|
||||
.ThenInclude(x => x.TechnicalWork)
|
||||
//.Include(x => x.Сущность Сани)
|
||||
.Include(x => x.Repairs)
|
||||
.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.Сущность Сани)
|
||||
.Include(x => x.Repairs)
|
||||
.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.Сущность Сани)
|
||||
.Include(x => x.Repairs)
|
||||
.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.Сущность Сани)
|
||||
.Include(x => x.Repairs)
|
||||
.Include(x => x.Executor)
|
||||
.FirstOrDefault(x => (!string.IsNullOrEmpty(model.DefectType) && x.DefectType == model.DefectType) || (model.Id.HasValue && x.Id == model.Id))?
|
||||
.GetViewModel;
|
||||
|
@ -22,7 +22,7 @@ namespace ServiceStationDatabaseImplement.Implements
|
||||
.ThenInclude(x => x.SparePart)
|
||||
.ThenInclude(x => x.SparePartWorks)
|
||||
.ThenInclude(x => x.Work)
|
||||
.Include(x => x.Defect)
|
||||
//.Include(x => x.Defect)
|
||||
.Include(x => x.Guarantor)
|
||||
.Select(x => x.GetViewModel)
|
||||
.ToList();
|
||||
@ -40,7 +40,7 @@ namespace ServiceStationDatabaseImplement.Implements
|
||||
.ThenInclude(x => x.SparePart)
|
||||
.ThenInclude(x => x.SparePartWorks)
|
||||
.ThenInclude(x => x.Work)
|
||||
.Include(x => x.Defect)
|
||||
//.Include(x => x.Defect)
|
||||
.Include(x => x.Guarantor)
|
||||
.Where(x => x.GuarantorId == model.GuarantorId)
|
||||
.ToList()
|
||||
@ -52,7 +52,7 @@ namespace ServiceStationDatabaseImplement.Implements
|
||||
.ThenInclude(x => x.SparePart)
|
||||
.ThenInclude(x => x.SparePartWorks)
|
||||
.ThenInclude(x => x.Work)
|
||||
.Include(x => x.Defect)
|
||||
//.Include(x => x.Defect)
|
||||
.Include(x => x.Guarantor)
|
||||
.Where(x => x.RepairName == model.RepairName)
|
||||
.ToList()
|
||||
@ -71,7 +71,7 @@ namespace ServiceStationDatabaseImplement.Implements
|
||||
.ThenInclude(x => x.SparePart)
|
||||
.ThenInclude(x => x.SparePartWorks)
|
||||
.ThenInclude(x => x.Work)
|
||||
.Include(x => x.Defect)
|
||||
//.Include(x => x.Defect)
|
||||
.Include(x => x.Guarantor)
|
||||
.FirstOrDefault(x => (!string.IsNullOrEmpty(model.RepairName) && x.RepairName == model.RepairName) || (model.Id.HasValue && x.Id == model.Id))?
|
||||
.GetViewModel;
|
||||
|
@ -23,7 +23,7 @@ namespace ServiceStationDatabaseImplement.Implements
|
||||
.ThenInclude(x => x.Car)
|
||||
.ThenInclude(x => x.CarDefects)
|
||||
.ThenInclude(x => x.Defect)
|
||||
//.Include(x => x.Сущность Сани)
|
||||
.Include(x => x.Work)
|
||||
.Include(x => x.Executor)
|
||||
.ToList()
|
||||
.Select(x => x.GetViewModel)
|
||||
@ -45,7 +45,7 @@ namespace ServiceStationDatabaseImplement.Implements
|
||||
.ThenInclude(x => x.Car)
|
||||
.ThenInclude(x => x.CarDefects)
|
||||
.ThenInclude(x => x.Defect)
|
||||
//.Include(x => x.Сущность Сани)
|
||||
.Include(x => x.Work)
|
||||
.Include(x => x.Executor)
|
||||
.Where(x => x.DateStartWork >= model.DateFrom && x.DateStartWork <= model.DateTo && x.ExecutorId == model.ExecutorId)
|
||||
.Select(x => x.GetViewModel)
|
||||
@ -58,7 +58,7 @@ namespace ServiceStationDatabaseImplement.Implements
|
||||
.ThenInclude(x => x.Car)
|
||||
.ThenInclude(x => x.CarDefects)
|
||||
.ThenInclude(x => x.Defect)
|
||||
//.Include(x => x.Сущность Сани)
|
||||
.Include(x => x.Work)
|
||||
.Include(x => x.Executor)
|
||||
.Where(x => x.ExecutorId == model.ExecutorId)
|
||||
.ToList()
|
||||
@ -70,7 +70,7 @@ namespace ServiceStationDatabaseImplement.Implements
|
||||
.ThenInclude(x => x.Car)
|
||||
.ThenInclude(x => x.CarDefects)
|
||||
.ThenInclude(x => x.Defect)
|
||||
//.Include(x => x.Сущность Сани)
|
||||
.Include(x => x.Work)
|
||||
.Include(x => x.Executor)
|
||||
.Where(x => x.WorkType.Contains(model.WorkType))
|
||||
.ToList()
|
||||
@ -88,7 +88,7 @@ namespace ServiceStationDatabaseImplement.Implements
|
||||
.ThenInclude(x => x.Car)
|
||||
.ThenInclude(x => x.CarDefects)
|
||||
.ThenInclude(x => x.Defect)
|
||||
//.Include(x => x.Сущность Сани)
|
||||
.Include(x => x.Work)
|
||||
.Include(x => x.Executor)
|
||||
.FirstOrDefault(x => (!string.IsNullOrEmpty(model.WorkType) && x.WorkType == model.WorkType) || (model.Id.HasValue && x.Id == model.Id))?
|
||||
.GetViewModel;
|
||||
|
@ -22,7 +22,7 @@ namespace ServiceStationDatabaseImplement.Implements
|
||||
.ThenInclude(x => x.SparePart)
|
||||
.ThenInclude(x => x.SparePartRepairs)
|
||||
.ThenInclude(x => x.Repair)
|
||||
.Include(x => x.TechnicalWork)
|
||||
//.Include(x => x.TechnicalWork)
|
||||
.Include(x => x.Guarantor)
|
||||
.ToList()
|
||||
.Select(x => x.GetViewModel)
|
||||
@ -44,7 +44,7 @@ namespace ServiceStationDatabaseImplement.Implements
|
||||
.ThenInclude(x => x.SparePart)
|
||||
.ThenInclude(x => x.SparePartRepairs)
|
||||
.ThenInclude(x => x.Repair)
|
||||
.Include(x => x.TechnicalWork)
|
||||
//.Include(x => x.TechnicalWork)
|
||||
.Include(x => x.Guarantor)
|
||||
.Where(x => x.GuarantorId == model.GuarantorId)
|
||||
.Select(x => x.GetViewModel)
|
||||
@ -57,7 +57,7 @@ namespace ServiceStationDatabaseImplement.Implements
|
||||
.ThenInclude(x => x.SparePart)
|
||||
.ThenInclude(x => x.SparePartRepairs)
|
||||
.ThenInclude(x => x.Repair)
|
||||
.Include(x => x.TechnicalWork)
|
||||
//.Include(x => x.TechnicalWork)
|
||||
.Include(x => x.Guarantor)
|
||||
.Where(x => x.GuarantorId == model.GuarantorId)
|
||||
.ToList()
|
||||
@ -69,7 +69,7 @@ namespace ServiceStationDatabaseImplement.Implements
|
||||
.ThenInclude(x => x.SparePart)
|
||||
.ThenInclude(x => x.SparePartRepairs)
|
||||
.ThenInclude(x => x.Repair)
|
||||
.Include(x => x.TechnicalWork)
|
||||
//.Include(x => x.TechnicalWork)
|
||||
.Include(x => x.Guarantor)
|
||||
.Where(x => x.WorkName.Contains(model.WorkName))
|
||||
.ToList()
|
||||
@ -87,7 +87,7 @@ namespace ServiceStationDatabaseImplement.Implements
|
||||
.ThenInclude(x => x.SparePart)
|
||||
.ThenInclude(x => x.SparePartRepairs)
|
||||
.ThenInclude(x => x.Repair)
|
||||
.Include(x => x.TechnicalWork)
|
||||
//.Include(x => x.TechnicalWork)
|
||||
.Include(x => x.Guarantor)
|
||||
.FirstOrDefault(x => (!string.IsNullOrEmpty(model.WorkName) && x.WorkName == model.WorkName) || (model.Id.HasValue && x.Id == model.Id))?
|
||||
.GetViewModel;
|
||||
|
563
ServiceStation/ServiceStationDatabaseImplement/Migrations/20240427193650_InitMigration.Designer.cs
generated
Normal file
563
ServiceStation/ServiceStationDatabaseImplement/Migrations/20240427193650_InitMigration.Designer.cs
generated
Normal file
@ -0,0 +1,563 @@
|
||||
// <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("20240427193650_InitMigration")]
|
||||
partial class InitMigration
|
||||
{
|
||||
/// <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.HasKey("Id");
|
||||
|
||||
b.HasIndex("ExecutorId");
|
||||
|
||||
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>("DefectId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("GuarantorId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<string>("RepairName")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<double>("RepairPrice")
|
||||
.HasColumnType("float");
|
||||
|
||||
b.Property<int>("Status")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("DefectId");
|
||||
|
||||
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<int>("WorkId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<double>("WorkPrice")
|
||||
.HasColumnType("float");
|
||||
|
||||
b.Property<string>("WorkType")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("ExecutorId");
|
||||
|
||||
b.HasIndex("WorkId");
|
||||
|
||||
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.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.Navigation("Executor");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("ServiceStationDatabaseImplement.Models.Repair", b =>
|
||||
{
|
||||
b.HasOne("ServiceStationDatabaseImplement.Models.Defect", null)
|
||||
.WithMany("Repairs")
|
||||
.HasForeignKey("DefectId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
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.HasOne("ServiceStationDatabaseImplement.Models.Work", "Work")
|
||||
.WithMany("TechnicalWorks")
|
||||
.HasForeignKey("WorkId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Executor");
|
||||
|
||||
b.Navigation("Work");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("ServiceStationDatabaseImplement.Models.Work", b =>
|
||||
{
|
||||
b.HasOne("ServiceStationDatabaseImplement.Models.Guarantor", "Guarantor")
|
||||
.WithMany("Works")
|
||||
.HasForeignKey("GuarantorId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Guarantor");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("ServiceStationDatabaseImplement.Models.Car", b =>
|
||||
{
|
||||
b.Navigation("CarDefects");
|
||||
|
||||
b.Navigation("CarTechnicalWorks");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("ServiceStationDatabaseImplement.Models.Defect", b =>
|
||||
{
|
||||
b.Navigation("Cars");
|
||||
|
||||
b.Navigation("Repairs");
|
||||
});
|
||||
|
||||
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("SpareParts");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("ServiceStationDatabaseImplement.Models.SparePart", b =>
|
||||
{
|
||||
b.Navigation("SparePartRepairs");
|
||||
|
||||
b.Navigation("SparePartWorks");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("ServiceStationDatabaseImplement.Models.TechnicalWork", b =>
|
||||
{
|
||||
b.Navigation("Cars");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("ServiceStationDatabaseImplement.Models.Work", b =>
|
||||
{
|
||||
b.Navigation("SpareParts");
|
||||
|
||||
b.Navigation("TechnicalWorks");
|
||||
});
|
||||
#pragma warning restore 612, 618
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,415 @@
|
||||
using System;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace ServiceStationDatabaseImplement.Migrations
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public partial class InitMigration : Migration
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.CreateTable(
|
||||
name: "Executors",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(type: "int", nullable: false)
|
||||
.Annotation("SqlServer:Identity", "1, 1"),
|
||||
ExecutorFIO = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
||||
ExecutorEmail = table.Column<string>(type: "nvarchar(max)", nullable: true),
|
||||
ExecutorPassword = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
||||
ExecutorNumber = table.Column<string>(type: "nvarchar(max)", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_Executors", x => x.Id);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "Guarantors",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(type: "int", nullable: false)
|
||||
.Annotation("SqlServer:Identity", "1, 1"),
|
||||
GuarantorFIO = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
||||
GuarantorEmail = table.Column<string>(type: "nvarchar(max)", nullable: true),
|
||||
GuarantorPassword = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
||||
GuarantorNumber = table.Column<string>(type: "nvarchar(max)", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_Guarantors", x => x.Id);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "Cars",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(type: "int", nullable: false)
|
||||
.Annotation("SqlServer:Identity", "1, 1"),
|
||||
CarNumber = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
||||
CarBrand = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
||||
ExecutorId = table.Column<int>(type: "int", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_Cars", x => x.Id);
|
||||
table.ForeignKey(
|
||||
name: "FK_Cars_Executors_ExecutorId",
|
||||
column: x => x.ExecutorId,
|
||||
principalTable: "Executors",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "Defects",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(type: "int", nullable: false)
|
||||
.Annotation("SqlServer:Identity", "1, 1"),
|
||||
DefectType = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
||||
DefectPrice = table.Column<double>(type: "float", nullable: false),
|
||||
ExecutorId = table.Column<int>(type: "int", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_Defects", x => x.Id);
|
||||
table.ForeignKey(
|
||||
name: "FK_Defects_Executors_ExecutorId",
|
||||
column: x => x.ExecutorId,
|
||||
principalTable: "Executors",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "SpareParts",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(type: "int", nullable: false)
|
||||
.Annotation("SqlServer:Identity", "1, 1"),
|
||||
SparePartName = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
||||
SparePartPrice = table.Column<double>(type: "float", nullable: false),
|
||||
GuarantorId = table.Column<int>(type: "int", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_SpareParts", x => x.Id);
|
||||
table.ForeignKey(
|
||||
name: "FK_SpareParts_Guarantors_GuarantorId",
|
||||
column: x => x.GuarantorId,
|
||||
principalTable: "Guarantors",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "Works",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(type: "int", nullable: false)
|
||||
.Annotation("SqlServer:Identity", "1, 1"),
|
||||
WorkName = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
||||
Status = table.Column<int>(type: "int", nullable: false),
|
||||
WorkPrice = table.Column<double>(type: "float", nullable: false),
|
||||
GuarantorId = table.Column<int>(type: "int", nullable: false),
|
||||
TechnicalWorkId = table.Column<int>(type: "int", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_Works", x => x.Id);
|
||||
table.ForeignKey(
|
||||
name: "FK_Works_Guarantors_GuarantorId",
|
||||
column: x => x.GuarantorId,
|
||||
principalTable: "Guarantors",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "CarDefects",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(type: "int", nullable: false)
|
||||
.Annotation("SqlServer:Identity", "1, 1"),
|
||||
CarId = table.Column<int>(type: "int", nullable: false),
|
||||
DefectId = table.Column<int>(type: "int", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_CarDefects", x => x.Id);
|
||||
table.ForeignKey(
|
||||
name: "FK_CarDefects_Cars_CarId",
|
||||
column: x => x.CarId,
|
||||
principalTable: "Cars",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
table.ForeignKey(
|
||||
name: "FK_CarDefects_Defects_DefectId",
|
||||
column: x => x.DefectId,
|
||||
principalTable: "Defects",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Restrict);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "Repairs",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(type: "int", nullable: false)
|
||||
.Annotation("SqlServer:Identity", "1, 1"),
|
||||
RepairName = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
||||
Status = table.Column<int>(type: "int", nullable: false),
|
||||
RepairPrice = table.Column<double>(type: "float", nullable: false),
|
||||
GuarantorId = table.Column<int>(type: "int", nullable: false),
|
||||
DefectId = table.Column<int>(type: "int", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_Repairs", x => x.Id);
|
||||
table.ForeignKey(
|
||||
name: "FK_Repairs_Defects_DefectId",
|
||||
column: x => x.DefectId,
|
||||
principalTable: "Defects",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
table.ForeignKey(
|
||||
name: "FK_Repairs_Guarantors_GuarantorId",
|
||||
column: x => x.GuarantorId,
|
||||
principalTable: "Guarantors",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Restrict);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "SparePartWorks",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(type: "int", nullable: false)
|
||||
.Annotation("SqlServer:Identity", "1, 1"),
|
||||
SparePartId = table.Column<int>(type: "int", nullable: false),
|
||||
WorkId = table.Column<int>(type: "int", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_SparePartWorks", x => x.Id);
|
||||
table.ForeignKey(
|
||||
name: "FK_SparePartWorks_SpareParts_SparePartId",
|
||||
column: x => x.SparePartId,
|
||||
principalTable: "SpareParts",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
table.ForeignKey(
|
||||
name: "FK_SparePartWorks_Works_WorkId",
|
||||
column: x => x.WorkId,
|
||||
principalTable: "Works",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Restrict);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "TechnicalWorks",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(type: "int", nullable: false)
|
||||
.Annotation("SqlServer:Identity", "1, 1"),
|
||||
WorkType = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
||||
DateStartWork = table.Column<DateTime>(type: "datetime2", nullable: true),
|
||||
WorkPrice = table.Column<double>(type: "float", nullable: false),
|
||||
ExecutorId = table.Column<int>(type: "int", nullable: false),
|
||||
WorkId = table.Column<int>(type: "int", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_TechnicalWorks", x => x.Id);
|
||||
table.ForeignKey(
|
||||
name: "FK_TechnicalWorks_Executors_ExecutorId",
|
||||
column: x => x.ExecutorId,
|
||||
principalTable: "Executors",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
table.ForeignKey(
|
||||
name: "FK_TechnicalWorks_Works_WorkId",
|
||||
column: x => x.WorkId,
|
||||
principalTable: "Works",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Restrict);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "SparePartRepairs",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(type: "int", nullable: false)
|
||||
.Annotation("SqlServer:Identity", "1, 1"),
|
||||
SparePartId = table.Column<int>(type: "int", nullable: false),
|
||||
RepairId = table.Column<int>(type: "int", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_SparePartRepairs", x => x.Id);
|
||||
table.ForeignKey(
|
||||
name: "FK_SparePartRepairs_Repairs_RepairId",
|
||||
column: x => x.RepairId,
|
||||
principalTable: "Repairs",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
table.ForeignKey(
|
||||
name: "FK_SparePartRepairs_SpareParts_SparePartId",
|
||||
column: x => x.SparePartId,
|
||||
principalTable: "SpareParts",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Restrict);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "CarTechnicalWorks",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(type: "int", nullable: false)
|
||||
.Annotation("SqlServer:Identity", "1, 1"),
|
||||
CarId = table.Column<int>(type: "int", nullable: false),
|
||||
TechnicalWorkId = table.Column<int>(type: "int", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_CarTechnicalWorks", x => x.Id);
|
||||
table.ForeignKey(
|
||||
name: "FK_CarTechnicalWorks_Cars_CarId",
|
||||
column: x => x.CarId,
|
||||
principalTable: "Cars",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
table.ForeignKey(
|
||||
name: "FK_CarTechnicalWorks_TechnicalWorks_TechnicalWorkId",
|
||||
column: x => x.TechnicalWorkId,
|
||||
principalTable: "TechnicalWorks",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Restrict);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_CarDefects_CarId",
|
||||
table: "CarDefects",
|
||||
column: "CarId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_CarDefects_DefectId",
|
||||
table: "CarDefects",
|
||||
column: "DefectId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_Cars_ExecutorId",
|
||||
table: "Cars",
|
||||
column: "ExecutorId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_CarTechnicalWorks_CarId",
|
||||
table: "CarTechnicalWorks",
|
||||
column: "CarId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_CarTechnicalWorks_TechnicalWorkId",
|
||||
table: "CarTechnicalWorks",
|
||||
column: "TechnicalWorkId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_Defects_ExecutorId",
|
||||
table: "Defects",
|
||||
column: "ExecutorId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_Repairs_DefectId",
|
||||
table: "Repairs",
|
||||
column: "DefectId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_Repairs_GuarantorId",
|
||||
table: "Repairs",
|
||||
column: "GuarantorId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_SparePartRepairs_RepairId",
|
||||
table: "SparePartRepairs",
|
||||
column: "RepairId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_SparePartRepairs_SparePartId",
|
||||
table: "SparePartRepairs",
|
||||
column: "SparePartId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_SpareParts_GuarantorId",
|
||||
table: "SpareParts",
|
||||
column: "GuarantorId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_SparePartWorks_SparePartId",
|
||||
table: "SparePartWorks",
|
||||
column: "SparePartId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_SparePartWorks_WorkId",
|
||||
table: "SparePartWorks",
|
||||
column: "WorkId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_TechnicalWorks_ExecutorId",
|
||||
table: "TechnicalWorks",
|
||||
column: "ExecutorId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_TechnicalWorks_WorkId",
|
||||
table: "TechnicalWorks",
|
||||
column: "WorkId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_Works_GuarantorId",
|
||||
table: "Works",
|
||||
column: "GuarantorId");
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropTable(
|
||||
name: "CarDefects");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "CarTechnicalWorks");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "SparePartRepairs");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "SparePartWorks");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "Cars");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "TechnicalWorks");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "Repairs");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "SpareParts");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "Works");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "Defects");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "Guarantors");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "Executors");
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,560 @@
|
||||
// <auto-generated />
|
||||
using System;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||
using Microsoft.EntityFrameworkCore.Metadata;
|
||||
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||
using ServiceStationDatabaseImplement;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace ServiceStationDatabaseImplement.Migrations
|
||||
{
|
||||
[DbContext(typeof(ServiceStationDatabase))]
|
||||
partial class ServiceStationDatabaseModelSnapshot : ModelSnapshot
|
||||
{
|
||||
protected override void BuildModel(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.HasKey("Id");
|
||||
|
||||
b.HasIndex("ExecutorId");
|
||||
|
||||
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>("DefectId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("GuarantorId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<string>("RepairName")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<double>("RepairPrice")
|
||||
.HasColumnType("float");
|
||||
|
||||
b.Property<int>("Status")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("DefectId");
|
||||
|
||||
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<int>("WorkId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<double>("WorkPrice")
|
||||
.HasColumnType("float");
|
||||
|
||||
b.Property<string>("WorkType")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("ExecutorId");
|
||||
|
||||
b.HasIndex("WorkId");
|
||||
|
||||
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.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.Navigation("Executor");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("ServiceStationDatabaseImplement.Models.Repair", b =>
|
||||
{
|
||||
b.HasOne("ServiceStationDatabaseImplement.Models.Defect", null)
|
||||
.WithMany("Repairs")
|
||||
.HasForeignKey("DefectId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
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.HasOne("ServiceStationDatabaseImplement.Models.Work", "Work")
|
||||
.WithMany("TechnicalWorks")
|
||||
.HasForeignKey("WorkId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Executor");
|
||||
|
||||
b.Navigation("Work");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("ServiceStationDatabaseImplement.Models.Work", b =>
|
||||
{
|
||||
b.HasOne("ServiceStationDatabaseImplement.Models.Guarantor", "Guarantor")
|
||||
.WithMany("Works")
|
||||
.HasForeignKey("GuarantorId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Guarantor");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("ServiceStationDatabaseImplement.Models.Car", b =>
|
||||
{
|
||||
b.Navigation("CarDefects");
|
||||
|
||||
b.Navigation("CarTechnicalWorks");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("ServiceStationDatabaseImplement.Models.Defect", b =>
|
||||
{
|
||||
b.Navigation("Cars");
|
||||
|
||||
b.Navigation("Repairs");
|
||||
});
|
||||
|
||||
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("SpareParts");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("ServiceStationDatabaseImplement.Models.SparePart", b =>
|
||||
{
|
||||
b.Navigation("SparePartRepairs");
|
||||
|
||||
b.Navigation("SparePartWorks");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("ServiceStationDatabaseImplement.Models.TechnicalWork", b =>
|
||||
{
|
||||
b.Navigation("Cars");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("ServiceStationDatabaseImplement.Models.Work", b =>
|
||||
{
|
||||
b.Navigation("SpareParts");
|
||||
|
||||
b.Navigation("TechnicalWorks");
|
||||
});
|
||||
#pragma warning restore 612, 618
|
||||
}
|
||||
}
|
||||
}
|
@ -1,4 +1,5 @@
|
||||
using ServiceStationContracts.BindingModels;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
using ServiceStationContracts.BindingModels;
|
||||
using ServiceStationContracts.ViewModels;
|
||||
using ServiceStationDataModels.Models;
|
||||
using System;
|
||||
@ -26,6 +27,7 @@ namespace ServiceStationDatabaseImplement.Models
|
||||
|
||||
public virtual Executor Executor { get; set; }
|
||||
|
||||
|
||||
private Dictionary<int, ICarModel>? _defectCars = null;
|
||||
[NotMapped]
|
||||
public Dictionary<int, ICarModel> DefectCars
|
||||
@ -41,8 +43,8 @@ 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)
|
||||
{
|
||||
|
@ -33,7 +33,7 @@ namespace ServiceStationDatabaseImplement.Models
|
||||
|
||||
public virtual Guarantor Guarantor { get; set; }
|
||||
|
||||
public virtual Defect Defect { get; set; }
|
||||
//public virtual Defect Defect { get; set; }
|
||||
|
||||
private Dictionary<int, ISparePartModel>? _repairSpareParts = null;
|
||||
|
||||
@ -52,8 +52,8 @@ namespace ServiceStationDatabaseImplement.Models
|
||||
[ForeignKey("RepairId")]
|
||||
public virtual List<SparePartRepair> SpareParts { get; set; } = new();
|
||||
|
||||
[ForeignKey("RepairId")]
|
||||
public virtual List<Defect> Defects { get; set; } = new();
|
||||
//[ForeignKey("RepairId")]
|
||||
//public virtual List<Defect> Defects { get; set; } = new();
|
||||
|
||||
public static Repair? Create(ServiceStationDatabase context, RepairBindingModel model)
|
||||
{
|
||||
|
@ -26,6 +26,7 @@ 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
|
||||
@ -42,8 +43,6 @@ namespace ServiceStationDatabaseImplement.Models
|
||||
[ForeignKey("TechnicalWorkId")]
|
||||
public virtual List<CarTechnicalWork> Cars { get; set; } = new();
|
||||
|
||||
//внешний ключ у сущности Сани
|
||||
|
||||
public static TechnicalWork? Create(ServiceStationDatabase context, TechnicalWorkBindingModel model)
|
||||
{
|
||||
if (model == null) return null;
|
||||
|
@ -33,7 +33,7 @@ namespace ServiceStationDatabaseImplement.Models
|
||||
|
||||
public virtual Guarantor Guarantor { get; set; }
|
||||
|
||||
public virtual TechnicalWork TechnicalWork { get; set; }
|
||||
//public virtual TechnicalWork TechnicalWork { get; set; }
|
||||
|
||||
private Dictionary<int, ISparePartModel>? _workSpareParts = null;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user