Compare commits
23 Commits
eb95536307
...
1d300e5010
Author | SHA1 | Date | |
---|---|---|---|
1d300e5010 | |||
60291edc77 | |||
5624a200d9 | |||
b31e48bfc5 | |||
|
8f6f381a25 | ||
|
62d4b6aebc | ||
|
e27d44d933 | ||
a61d49a15a | |||
|
93835aae7a | ||
923255d8ec | |||
8a4a34b232 | |||
fb65ccd9a2 | |||
|
245f5de6ca | ||
|
9b6262a5ad | ||
|
dd8f6dca9e | ||
|
3819f1ada5 | ||
|
0432e48870 | ||
|
2cb9fd4ac6 | ||
|
964618c53c | ||
55990af493 | |||
a6d0252745 | |||
|
51b9662d5b | ||
|
2ca5dfc3b6 |
@ -11,6 +11,8 @@ namespace CarCenterContracts.BindingModels
|
||||
public class CarBindingModel : ICarModel
|
||||
{
|
||||
public int Id { get; set; }
|
||||
public int StorekeeperId { get; set; }
|
||||
public int OrderId { get; set; }
|
||||
public CarBrand CarBrand { get; set; } = CarBrand.Неизвестно;
|
||||
public string Model { get; set; } = string.Empty;
|
||||
public CarClass CarClass { get; set; } = CarClass.Неизвестно;
|
||||
|
@ -11,6 +11,7 @@ namespace CarCenterContracts.BindingModels
|
||||
public class OrderBindingModel : IOrderModel
|
||||
{
|
||||
public int Id { get; set; }
|
||||
public int WorkerId { get; set; }
|
||||
public PaymentType PaymentType { get; set; } = PaymentType.Неизвестно;
|
||||
|
||||
public PaymentStatus PaymentStatus { get; set; } = PaymentStatus.Неизвестно;
|
||||
@ -21,6 +22,6 @@ namespace CarCenterContracts.BindingModels
|
||||
|
||||
public double Sum { get; set; }
|
||||
|
||||
|
||||
public Dictionary<int, IPresaleModel> OrderPresales { get; set; } = new();
|
||||
}
|
||||
}
|
||||
|
@ -18,6 +18,6 @@ namespace CarCenterContracts.BindingModels
|
||||
public DateTime DueTill { get; set; }
|
||||
|
||||
public double Price { get; set; }
|
||||
|
||||
public Dictionary<int, IBundlingModel> PresaleBundlings { get; set; } = new();
|
||||
}
|
||||
}
|
||||
|
@ -11,6 +11,7 @@ namespace CarCenterContracts.BindingModels
|
||||
public class RequestBindingModel : IRequestModel
|
||||
{
|
||||
public int Id { get; set; }
|
||||
public int PresaleId { get; set; }
|
||||
public string Description { get; set; } = string.Empty;
|
||||
public RequestTypes RequestType { get; set; } = RequestTypes.Неизвестно;
|
||||
|
||||
|
@ -12,6 +12,15 @@ namespace CarCenterContracts.ViewModels
|
||||
public class CarViewModel : ICarModel
|
||||
{
|
||||
public int Id { get; set; }
|
||||
public int? OrderId { get; set; }
|
||||
[DisplayName("ФИО покупателя")]
|
||||
public string BuyerFCS { get; set; }
|
||||
public int? FeatureId { get; set; }
|
||||
[DisplayName("Цена особенности")]
|
||||
public double FeaturePrice { get; set; }
|
||||
public int StorekeeperId { get; set; }
|
||||
[DisplayName("Имя работника")]
|
||||
public string StorekeeperName { get; set; } = string.Empty;
|
||||
[DisplayName("Марка")]
|
||||
public CarBrand CarBrand { get; set; }
|
||||
[DisplayName("Модель")]
|
||||
|
@ -12,6 +12,9 @@ namespace CarCenterContracts.ViewModels
|
||||
public class OrderViewModel : IOrderModel
|
||||
{
|
||||
public int Id { get; set; }
|
||||
public int WorkerId { get; set; }
|
||||
[DisplayName("Имя работника")]
|
||||
public string WorkerName { get; set; } = string.Empty;
|
||||
[DisplayName("Тип оплаты")]
|
||||
public PaymentType PaymentType { get; set; } = PaymentType.Неизвестно;
|
||||
[DisplayName("Статус оплаты")]
|
||||
@ -22,5 +25,6 @@ namespace CarCenterContracts.ViewModels
|
||||
public DateTime PaymentDate { get; set; }
|
||||
[DisplayName("Сумма")]
|
||||
public double Sum { get; set; }
|
||||
public Dictionary<int, IPresaleModel> OrderPresales { get; set; } = new();
|
||||
}
|
||||
}
|
||||
|
@ -20,5 +20,6 @@ namespace CarCenterContracts.ViewModels
|
||||
public DateTime DueTill { get; set; }
|
||||
[DisplayName("Цена")]
|
||||
public double Price { get; set; }
|
||||
public Dictionary<int, IBundlingModel> PresaleBundlings { get; set; } = new();
|
||||
}
|
||||
}
|
||||
|
@ -12,7 +12,10 @@ namespace CarCenterContracts.ViewModels
|
||||
public class RequestViewModel : IRequestModel
|
||||
{
|
||||
public int Id { get; set; }
|
||||
[DisplayName("Описание")]
|
||||
public int PresaleId { get; set; }
|
||||
[DisplayName("Описание работы")]
|
||||
public string PresaleDescription { get; set; } = string.Empty;
|
||||
[DisplayName("Описание пожелания")]
|
||||
public string Description { get; set; } = string.Empty;
|
||||
[DisplayName("Тип пожелания")]
|
||||
public RequestTypes RequestType { get; set; } = RequestTypes.Неизвестно;
|
||||
|
@ -6,4 +6,11 @@
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="6.0.29">
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
</PackageReference>
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
@ -19,5 +19,7 @@ namespace CarCenterDataModels.Models
|
||||
|
||||
double Sum { get; }
|
||||
|
||||
Dictionary<int, IPresaleModel> OrderPresales { get; }
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -17,5 +17,6 @@ namespace CarCenterDataModels.Models
|
||||
|
||||
double Price { get; }
|
||||
|
||||
Dictionary<int, IBundlingModel> PresaleBundlings { get; }
|
||||
}
|
||||
}
|
||||
|
@ -1,4 +1,5 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using CarCenterDatabaseImplement.Models;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
@ -19,6 +20,16 @@ namespace CarCenterDatabaseImplement
|
||||
AppContext.SetSwitch("Npgsql.EnableLegacyTimestampBehavior", true);
|
||||
AppContext.SetSwitch("Npgsql.DisableDateTimeInfinityConversions", true);
|
||||
}
|
||||
|
||||
public virtual DbSet<Order> Orders { set; get; }
|
||||
public virtual DbSet<Presale> Presales { set; get; }
|
||||
public virtual DbSet<OrderPresale> OrderPresales { set; get; }
|
||||
public virtual DbSet<Worker> Workers { set; get; }
|
||||
public virtual DbSet<Storekeeper> Storekeepers { set; get; }
|
||||
public virtual DbSet<Car> Cars { set; get; }
|
||||
public virtual DbSet<Request> Requests { set; get; }
|
||||
public virtual DbSet<Feature> Features { set; get; }
|
||||
public virtual DbSet<Bundling> Bundlings { set; get; }
|
||||
public virtual DbSet<CarBundling> CarBundlings { set; get; }
|
||||
public virtual DbSet<PresaleBundling> PresaleBundlings { set; get; }
|
||||
}
|
||||
}
|
||||
|
@ -6,11 +6,6 @@
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Folder Include="Models\" />
|
||||
<Folder Include="Implements\" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="6.0.29" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="6.0.29">
|
||||
|
@ -0,0 +1,91 @@
|
||||
using CarCenterContracts.BindingModels;
|
||||
using CarCenterContracts.SearchModels;
|
||||
using CarCenterContracts.StoragesContracts;
|
||||
using CarCenterContracts.ViewModels;
|
||||
using CarCenterDatabaseImplement.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace CarCenterDatabaseImplement.Implements
|
||||
{
|
||||
public class BundlingStorage : IBundlingStorage
|
||||
{
|
||||
public List<BundlingViewModel> GetFullList()
|
||||
{
|
||||
using var context = new CarCenterDatabase();
|
||||
return context.Bundlings
|
||||
.Select(x => x.GetViewModel)
|
||||
.ToList();
|
||||
}
|
||||
public List<BundlingViewModel> GetFilteredList(BundlingSearchModel model)
|
||||
{
|
||||
using var context = new CarCenterDatabase();
|
||||
if (model.Id.HasValue)
|
||||
{
|
||||
return context.Bundlings
|
||||
.Where(x => x.Id == model.Id)
|
||||
.Select(x => x.GetViewModel)
|
||||
.ToList();
|
||||
}
|
||||
return new();
|
||||
}
|
||||
public BundlingViewModel? GetElement(BundlingSearchModel model)
|
||||
{
|
||||
using var context = new CarCenterDatabase();
|
||||
if (!model.Id.HasValue)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return context.Bundlings
|
||||
.FirstOrDefault(x => model.Id.HasValue && x.Id == model.Id)
|
||||
?.GetViewModel;
|
||||
}
|
||||
public BundlingViewModel? Insert(BundlingBindingModel model)
|
||||
{
|
||||
using var context = new CarCenterDatabase();
|
||||
var newBundling = Bundling.Create(model);
|
||||
if (newBundling == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
context.Bundlings.Add(newBundling);
|
||||
context.SaveChanges();
|
||||
return context.Bundlings
|
||||
.FirstOrDefault(x => x.Id == newBundling.Id)
|
||||
?.GetViewModel;
|
||||
}
|
||||
public BundlingViewModel? Update(BundlingBindingModel model)
|
||||
{
|
||||
using var context = new CarCenterDatabase();
|
||||
var order = context.Bundlings.FirstOrDefault(x => x.Id == model.Id);
|
||||
if (order == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
order.Update(model);
|
||||
context.SaveChanges();
|
||||
return context.Bundlings
|
||||
.FirstOrDefault(x => x.Id == model.Id)
|
||||
?.GetViewModel;
|
||||
}
|
||||
public BundlingViewModel? Delete(BundlingBindingModel model)
|
||||
{
|
||||
using var context = new CarCenterDatabase();
|
||||
var element = context.Bundlings
|
||||
.FirstOrDefault(rec => rec.Id == model.Id);
|
||||
if (element != null)
|
||||
{
|
||||
var deletedElement = context.Bundlings
|
||||
.FirstOrDefault(x => x.Id == model.Id)
|
||||
?.GetViewModel;
|
||||
context.Bundlings.Remove(element);
|
||||
context.SaveChanges();
|
||||
return deletedElement;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
122
CarCenter/CarCenterDatabaseImplement/Implements/CarStorage.cs
Normal file
122
CarCenter/CarCenterDatabaseImplement/Implements/CarStorage.cs
Normal file
@ -0,0 +1,122 @@
|
||||
using CarCenterContracts.BindingModels;
|
||||
using CarCenterContracts.SearchModels;
|
||||
using CarCenterContracts.StoragesContracts;
|
||||
using CarCenterContracts.ViewModels;
|
||||
using CarCenterDatabaseImplement.Models;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace CarCenterDatabaseImplement.Implements
|
||||
{
|
||||
public class CarStorage : ICarStorage
|
||||
{
|
||||
public List<CarViewModel> GetFullList()
|
||||
{
|
||||
using var context = new CarCenterDatabase();
|
||||
return context.Cars
|
||||
.Include(x => x.Bundlings)
|
||||
.ThenInclude(x => x.Bundling)
|
||||
.Include(x => x.Feature)
|
||||
.Include(x => x.Order)
|
||||
.Include(x => x.Storekeeper)
|
||||
.Select(x => x.GetViewModel)
|
||||
.ToList();
|
||||
}
|
||||
public List<CarViewModel> GetFilteredList(CarSearchModel model)
|
||||
{
|
||||
using var context = new CarCenterDatabase();
|
||||
if (model.Id.HasValue)
|
||||
{
|
||||
return context.Cars
|
||||
.Include(x => x.Bundlings)
|
||||
.ThenInclude(x => x.Bundling)
|
||||
.Include(x => x.Feature)
|
||||
.Include(x => x.Order)
|
||||
.Include(x => x.Storekeeper)
|
||||
.Where(x => x.Id == model.Id)
|
||||
.Select(x => x.GetViewModel)
|
||||
.ToList();
|
||||
}
|
||||
return new();
|
||||
}
|
||||
public CarViewModel? GetElement(CarSearchModel model)
|
||||
{
|
||||
using var context = new CarCenterDatabase();
|
||||
if (!model.Id.HasValue)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return context.Cars
|
||||
.Include(x => x.Bundlings) // здесь эксперименты))
|
||||
.ThenInclude(x => x.Bundling)
|
||||
.Include(x => x.Feature)
|
||||
.Include(x => x.Order)
|
||||
.Include(x => x.Storekeeper)
|
||||
.FirstOrDefault(x => model.Id.HasValue && x.Id == model.Id)
|
||||
?.GetViewModel;
|
||||
}
|
||||
public CarViewModel? Insert(CarBindingModel model)
|
||||
{
|
||||
using var context = new CarCenterDatabase();
|
||||
var newCar = Car.Create(context, model);
|
||||
if (newCar == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
context.Cars.Add(newCar);
|
||||
context.SaveChanges();
|
||||
return context.Cars
|
||||
.Include(x => x.Bundlings)
|
||||
.ThenInclude(x => x.Bundling)
|
||||
.Include(x => x.Feature)
|
||||
.Include(x => x.Order)
|
||||
.Include(x => x.Storekeeper)
|
||||
.FirstOrDefault(x => x.Id == newCar.Id)
|
||||
?.GetViewModel;
|
||||
}
|
||||
public CarViewModel? Update(CarBindingModel model)
|
||||
{
|
||||
using var context = new CarCenterDatabase();
|
||||
var car = context.Cars.FirstOrDefault(x => x.Id == model.Id);
|
||||
if (car == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
car.Update(model);
|
||||
context.SaveChanges();
|
||||
return context.Cars
|
||||
.Include(x => x.Bundlings)
|
||||
.ThenInclude(x => x.Bundling)
|
||||
.Include(x => x.Feature)
|
||||
.Include(x => x.Order)
|
||||
.Include(x => x.Storekeeper)
|
||||
.FirstOrDefault(x => x.Id == model.Id)
|
||||
?.GetViewModel;
|
||||
}
|
||||
public CarViewModel? Delete(CarBindingModel model)
|
||||
{
|
||||
using var context = new CarCenterDatabase();
|
||||
var element = context.Cars
|
||||
.FirstOrDefault(rec => rec.Id == model.Id);
|
||||
if (element != null)
|
||||
{
|
||||
var deletedElement = context.Cars
|
||||
.Include(x => x.Bundlings)
|
||||
.ThenInclude(x => x.Bundling)
|
||||
.Include(x => x.Feature)
|
||||
.Include(x => x.Order)
|
||||
.Include(x => x.Storekeeper)
|
||||
.FirstOrDefault(x => x.Id == model.Id)
|
||||
?.GetViewModel;
|
||||
context.Cars.Remove(element);
|
||||
context.SaveChanges();
|
||||
return deletedElement;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,92 @@
|
||||
using CarCenterContracts.BindingModels;
|
||||
using CarCenterContracts.SearchModels;
|
||||
using CarCenterContracts.StoragesContracts;
|
||||
using CarCenterContracts.ViewModels;
|
||||
using CarCenterDatabaseImplement.Models;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace CarCenterDatabaseImplement.Implements
|
||||
{
|
||||
public class FeatureStorage : IFeatureStorage
|
||||
{
|
||||
public List<FeatureViewModel> GetFullList()
|
||||
{
|
||||
using var context = new CarCenterDatabase();
|
||||
return context.Features
|
||||
.Select(x => x.GetViewModel)
|
||||
.ToList();
|
||||
}
|
||||
public List<FeatureViewModel> GetFilteredList(FeatureSearchModel model)
|
||||
{
|
||||
using var context = new CarCenterDatabase();
|
||||
if (model.Id.HasValue)
|
||||
{
|
||||
return context.Features
|
||||
.Where(x => x.Id == model.Id)
|
||||
.Select(x => x.GetViewModel)
|
||||
.ToList();
|
||||
}
|
||||
return new();
|
||||
}
|
||||
public FeatureViewModel? GetElement(FeatureSearchModel model)
|
||||
{
|
||||
using var context = new CarCenterDatabase();
|
||||
if (!model.Id.HasValue)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return context.Features
|
||||
.FirstOrDefault(x => model.Id.HasValue && x.Id == model.Id)
|
||||
?.GetViewModel;
|
||||
}
|
||||
public FeatureViewModel? Insert(FeatureBindingModel model)
|
||||
{
|
||||
using var context = new CarCenterDatabase();
|
||||
var newFeature = Feature.Create(model);
|
||||
if (newFeature == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
context.Features.Add(newFeature);
|
||||
context.SaveChanges();
|
||||
return context.Features
|
||||
.FirstOrDefault(x => x.Id == newFeature.Id)
|
||||
?.GetViewModel;
|
||||
}
|
||||
public FeatureViewModel? Update(FeatureBindingModel model)
|
||||
{
|
||||
using var context = new CarCenterDatabase();
|
||||
var order = context.Features.FirstOrDefault(x => x.Id == model.Id);
|
||||
if (order == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
order.Update(model);
|
||||
context.SaveChanges();
|
||||
return context.Features
|
||||
.FirstOrDefault(x => x.Id == model.Id)
|
||||
?.GetViewModel;
|
||||
}
|
||||
public FeatureViewModel? Delete(FeatureBindingModel model)
|
||||
{
|
||||
using var context = new CarCenterDatabase();
|
||||
var element = context.Features
|
||||
.FirstOrDefault(rec => rec.Id == model.Id);
|
||||
if (element != null)
|
||||
{
|
||||
var deletedElement = context.Features
|
||||
.FirstOrDefault(x => x.Id == model.Id)
|
||||
?.GetViewModel;
|
||||
context.Features.Remove(element);
|
||||
context.SaveChanges();
|
||||
return deletedElement;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
115
CarCenter/CarCenterDatabaseImplement/Implements/OrderStorage.cs
Normal file
115
CarCenter/CarCenterDatabaseImplement/Implements/OrderStorage.cs
Normal file
@ -0,0 +1,115 @@
|
||||
using CarCenterContracts.BindingModels;
|
||||
using CarCenterContracts.SearchModels;
|
||||
using CarCenterContracts.StoragesContracts;
|
||||
using CarCenterContracts.ViewModels;
|
||||
using CarCenterDatabaseImplement.Models;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace CarCenterDatabaseImplement.Implements
|
||||
{
|
||||
public class OrderStorage : IOrderStorage
|
||||
{
|
||||
public OrderViewModel? Delete(OrderBindingModel model)
|
||||
{
|
||||
using var context = new CarCenterDatabase();
|
||||
var element = context.Orders
|
||||
.FirstOrDefault(rec => rec.Id == model.Id);
|
||||
if (element != null)
|
||||
{
|
||||
var deletedElement = context.Orders
|
||||
.Include(x => x.Worker)
|
||||
.Include(x => x.Presales)
|
||||
.ThenInclude(x => x.Presale)
|
||||
.FirstOrDefault(x => x.Id == model.Id)
|
||||
?.GetViewModel;
|
||||
context.Orders.Remove(element);
|
||||
context.SaveChanges();
|
||||
return deletedElement;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public OrderViewModel? GetElement(OrderSearchModel model)
|
||||
{
|
||||
using var context = new CarCenterDatabase();
|
||||
if (!model.Id.HasValue)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return context.Orders
|
||||
.Include(x => x.Worker) //рубрика ЭЭЭЭЭЭЭЭЭКсперименты
|
||||
.Include(x => x.Presales)
|
||||
.ThenInclude(x => x.Presale)
|
||||
.FirstOrDefault(x => model.Id.HasValue && x.Id == model.Id)
|
||||
?.GetViewModel;
|
||||
}
|
||||
|
||||
public List<OrderViewModel> GetFilteredList(OrderSearchModel model)
|
||||
{
|
||||
using var context = new CarCenterDatabase();
|
||||
if (model.Id.HasValue)
|
||||
{
|
||||
return context.Orders
|
||||
.Include(x => x.Worker)
|
||||
.Include(x => x.Presales)
|
||||
.ThenInclude(x => x.Presale)
|
||||
.Where(x => x.Id == model.Id)
|
||||
.Select(x => x.GetViewModel)
|
||||
.ToList();
|
||||
}
|
||||
return new();
|
||||
}
|
||||
|
||||
public List<OrderViewModel> GetFullList()
|
||||
{
|
||||
using var context = new CarCenterDatabase();
|
||||
return context.Orders
|
||||
.Include(x => x.Worker)
|
||||
.Include(x => x.Presales)
|
||||
.ThenInclude(x => x.Presale)
|
||||
.Select(x => x.GetViewModel)
|
||||
.ToList();
|
||||
}
|
||||
|
||||
public OrderViewModel? Insert(OrderBindingModel model)
|
||||
{
|
||||
using var context = new CarCenterDatabase();
|
||||
var newOrder = Order.Create(context,model);
|
||||
if (newOrder == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
context.Orders.Add(newOrder);
|
||||
context.SaveChanges();
|
||||
return context.Orders
|
||||
.Include(x => x.Worker)
|
||||
.Include(x => x.Presales)
|
||||
.ThenInclude(x => x.Presale)
|
||||
.FirstOrDefault(x => x.Id == newOrder.Id)
|
||||
?.GetViewModel;
|
||||
}
|
||||
|
||||
public OrderViewModel? Update(OrderBindingModel model)
|
||||
{
|
||||
using var context = new CarCenterDatabase();
|
||||
var order = context.Orders.FirstOrDefault(x => x.Id == model.Id);
|
||||
if (order == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
order.Update(model);
|
||||
context.SaveChanges();
|
||||
return context.Orders
|
||||
.Include(x => x.Worker)
|
||||
.Include(x => x.Presales)
|
||||
.ThenInclude(x => x.Presale)
|
||||
.FirstOrDefault(x => x.Id == model.Id)
|
||||
?.GetViewModel;
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,109 @@
|
||||
using CarCenterContracts.BindingModels;
|
||||
using CarCenterContracts.SearchModels;
|
||||
using CarCenterContracts.StoragesContracts;
|
||||
using CarCenterContracts.ViewModels;
|
||||
using CarCenterDatabaseImplement.Models;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace CarCenterDatabaseImplement.Implements
|
||||
{
|
||||
public class PresaleStorage : IPresaleStorage
|
||||
{
|
||||
public PresaleViewModel? Delete(PresaleBindingModel model)
|
||||
{
|
||||
using var context = new CarCenterDatabase();
|
||||
var element = context.Presales
|
||||
.FirstOrDefault(rec => rec.Id == model.Id);
|
||||
if (element != null)
|
||||
{
|
||||
var deletedElement = context.Presales
|
||||
.Include(x => x.Bundlings)
|
||||
.ThenInclude(x => x.Bundling)
|
||||
.FirstOrDefault(x => x.Id == model.Id)
|
||||
?.GetViewModel;
|
||||
context.Presales.Remove(element);
|
||||
context.SaveChanges();
|
||||
return deletedElement;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public PresaleViewModel? GetElement(PresaleSearchModel model)
|
||||
{
|
||||
using var context = new CarCenterDatabase();
|
||||
if (!model.Id.HasValue)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return context.Presales
|
||||
.Include(x => x.Bundlings)
|
||||
.ThenInclude(x => x.Bundling)
|
||||
.FirstOrDefault(x => model.Id.HasValue && x.Id == model.Id)
|
||||
?.GetViewModel;
|
||||
}
|
||||
|
||||
public List<PresaleViewModel> GetFilteredList(PresaleSearchModel model)
|
||||
{
|
||||
using var context = new CarCenterDatabase();
|
||||
if (model.Id.HasValue)
|
||||
{
|
||||
return context.Presales
|
||||
.Include(x => x.Bundlings)
|
||||
.ThenInclude(x => x.Bundling)
|
||||
.Where(x => x.Id == model.Id)
|
||||
.Select(x => x.GetViewModel)
|
||||
.ToList();
|
||||
}
|
||||
return new();
|
||||
}
|
||||
|
||||
public List<PresaleViewModel> GetFullList()
|
||||
{
|
||||
using var context = new CarCenterDatabase();
|
||||
return context.Presales
|
||||
.Include(x => x.Bundlings)
|
||||
.ThenInclude(x => x.Bundling)
|
||||
.Select(x => x.GetViewModel)
|
||||
.ToList();
|
||||
}
|
||||
|
||||
public PresaleViewModel? Insert(PresaleBindingModel model)
|
||||
{
|
||||
using var context = new CarCenterDatabase();
|
||||
var newPresale = Presale.Create(context, model);
|
||||
if (newPresale == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
context.Presales.Add(newPresale);
|
||||
context.SaveChanges();
|
||||
return context.Presales
|
||||
.Include(x => x.Bundlings)
|
||||
.ThenInclude(x => x.Bundling)
|
||||
.FirstOrDefault(x => x.Id == newPresale.Id)
|
||||
?.GetViewModel;
|
||||
}
|
||||
|
||||
public PresaleViewModel? Update(PresaleBindingModel model)
|
||||
{
|
||||
using var context = new CarCenterDatabase();
|
||||
var order = context.Presales.FirstOrDefault(x => x.Id == model.Id);
|
||||
if (order == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
order.Update(model);
|
||||
context.SaveChanges();
|
||||
return context.Presales
|
||||
.Include(x => x.Bundlings)
|
||||
.ThenInclude(x => x.Bundling)
|
||||
.FirstOrDefault(x => x.Id == model.Id)
|
||||
?.GetViewModel;
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,103 @@
|
||||
using CarCenterContracts.BindingModels;
|
||||
using CarCenterContracts.SearchModels;
|
||||
using CarCenterContracts.StoragesContracts;
|
||||
using CarCenterContracts.ViewModels;
|
||||
using CarCenterDatabaseImplement.Models;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace CarCenterDatabaseImplement.Implements
|
||||
{
|
||||
public class RequestStorage : IRequestStorage
|
||||
{
|
||||
public RequestViewModel? Delete(RequestBindingModel model)
|
||||
{
|
||||
using var context = new CarCenterDatabase();
|
||||
var element = context.Requests
|
||||
.FirstOrDefault(rec => rec.Id == model.Id);
|
||||
if (element != null)
|
||||
{
|
||||
var deletedElement = context.Requests
|
||||
.Include(x => x.Presale)
|
||||
.FirstOrDefault(x => x.Id == model.Id)
|
||||
?.GetViewModel;
|
||||
context.Requests.Remove(element);
|
||||
context.SaveChanges();
|
||||
return deletedElement;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public RequestViewModel? GetElement(RequestSearchModel model)
|
||||
{
|
||||
using var context = new CarCenterDatabase();
|
||||
if (!model.Id.HasValue)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return context.Requests
|
||||
.Include(x => x.Presale)
|
||||
.FirstOrDefault(x => model.Id.HasValue && x.Id == model.Id)
|
||||
?.GetViewModel;
|
||||
}
|
||||
|
||||
public List<RequestViewModel> GetFilteredList(RequestSearchModel model)
|
||||
{
|
||||
using var context = new CarCenterDatabase();
|
||||
if (model.Id.HasValue)
|
||||
{
|
||||
return context.Requests
|
||||
.Include(x => x.Presale)
|
||||
.Where(x => x.Id == model.Id)
|
||||
.Select(x => x.GetViewModel)
|
||||
.ToList();
|
||||
}
|
||||
return new();
|
||||
}
|
||||
|
||||
public List<RequestViewModel> GetFullList()
|
||||
{
|
||||
using var context = new CarCenterDatabase();
|
||||
return context.Requests
|
||||
.Include(x => x.Presale)
|
||||
.Select(x => x.GetViewModel)
|
||||
.ToList();
|
||||
}
|
||||
|
||||
public RequestViewModel? Insert(RequestBindingModel model)
|
||||
{
|
||||
using var context = new CarCenterDatabase();
|
||||
var newRequest = Request.Create(model);
|
||||
if (newRequest == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
context.Requests.Add(newRequest);
|
||||
context.SaveChanges();
|
||||
return context.Requests
|
||||
.Include(x => x.Presale)
|
||||
.FirstOrDefault(x => x.Id == newRequest.Id)
|
||||
?.GetViewModel;
|
||||
}
|
||||
|
||||
public RequestViewModel? Update(RequestBindingModel model)
|
||||
{
|
||||
using var context = new CarCenterDatabase();
|
||||
var order = context.Requests.FirstOrDefault(x => x.Id == model.Id);
|
||||
if (order == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
order.Update(model);
|
||||
context.SaveChanges();
|
||||
return context.Requests
|
||||
.Include(x => x.Presale)
|
||||
.FirstOrDefault(x => x.Id == model.Id)
|
||||
?.GetViewModel;
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,99 @@
|
||||
using CarCenterContracts.BindingModels;
|
||||
using CarCenterContracts.SearchModels;
|
||||
using CarCenterContracts.StoragesContracts;
|
||||
using CarCenterContracts.ViewModels;
|
||||
using CarCenterDatabaseImplement.Models;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace CarCenterDatabaseImplement.Implements
|
||||
{
|
||||
public class StorekeeperStorage : IStorekeeperStorage
|
||||
{
|
||||
public List<StorekeeperViewModel> GetFullList()
|
||||
{
|
||||
using var context = new CarCenterDatabase();
|
||||
|
||||
return context.Storekeepers
|
||||
.Select(x => x.GetViewModel)
|
||||
.ToList();
|
||||
}
|
||||
public List<StorekeeperViewModel> GetFilteredList(StorekeeperSearchModel model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
return new();
|
||||
}
|
||||
|
||||
if (model.Id.HasValue)
|
||||
{
|
||||
var res = GetElement(model);
|
||||
|
||||
return res != null ? new() { res } : new();
|
||||
}
|
||||
return new();
|
||||
}
|
||||
|
||||
public StorekeeperViewModel? GetElement(StorekeeperSearchModel model)
|
||||
{
|
||||
using var context = new CarCenterDatabase();
|
||||
|
||||
if (model.Id.HasValue)
|
||||
return context.Storekeepers
|
||||
.FirstOrDefault(x => x.Id == model.Id)
|
||||
?.GetViewModel;
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
public StorekeeperViewModel? Delete(StorekeeperBindingModel model)
|
||||
{
|
||||
using var context = new CarCenterDatabase();
|
||||
|
||||
var res = context.Storekeepers
|
||||
.FirstOrDefault(x => x.Id == model.Id);
|
||||
|
||||
if (res != null)
|
||||
{
|
||||
context.Storekeepers.Remove(res);
|
||||
context.SaveChanges();
|
||||
}
|
||||
|
||||
return res?.GetViewModel;
|
||||
}
|
||||
|
||||
public StorekeeperViewModel? Insert(StorekeeperBindingModel model)
|
||||
{
|
||||
using var context = new CarCenterDatabase();
|
||||
|
||||
var res = Storekeeper.Create(model);
|
||||
|
||||
if (res != null)
|
||||
{
|
||||
context.Storekeepers.Add(res);
|
||||
context.SaveChanges();
|
||||
}
|
||||
|
||||
return res?.GetViewModel;
|
||||
}
|
||||
|
||||
public StorekeeperViewModel? Update(StorekeeperBindingModel model)
|
||||
{
|
||||
using var context = new CarCenterDatabase();
|
||||
|
||||
var res = context.Storekeepers.FirstOrDefault(x => x.Id == model.Id);
|
||||
|
||||
if (res != null)
|
||||
{
|
||||
res.Update(model);
|
||||
context.SaveChanges();
|
||||
}
|
||||
|
||||
return res?.GetViewModel;
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,99 @@
|
||||
using CarCenterContracts.BindingModels;
|
||||
using CarCenterContracts.SearchModels;
|
||||
using CarCenterContracts.StoragesContracts;
|
||||
using CarCenterContracts.ViewModels;
|
||||
using CarCenterDatabaseImplement.Models;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace CarCenterDatabaseImplement.Implements
|
||||
{
|
||||
public class WorkerStorage : IWorkerStorage
|
||||
{
|
||||
public List<WorkerViewModel> GetFullList()
|
||||
{
|
||||
using var context = new CarCenterDatabase();
|
||||
|
||||
return context.Workers
|
||||
.Select(x => x.GetViewModel)
|
||||
.ToList();
|
||||
}
|
||||
public List<WorkerViewModel> GetFilteredList(WorkerSearchModel model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
return new();
|
||||
}
|
||||
|
||||
if (model.Id.HasValue)
|
||||
{
|
||||
var res = GetElement(model);
|
||||
|
||||
return res != null ? new() { res } : new();
|
||||
}
|
||||
return new();
|
||||
}
|
||||
|
||||
public WorkerViewModel? GetElement(WorkerSearchModel model)
|
||||
{
|
||||
using var context = new CarCenterDatabase();
|
||||
|
||||
if (model.Id.HasValue)
|
||||
return context.Workers
|
||||
.FirstOrDefault(x => x.Id == model.Id)
|
||||
?.GetViewModel;
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
public WorkerViewModel? Delete(WorkerBindingModel model)
|
||||
{
|
||||
using var context = new CarCenterDatabase();
|
||||
|
||||
var res = context.Workers
|
||||
.FirstOrDefault(x => x.Id == model.Id);
|
||||
|
||||
if (res != null)
|
||||
{
|
||||
context.Workers.Remove(res);
|
||||
context.SaveChanges();
|
||||
}
|
||||
|
||||
return res?.GetViewModel;
|
||||
}
|
||||
|
||||
public WorkerViewModel? Insert(WorkerBindingModel model)
|
||||
{
|
||||
using var context = new CarCenterDatabase();
|
||||
|
||||
var res = Worker.Create(model);
|
||||
|
||||
if (res != null)
|
||||
{
|
||||
context.Workers.Add(res);
|
||||
context.SaveChanges();
|
||||
}
|
||||
|
||||
return res?.GetViewModel;
|
||||
}
|
||||
|
||||
public WorkerViewModel? Update(WorkerBindingModel model)
|
||||
{
|
||||
using var context = new CarCenterDatabase();
|
||||
|
||||
var res = context.Workers.FirstOrDefault(x => x.Id == model.Id);
|
||||
|
||||
if (res != null)
|
||||
{
|
||||
res.Update(model);
|
||||
context.SaveChanges();
|
||||
}
|
||||
|
||||
return res?.GetViewModel;
|
||||
}
|
||||
}
|
||||
}
|
501
CarCenter/CarCenterDatabaseImplement/Migrations/20240428140324_InitialCreate.Designer.cs
generated
Normal file
501
CarCenter/CarCenterDatabaseImplement/Migrations/20240428140324_InitialCreate.Designer.cs
generated
Normal file
@ -0,0 +1,501 @@
|
||||
// <auto-generated />
|
||||
using System;
|
||||
using CarCenterDatabaseImplement;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace CarCenterDatabaseImplement.Migrations
|
||||
{
|
||||
[DbContext(typeof(CarCenterDatabase))]
|
||||
[Migration("20240428140324_InitialCreate")]
|
||||
partial class InitialCreate
|
||||
{
|
||||
protected override void BuildTargetModel(ModelBuilder modelBuilder)
|
||||
{
|
||||
#pragma warning disable 612, 618
|
||||
modelBuilder
|
||||
.HasAnnotation("ProductVersion", "6.0.29")
|
||||
.HasAnnotation("Relational:MaxIdentifierLength", 63);
|
||||
|
||||
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
|
||||
|
||||
modelBuilder.Entity("CarCenterDatabaseImplement.Models.Bundling", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("integer");
|
||||
|
||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<int>("EquipmentPackage")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<double>("Price")
|
||||
.HasColumnType("double precision");
|
||||
|
||||
b.Property<int>("TirePackage")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<int>("ToolKit")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Bundlings");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("CarCenterDatabaseImplement.Models.Car", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("integer");
|
||||
|
||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<int>("CarBrand")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<int>("CarClass")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<int>("FeatureID")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<int?>("FeatureId")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<string>("Model")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<int>("OrderId")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<double>("Price")
|
||||
.HasColumnType("double precision");
|
||||
|
||||
b.Property<int>("StorekeeperId")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<long>("VINnumber")
|
||||
.HasColumnType("bigint");
|
||||
|
||||
b.Property<int>("Year")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("FeatureId");
|
||||
|
||||
b.HasIndex("OrderId");
|
||||
|
||||
b.HasIndex("StorekeeperId");
|
||||
|
||||
b.ToTable("Cars");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("CarCenterDatabaseImplement.Models.CarBundling", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("integer");
|
||||
|
||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<int>("BundlingId")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<int>("CarId")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("BundlingId");
|
||||
|
||||
b.HasIndex("CarId");
|
||||
|
||||
b.ToTable("CarBundlings");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("CarCenterDatabaseImplement.Models.Feature", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("integer");
|
||||
|
||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<string>("CabinColor")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<int>("DriveType")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<int>("HelpDevice")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<double>("Price")
|
||||
.HasColumnType("double precision");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Features");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("CarCenterDatabaseImplement.Models.Order", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("integer");
|
||||
|
||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<string>("BuyerFCS")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<DateTime>("PaymentDate")
|
||||
.HasColumnType("timestamp without time zone");
|
||||
|
||||
b.Property<int>("PaymentStatus")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<int>("PaymentType")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<double>("Sum")
|
||||
.HasColumnType("double precision");
|
||||
|
||||
b.Property<int>("WorkerId")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("WorkerId");
|
||||
|
||||
b.ToTable("Orders");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("CarCenterDatabaseImplement.Models.OrderPresale", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("integer");
|
||||
|
||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<int>("OrderId")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<int>("PresaleId")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("OrderId");
|
||||
|
||||
b.HasIndex("PresaleId");
|
||||
|
||||
b.ToTable("OrderPresales");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("CarCenterDatabaseImplement.Models.Presale", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("integer");
|
||||
|
||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<string>("Description")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<DateTime>("DueTill")
|
||||
.HasColumnType("timestamp without time zone");
|
||||
|
||||
b.Property<int>("PresaleStatus")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<double>("Price")
|
||||
.HasColumnType("double precision");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Presales");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("CarCenterDatabaseImplement.Models.PresaleBundling", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("integer");
|
||||
|
||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<int>("BundlingId")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<int>("PresaleId")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("BundlingId");
|
||||
|
||||
b.HasIndex("PresaleId");
|
||||
|
||||
b.ToTable("PresaleBundlings");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("CarCenterDatabaseImplement.Models.Request", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("integer");
|
||||
|
||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<string>("Description")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<int>("PresaleId")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<int>("RequestType")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("PresaleId");
|
||||
|
||||
b.ToTable("Requests");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("CarCenterDatabaseImplement.Models.Storekeeper", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("integer");
|
||||
|
||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<string>("Email")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<string>("Name")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<string>("Password")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<string>("Patronymic")
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<long>("PhoneNumber")
|
||||
.HasColumnType("bigint");
|
||||
|
||||
b.Property<string>("Surname")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Storekeepers");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("CarCenterDatabaseImplement.Models.Worker", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("integer");
|
||||
|
||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<string>("Email")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<string>("Name")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<string>("Password")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<string>("Patronymic")
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<long>("PhoneNumber")
|
||||
.HasColumnType("bigint");
|
||||
|
||||
b.Property<string>("Surname")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Workers");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("CarCenterDatabaseImplement.Models.Car", b =>
|
||||
{
|
||||
b.HasOne("CarCenterDatabaseImplement.Models.Feature", "Feature")
|
||||
.WithMany("Cars")
|
||||
.HasForeignKey("FeatureId");
|
||||
|
||||
b.HasOne("CarCenterDatabaseImplement.Models.Order", "Order")
|
||||
.WithMany("Cars")
|
||||
.HasForeignKey("OrderId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("CarCenterDatabaseImplement.Models.Storekeeper", "Storekeeper")
|
||||
.WithMany("Cars")
|
||||
.HasForeignKey("StorekeeperId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Feature");
|
||||
|
||||
b.Navigation("Order");
|
||||
|
||||
b.Navigation("Storekeeper");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("CarCenterDatabaseImplement.Models.CarBundling", b =>
|
||||
{
|
||||
b.HasOne("CarCenterDatabaseImplement.Models.Bundling", "Bundling")
|
||||
.WithMany("CarBundling")
|
||||
.HasForeignKey("BundlingId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("CarCenterDatabaseImplement.Models.Car", "Car")
|
||||
.WithMany("Bundlings")
|
||||
.HasForeignKey("CarId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Bundling");
|
||||
|
||||
b.Navigation("Car");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("CarCenterDatabaseImplement.Models.Order", b =>
|
||||
{
|
||||
b.HasOne("CarCenterDatabaseImplement.Models.Worker", "Worker")
|
||||
.WithMany("Orders")
|
||||
.HasForeignKey("WorkerId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Worker");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("CarCenterDatabaseImplement.Models.OrderPresale", b =>
|
||||
{
|
||||
b.HasOne("CarCenterDatabaseImplement.Models.Order", "Order")
|
||||
.WithMany("Presales")
|
||||
.HasForeignKey("OrderId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("CarCenterDatabaseImplement.Models.Presale", "Presale")
|
||||
.WithMany("OrderPresales")
|
||||
.HasForeignKey("PresaleId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Order");
|
||||
|
||||
b.Navigation("Presale");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("CarCenterDatabaseImplement.Models.PresaleBundling", b =>
|
||||
{
|
||||
b.HasOne("CarCenterDatabaseImplement.Models.Bundling", "Bundling")
|
||||
.WithMany("PresaleBundling")
|
||||
.HasForeignKey("BundlingId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("CarCenterDatabaseImplement.Models.Presale", "Presale")
|
||||
.WithMany("Bundlings")
|
||||
.HasForeignKey("PresaleId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Bundling");
|
||||
|
||||
b.Navigation("Presale");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("CarCenterDatabaseImplement.Models.Request", b =>
|
||||
{
|
||||
b.HasOne("CarCenterDatabaseImplement.Models.Presale", "Presale")
|
||||
.WithMany("Requests")
|
||||
.HasForeignKey("PresaleId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Presale");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("CarCenterDatabaseImplement.Models.Bundling", b =>
|
||||
{
|
||||
b.Navigation("CarBundling");
|
||||
|
||||
b.Navigation("PresaleBundling");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("CarCenterDatabaseImplement.Models.Car", b =>
|
||||
{
|
||||
b.Navigation("Bundlings");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("CarCenterDatabaseImplement.Models.Feature", b =>
|
||||
{
|
||||
b.Navigation("Cars");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("CarCenterDatabaseImplement.Models.Order", b =>
|
||||
{
|
||||
b.Navigation("Cars");
|
||||
|
||||
b.Navigation("Presales");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("CarCenterDatabaseImplement.Models.Presale", b =>
|
||||
{
|
||||
b.Navigation("Bundlings");
|
||||
|
||||
b.Navigation("OrderPresales");
|
||||
|
||||
b.Navigation("Requests");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("CarCenterDatabaseImplement.Models.Storekeeper", b =>
|
||||
{
|
||||
b.Navigation("Cars");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("CarCenterDatabaseImplement.Models.Worker", b =>
|
||||
{
|
||||
b.Navigation("Orders");
|
||||
});
|
||||
#pragma warning restore 612, 618
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,351 @@
|
||||
using System;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace CarCenterDatabaseImplement.Migrations
|
||||
{
|
||||
public partial class InitialCreate : Migration
|
||||
{
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.CreateTable(
|
||||
name: "Bundlings",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(type: "integer", nullable: false)
|
||||
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
||||
EquipmentPackage = table.Column<int>(type: "integer", nullable: false),
|
||||
TirePackage = table.Column<int>(type: "integer", nullable: false),
|
||||
ToolKit = table.Column<int>(type: "integer", nullable: false),
|
||||
Price = table.Column<double>(type: "double precision", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_Bundlings", x => x.Id);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "Features",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(type: "integer", nullable: false)
|
||||
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
||||
HelpDevice = table.Column<int>(type: "integer", nullable: false),
|
||||
CabinColor = table.Column<string>(type: "text", nullable: false),
|
||||
DriveType = table.Column<int>(type: "integer", nullable: false),
|
||||
Price = table.Column<double>(type: "double precision", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_Features", x => x.Id);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "Presales",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(type: "integer", nullable: false)
|
||||
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
||||
PresaleStatus = table.Column<int>(type: "integer", nullable: false),
|
||||
Description = table.Column<string>(type: "text", nullable: false),
|
||||
DueTill = table.Column<DateTime>(type: "timestamp without time zone", nullable: false),
|
||||
Price = table.Column<double>(type: "double precision", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_Presales", x => x.Id);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "Storekeepers",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(type: "integer", nullable: false)
|
||||
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
||||
Name = table.Column<string>(type: "text", nullable: false),
|
||||
Surname = table.Column<string>(type: "text", nullable: false),
|
||||
Patronymic = table.Column<string>(type: "text", nullable: true),
|
||||
Password = table.Column<string>(type: "text", nullable: false),
|
||||
Email = table.Column<string>(type: "text", nullable: false),
|
||||
PhoneNumber = table.Column<long>(type: "bigint", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_Storekeepers", x => x.Id);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "Workers",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(type: "integer", nullable: false)
|
||||
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
||||
Name = table.Column<string>(type: "text", nullable: false),
|
||||
Surname = table.Column<string>(type: "text", nullable: false),
|
||||
Patronymic = table.Column<string>(type: "text", nullable: true),
|
||||
Password = table.Column<string>(type: "text", nullable: false),
|
||||
Email = table.Column<string>(type: "text", nullable: false),
|
||||
PhoneNumber = table.Column<long>(type: "bigint", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_Workers", x => x.Id);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "PresaleBundlings",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(type: "integer", nullable: false)
|
||||
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
||||
PresaleId = table.Column<int>(type: "integer", nullable: false),
|
||||
BundlingId = table.Column<int>(type: "integer", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_PresaleBundlings", x => x.Id);
|
||||
table.ForeignKey(
|
||||
name: "FK_PresaleBundlings_Bundlings_BundlingId",
|
||||
column: x => x.BundlingId,
|
||||
principalTable: "Bundlings",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
table.ForeignKey(
|
||||
name: "FK_PresaleBundlings_Presales_PresaleId",
|
||||
column: x => x.PresaleId,
|
||||
principalTable: "Presales",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "Requests",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(type: "integer", nullable: false)
|
||||
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
||||
PresaleId = table.Column<int>(type: "integer", nullable: false),
|
||||
Description = table.Column<string>(type: "text", nullable: false),
|
||||
RequestType = table.Column<int>(type: "integer", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_Requests", x => x.Id);
|
||||
table.ForeignKey(
|
||||
name: "FK_Requests_Presales_PresaleId",
|
||||
column: x => x.PresaleId,
|
||||
principalTable: "Presales",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "Orders",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(type: "integer", nullable: false)
|
||||
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
||||
WorkerId = table.Column<int>(type: "integer", nullable: false),
|
||||
PaymentType = table.Column<int>(type: "integer", nullable: false),
|
||||
PaymentStatus = table.Column<int>(type: "integer", nullable: false),
|
||||
BuyerFCS = table.Column<string>(type: "text", nullable: false),
|
||||
PaymentDate = table.Column<DateTime>(type: "timestamp without time zone", nullable: false),
|
||||
Sum = table.Column<double>(type: "double precision", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_Orders", x => x.Id);
|
||||
table.ForeignKey(
|
||||
name: "FK_Orders_Workers_WorkerId",
|
||||
column: x => x.WorkerId,
|
||||
principalTable: "Workers",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "Cars",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(type: "integer", nullable: false)
|
||||
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
||||
StorekeeperId = table.Column<int>(type: "integer", nullable: false),
|
||||
OrderId = table.Column<int>(type: "integer", nullable: false),
|
||||
FeatureId = table.Column<int>(type: "integer", nullable: true),
|
||||
CarBrand = table.Column<int>(type: "integer", nullable: false),
|
||||
Model = table.Column<string>(type: "text", nullable: false),
|
||||
CarClass = table.Column<int>(type: "integer", nullable: false),
|
||||
Year = table.Column<int>(type: "integer", nullable: false),
|
||||
Price = table.Column<double>(type: "double precision", nullable: false),
|
||||
VINnumber = table.Column<long>(type: "bigint", nullable: false),
|
||||
FeatureID = table.Column<int>(type: "integer", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_Cars", x => x.Id);
|
||||
table.ForeignKey(
|
||||
name: "FK_Cars_Features_FeatureId",
|
||||
column: x => x.FeatureId,
|
||||
principalTable: "Features",
|
||||
principalColumn: "Id");
|
||||
table.ForeignKey(
|
||||
name: "FK_Cars_Orders_OrderId",
|
||||
column: x => x.OrderId,
|
||||
principalTable: "Orders",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
table.ForeignKey(
|
||||
name: "FK_Cars_Storekeepers_StorekeeperId",
|
||||
column: x => x.StorekeeperId,
|
||||
principalTable: "Storekeepers",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "OrderPresales",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(type: "integer", nullable: false)
|
||||
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
||||
OrderId = table.Column<int>(type: "integer", nullable: false),
|
||||
PresaleId = table.Column<int>(type: "integer", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_OrderPresales", x => x.Id);
|
||||
table.ForeignKey(
|
||||
name: "FK_OrderPresales_Orders_OrderId",
|
||||
column: x => x.OrderId,
|
||||
principalTable: "Orders",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
table.ForeignKey(
|
||||
name: "FK_OrderPresales_Presales_PresaleId",
|
||||
column: x => x.PresaleId,
|
||||
principalTable: "Presales",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "CarBundlings",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(type: "integer", nullable: false)
|
||||
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
||||
CarId = table.Column<int>(type: "integer", nullable: false),
|
||||
BundlingId = table.Column<int>(type: "integer", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_CarBundlings", x => x.Id);
|
||||
table.ForeignKey(
|
||||
name: "FK_CarBundlings_Bundlings_BundlingId",
|
||||
column: x => x.BundlingId,
|
||||
principalTable: "Bundlings",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
table.ForeignKey(
|
||||
name: "FK_CarBundlings_Cars_CarId",
|
||||
column: x => x.CarId,
|
||||
principalTable: "Cars",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_CarBundlings_BundlingId",
|
||||
table: "CarBundlings",
|
||||
column: "BundlingId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_CarBundlings_CarId",
|
||||
table: "CarBundlings",
|
||||
column: "CarId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_Cars_FeatureId",
|
||||
table: "Cars",
|
||||
column: "FeatureId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_Cars_OrderId",
|
||||
table: "Cars",
|
||||
column: "OrderId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_Cars_StorekeeperId",
|
||||
table: "Cars",
|
||||
column: "StorekeeperId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_OrderPresales_OrderId",
|
||||
table: "OrderPresales",
|
||||
column: "OrderId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_OrderPresales_PresaleId",
|
||||
table: "OrderPresales",
|
||||
column: "PresaleId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_Orders_WorkerId",
|
||||
table: "Orders",
|
||||
column: "WorkerId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_PresaleBundlings_BundlingId",
|
||||
table: "PresaleBundlings",
|
||||
column: "BundlingId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_PresaleBundlings_PresaleId",
|
||||
table: "PresaleBundlings",
|
||||
column: "PresaleId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_Requests_PresaleId",
|
||||
table: "Requests",
|
||||
column: "PresaleId");
|
||||
}
|
||||
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropTable(
|
||||
name: "CarBundlings");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "OrderPresales");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "PresaleBundlings");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "Requests");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "Cars");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "Bundlings");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "Presales");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "Features");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "Orders");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "Storekeepers");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "Workers");
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,499 @@
|
||||
// <auto-generated />
|
||||
using System;
|
||||
using CarCenterDatabaseImplement;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace CarCenterDatabaseImplement.Migrations
|
||||
{
|
||||
[DbContext(typeof(CarCenterDatabase))]
|
||||
partial class CarCenterDatabaseModelSnapshot : ModelSnapshot
|
||||
{
|
||||
protected override void BuildModel(ModelBuilder modelBuilder)
|
||||
{
|
||||
#pragma warning disable 612, 618
|
||||
modelBuilder
|
||||
.HasAnnotation("ProductVersion", "6.0.29")
|
||||
.HasAnnotation("Relational:MaxIdentifierLength", 63);
|
||||
|
||||
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
|
||||
|
||||
modelBuilder.Entity("CarCenterDatabaseImplement.Models.Bundling", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("integer");
|
||||
|
||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<int>("EquipmentPackage")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<double>("Price")
|
||||
.HasColumnType("double precision");
|
||||
|
||||
b.Property<int>("TirePackage")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<int>("ToolKit")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Bundlings");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("CarCenterDatabaseImplement.Models.Car", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("integer");
|
||||
|
||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<int>("CarBrand")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<int>("CarClass")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<int>("FeatureID")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<int?>("FeatureId")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<string>("Model")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<int>("OrderId")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<double>("Price")
|
||||
.HasColumnType("double precision");
|
||||
|
||||
b.Property<int>("StorekeeperId")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<long>("VINnumber")
|
||||
.HasColumnType("bigint");
|
||||
|
||||
b.Property<int>("Year")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("FeatureId");
|
||||
|
||||
b.HasIndex("OrderId");
|
||||
|
||||
b.HasIndex("StorekeeperId");
|
||||
|
||||
b.ToTable("Cars");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("CarCenterDatabaseImplement.Models.CarBundling", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("integer");
|
||||
|
||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<int>("BundlingId")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<int>("CarId")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("BundlingId");
|
||||
|
||||
b.HasIndex("CarId");
|
||||
|
||||
b.ToTable("CarBundlings");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("CarCenterDatabaseImplement.Models.Feature", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("integer");
|
||||
|
||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<string>("CabinColor")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<int>("DriveType")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<int>("HelpDevice")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<double>("Price")
|
||||
.HasColumnType("double precision");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Features");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("CarCenterDatabaseImplement.Models.Order", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("integer");
|
||||
|
||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<string>("BuyerFCS")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<DateTime>("PaymentDate")
|
||||
.HasColumnType("timestamp without time zone");
|
||||
|
||||
b.Property<int>("PaymentStatus")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<int>("PaymentType")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<double>("Sum")
|
||||
.HasColumnType("double precision");
|
||||
|
||||
b.Property<int>("WorkerId")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("WorkerId");
|
||||
|
||||
b.ToTable("Orders");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("CarCenterDatabaseImplement.Models.OrderPresale", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("integer");
|
||||
|
||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<int>("OrderId")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<int>("PresaleId")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("OrderId");
|
||||
|
||||
b.HasIndex("PresaleId");
|
||||
|
||||
b.ToTable("OrderPresales");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("CarCenterDatabaseImplement.Models.Presale", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("integer");
|
||||
|
||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<string>("Description")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<DateTime>("DueTill")
|
||||
.HasColumnType("timestamp without time zone");
|
||||
|
||||
b.Property<int>("PresaleStatus")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<double>("Price")
|
||||
.HasColumnType("double precision");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Presales");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("CarCenterDatabaseImplement.Models.PresaleBundling", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("integer");
|
||||
|
||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<int>("BundlingId")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<int>("PresaleId")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("BundlingId");
|
||||
|
||||
b.HasIndex("PresaleId");
|
||||
|
||||
b.ToTable("PresaleBundlings");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("CarCenterDatabaseImplement.Models.Request", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("integer");
|
||||
|
||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<string>("Description")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<int>("PresaleId")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<int>("RequestType")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("PresaleId");
|
||||
|
||||
b.ToTable("Requests");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("CarCenterDatabaseImplement.Models.Storekeeper", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("integer");
|
||||
|
||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<string>("Email")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<string>("Name")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<string>("Password")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<string>("Patronymic")
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<long>("PhoneNumber")
|
||||
.HasColumnType("bigint");
|
||||
|
||||
b.Property<string>("Surname")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Storekeepers");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("CarCenterDatabaseImplement.Models.Worker", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("integer");
|
||||
|
||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<string>("Email")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<string>("Name")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<string>("Password")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<string>("Patronymic")
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<long>("PhoneNumber")
|
||||
.HasColumnType("bigint");
|
||||
|
||||
b.Property<string>("Surname")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Workers");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("CarCenterDatabaseImplement.Models.Car", b =>
|
||||
{
|
||||
b.HasOne("CarCenterDatabaseImplement.Models.Feature", "Feature")
|
||||
.WithMany("Cars")
|
||||
.HasForeignKey("FeatureId");
|
||||
|
||||
b.HasOne("CarCenterDatabaseImplement.Models.Order", "Order")
|
||||
.WithMany("Cars")
|
||||
.HasForeignKey("OrderId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("CarCenterDatabaseImplement.Models.Storekeeper", "Storekeeper")
|
||||
.WithMany("Cars")
|
||||
.HasForeignKey("StorekeeperId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Feature");
|
||||
|
||||
b.Navigation("Order");
|
||||
|
||||
b.Navigation("Storekeeper");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("CarCenterDatabaseImplement.Models.CarBundling", b =>
|
||||
{
|
||||
b.HasOne("CarCenterDatabaseImplement.Models.Bundling", "Bundling")
|
||||
.WithMany("CarBundling")
|
||||
.HasForeignKey("BundlingId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("CarCenterDatabaseImplement.Models.Car", "Car")
|
||||
.WithMany("Bundlings")
|
||||
.HasForeignKey("CarId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Bundling");
|
||||
|
||||
b.Navigation("Car");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("CarCenterDatabaseImplement.Models.Order", b =>
|
||||
{
|
||||
b.HasOne("CarCenterDatabaseImplement.Models.Worker", "Worker")
|
||||
.WithMany("Orders")
|
||||
.HasForeignKey("WorkerId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Worker");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("CarCenterDatabaseImplement.Models.OrderPresale", b =>
|
||||
{
|
||||
b.HasOne("CarCenterDatabaseImplement.Models.Order", "Order")
|
||||
.WithMany("Presales")
|
||||
.HasForeignKey("OrderId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("CarCenterDatabaseImplement.Models.Presale", "Presale")
|
||||
.WithMany("OrderPresales")
|
||||
.HasForeignKey("PresaleId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Order");
|
||||
|
||||
b.Navigation("Presale");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("CarCenterDatabaseImplement.Models.PresaleBundling", b =>
|
||||
{
|
||||
b.HasOne("CarCenterDatabaseImplement.Models.Bundling", "Bundling")
|
||||
.WithMany("PresaleBundling")
|
||||
.HasForeignKey("BundlingId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("CarCenterDatabaseImplement.Models.Presale", "Presale")
|
||||
.WithMany("Bundlings")
|
||||
.HasForeignKey("PresaleId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Bundling");
|
||||
|
||||
b.Navigation("Presale");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("CarCenterDatabaseImplement.Models.Request", b =>
|
||||
{
|
||||
b.HasOne("CarCenterDatabaseImplement.Models.Presale", "Presale")
|
||||
.WithMany("Requests")
|
||||
.HasForeignKey("PresaleId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Presale");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("CarCenterDatabaseImplement.Models.Bundling", b =>
|
||||
{
|
||||
b.Navigation("CarBundling");
|
||||
|
||||
b.Navigation("PresaleBundling");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("CarCenterDatabaseImplement.Models.Car", b =>
|
||||
{
|
||||
b.Navigation("Bundlings");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("CarCenterDatabaseImplement.Models.Feature", b =>
|
||||
{
|
||||
b.Navigation("Cars");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("CarCenterDatabaseImplement.Models.Order", b =>
|
||||
{
|
||||
b.Navigation("Cars");
|
||||
|
||||
b.Navigation("Presales");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("CarCenterDatabaseImplement.Models.Presale", b =>
|
||||
{
|
||||
b.Navigation("Bundlings");
|
||||
|
||||
b.Navigation("OrderPresales");
|
||||
|
||||
b.Navigation("Requests");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("CarCenterDatabaseImplement.Models.Storekeeper", b =>
|
||||
{
|
||||
b.Navigation("Cars");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("CarCenterDatabaseImplement.Models.Worker", b =>
|
||||
{
|
||||
b.Navigation("Orders");
|
||||
});
|
||||
#pragma warning restore 612, 618
|
||||
}
|
||||
}
|
||||
}
|
77
CarCenter/CarCenterDatabaseImplement/Models/Bundling.cs
Normal file
77
CarCenter/CarCenterDatabaseImplement/Models/Bundling.cs
Normal file
@ -0,0 +1,77 @@
|
||||
using CarCenterContracts.BindingModels;
|
||||
using CarCenterContracts.ViewModels;
|
||||
using CarCenterDataModels.Enums;
|
||||
using CarCenterDataModels.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace CarCenterDatabaseImplement.Models
|
||||
{
|
||||
public class Bundling : IBundlingModel
|
||||
{
|
||||
public int Id { get; private set; }
|
||||
[Required]
|
||||
public EquipmentPackage EquipmentPackage { get; set; } = EquipmentPackage.Неизвестно;
|
||||
[Required]
|
||||
public TirePackage TirePackage { get; set; } = TirePackage.Неизвестно;
|
||||
[Required]
|
||||
public ToolKit ToolKit { get; set; } = ToolKit.Неизвестно;
|
||||
[Required]
|
||||
public double Price { get; set; }
|
||||
[ForeignKey("BundlingId")]
|
||||
public virtual List<CarBundling> CarBundling { get; set; } = new();
|
||||
[ForeignKey("BundlingId")]
|
||||
public virtual List<PresaleBundling> PresaleBundling { get; set; } = new();
|
||||
public static Bundling? Create(BundlingBindingModel model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return new Bundling()
|
||||
{
|
||||
Id = model.Id,
|
||||
EquipmentPackage = model.EquipmentPackage,
|
||||
TirePackage = model.TirePackage,
|
||||
ToolKit = model.ToolKit,
|
||||
Price = model.Price,
|
||||
};
|
||||
}
|
||||
public static Bundling Create(BundlingViewModel model)
|
||||
{
|
||||
return new Bundling
|
||||
{
|
||||
Id = model.Id,
|
||||
EquipmentPackage = model.EquipmentPackage,
|
||||
TirePackage = model.TirePackage,
|
||||
ToolKit = model.ToolKit,
|
||||
Price = model.Price,
|
||||
};
|
||||
}
|
||||
public void Update(BundlingBindingModel model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
EquipmentPackage = model.EquipmentPackage;
|
||||
TirePackage = model.TirePackage;
|
||||
ToolKit = model.ToolKit;
|
||||
Price = model.Price;
|
||||
}
|
||||
public BundlingViewModel GetViewModel => new()
|
||||
{
|
||||
Id = Id,
|
||||
EquipmentPackage = EquipmentPackage,
|
||||
TirePackage = TirePackage,
|
||||
ToolKit = ToolKit,
|
||||
Price = Price,
|
||||
};
|
||||
}
|
||||
}
|
132
CarCenter/CarCenterDatabaseImplement/Models/Car.cs
Normal file
132
CarCenter/CarCenterDatabaseImplement/Models/Car.cs
Normal file
@ -0,0 +1,132 @@
|
||||
using CarCenterContracts.BindingModels;
|
||||
using CarCenterContracts.ViewModels;
|
||||
using CarCenterDataModels.Enums;
|
||||
using CarCenterDataModels.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace CarCenterDatabaseImplement.Models
|
||||
{
|
||||
public class Car : ICarModel
|
||||
{
|
||||
public int Id { get; private set; }
|
||||
public int StorekeeperId { get; set; }
|
||||
public int OrderId { get; set; }
|
||||
public int? FeatureId { get; set; }
|
||||
[Required]
|
||||
public CarBrand CarBrand { get; set; } = CarBrand.Неизвестно;
|
||||
[Required]
|
||||
public string Model { get; set; } = string.Empty;
|
||||
[Required]
|
||||
public CarClass CarClass { get; set; } = CarClass.Неизвестно;
|
||||
[Required]
|
||||
public int Year { get; set; }
|
||||
[Required]
|
||||
public double Price { get; set; }
|
||||
[Required]
|
||||
public long VINnumber { get; set; }
|
||||
[Required]
|
||||
public int FeatureID { get; set; }
|
||||
public virtual Storekeeper Storekeeper { get; set; }
|
||||
public virtual Feature Feature { get; set; }
|
||||
public virtual Order Order { get; set; }
|
||||
|
||||
private Dictionary<int, IBundlingModel>? _carBundlings = null;
|
||||
[ForeignKey("CarId")]
|
||||
public virtual List<CarBundling> Bundlings { get; set; } = new();
|
||||
[NotMapped]
|
||||
public Dictionary<int, IBundlingModel> CarBundlings
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_carBundlings == null)
|
||||
{
|
||||
_carBundlings = Bundlings.ToDictionary(recPc => recPc.BundlingId, recPc => recPc.Bundling as IBundlingModel);
|
||||
}
|
||||
return _carBundlings;
|
||||
}
|
||||
}
|
||||
public static Car? Create(CarCenterDatabase context, CarBindingModel model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return new Car()
|
||||
{
|
||||
Id = model.Id,
|
||||
StorekeeperId = model.StorekeeperId,
|
||||
FeatureId = model.FeatureID,
|
||||
OrderId = model.OrderId,
|
||||
CarBrand = model.CarBrand,
|
||||
Model = model.Model,
|
||||
CarClass = model.CarClass,
|
||||
Year = model.Year,
|
||||
Price = model.Price,
|
||||
VINnumber = model.VINnumber,
|
||||
FeatureID = model.FeatureID,
|
||||
Bundlings = model.CarBundlings.Select(x => new CarBundling
|
||||
{
|
||||
Bundling = context.Bundlings.First(y => y.Id == x.Key)
|
||||
}).ToList()
|
||||
};
|
||||
}
|
||||
|
||||
public void UpdateBundlings(CarCenterDatabase context, CarBindingModel model)
|
||||
{
|
||||
var car = context.Cars.First(x => x.Id == Id);
|
||||
foreach (var pc in model.CarBundlings)
|
||||
{
|
||||
context.CarBundlings.Add(new CarBundling
|
||||
{
|
||||
Car = car,
|
||||
Bundling = context.Bundlings.First(x => x.Id == pc.Key),
|
||||
});
|
||||
context.SaveChanges();
|
||||
}
|
||||
_carBundlings = null;
|
||||
}
|
||||
|
||||
public void Update(CarBindingModel model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
StorekeeperId = model.StorekeeperId;
|
||||
FeatureId = model.FeatureID;
|
||||
OrderId = model.OrderId;
|
||||
CarBrand = model.CarBrand;
|
||||
Model = model.Model;
|
||||
CarClass = model.CarClass;
|
||||
Year = model.Year;
|
||||
Price = model.Price;
|
||||
VINnumber = model.VINnumber;
|
||||
FeatureID = model.FeatureID;
|
||||
}
|
||||
public CarViewModel GetViewModel => new()
|
||||
{
|
||||
Id = Id,
|
||||
StorekeeperId = StorekeeperId,
|
||||
StorekeeperName = Storekeeper?.Name ?? string.Empty,
|
||||
FeatureId = FeatureId,
|
||||
FeaturePrice = Feature?.Price ?? 0,
|
||||
OrderId = OrderId,
|
||||
BuyerFCS = Order?.BuyerFCS ?? string.Empty,
|
||||
CarBrand = CarBrand,
|
||||
Model = Model,
|
||||
CarClass = CarClass,
|
||||
Year = Year,
|
||||
Price = Price,
|
||||
VINnumber = VINnumber,
|
||||
FeatureID = FeatureID,
|
||||
CarBundlings = CarBundlings,
|
||||
};
|
||||
}
|
||||
}
|
21
CarCenter/CarCenterDatabaseImplement/Models/CarBundling.cs
Normal file
21
CarCenter/CarCenterDatabaseImplement/Models/CarBundling.cs
Normal file
@ -0,0 +1,21 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace CarCenterDatabaseImplement.Models
|
||||
{
|
||||
public class CarBundling
|
||||
{
|
||||
public int Id { get; set; }
|
||||
[Required]
|
||||
public int CarId { get; set; }
|
||||
[Required]
|
||||
public int BundlingId { get; set; }
|
||||
[Required]
|
||||
public virtual Car Car { get; set; } = new();
|
||||
public virtual Bundling Bundling { get; set; } = new();
|
||||
}
|
||||
}
|
76
CarCenter/CarCenterDatabaseImplement/Models/Feature.cs
Normal file
76
CarCenter/CarCenterDatabaseImplement/Models/Feature.cs
Normal file
@ -0,0 +1,76 @@
|
||||
using CarCenterContracts.BindingModels;
|
||||
using CarCenterContracts.ViewModels;
|
||||
using CarCenterDataModels.Enums;
|
||||
using CarCenterDataModels.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace CarCenterDatabaseImplement.Models
|
||||
{
|
||||
public class Feature : IFeatureModel
|
||||
{
|
||||
public int Id { get; private set; }
|
||||
[Required]
|
||||
public HelpDevices HelpDevice { get; set; } = HelpDevices.Неизвестно;
|
||||
[Required]
|
||||
public string CabinColor { get; set; } = string.Empty;
|
||||
[Required]
|
||||
public DriveTypes DriveType { get; set; } = DriveTypes.Неизвестно;
|
||||
[Required]
|
||||
public double Price { get; set; }
|
||||
[ForeignKey("FeatureId")]
|
||||
public virtual List<Car> Cars { get; set; } = new();
|
||||
|
||||
public static Feature? Create(FeatureBindingModel model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return new Feature()
|
||||
{
|
||||
Id = model.Id,
|
||||
HelpDevice = model.HelpDevice,
|
||||
CabinColor = model.CabinColor,
|
||||
DriveType = model.DriveType,
|
||||
Price = model.Price,
|
||||
};
|
||||
}
|
||||
public static Feature Create(FeatureViewModel model)
|
||||
{
|
||||
return new Feature
|
||||
{
|
||||
Id = model.Id,
|
||||
HelpDevice = model.HelpDevice,
|
||||
CabinColor = model.CabinColor,
|
||||
DriveType = model.DriveType,
|
||||
Price = model.Price,
|
||||
};
|
||||
}
|
||||
public void Update(FeatureBindingModel model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
HelpDevice = model.HelpDevice;
|
||||
CabinColor = model.CabinColor;
|
||||
DriveType = model.DriveType;
|
||||
Price = model.Price;
|
||||
}
|
||||
public FeatureViewModel GetViewModel => new()
|
||||
{
|
||||
Id = Id,
|
||||
HelpDevice = HelpDevice,
|
||||
CabinColor = CabinColor,
|
||||
DriveType = DriveType,
|
||||
Price = Price,
|
||||
};
|
||||
}
|
||||
}
|
106
CarCenter/CarCenterDatabaseImplement/Models/Order.cs
Normal file
106
CarCenter/CarCenterDatabaseImplement/Models/Order.cs
Normal file
@ -0,0 +1,106 @@
|
||||
using CarCenterContracts.BindingModels;
|
||||
using CarCenterContracts.ViewModels;
|
||||
using CarCenterDataModels.Enums;
|
||||
using CarCenterDataModels.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace CarCenterDatabaseImplement.Models
|
||||
{
|
||||
public class Order : IOrderModel
|
||||
{
|
||||
public int Id { get; set; }
|
||||
public int WorkerId { get; set; }
|
||||
[Required]
|
||||
public PaymentType PaymentType { get; set; } = PaymentType.Неизвестно;
|
||||
[Required]
|
||||
public PaymentStatus PaymentStatus { get; set; } = PaymentStatus.Неизвестно;
|
||||
[Required]
|
||||
public string BuyerFCS { get; set; } = string.Empty;
|
||||
public DateTime PaymentDate { get; set; }
|
||||
[Required]
|
||||
public double Sum { get; set; }
|
||||
public virtual Worker Worker { get; set; }
|
||||
[ForeignKey("OrderId")]
|
||||
public virtual List<Car> Cars { get; set; } = new();
|
||||
private Dictionary<int, IPresaleModel>? _orderPresales = null;
|
||||
[ForeignKey("OrderId")]
|
||||
public virtual List<OrderPresale> Presales { get; set; } = new();
|
||||
[NotMapped]
|
||||
public Dictionary<int, IPresaleModel> OrderPresales
|
||||
{
|
||||
get
|
||||
{
|
||||
if(_orderPresales == null)
|
||||
{
|
||||
_orderPresales = Presales.ToDictionary(recPc => recPc.PresaleId, recPc => recPc.Presale as IPresaleModel);
|
||||
}
|
||||
return _orderPresales;
|
||||
}
|
||||
}
|
||||
public static Order? Create(CarCenterDatabase context, OrderBindingModel model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return new Order()
|
||||
{
|
||||
Id = model.Id,
|
||||
WorkerId = model.WorkerId,
|
||||
PaymentType = model.PaymentType,
|
||||
PaymentStatus = model.PaymentStatus,
|
||||
BuyerFCS = model.BuyerFCS,
|
||||
PaymentDate = model.PaymentDate,
|
||||
Sum = model.Sum,
|
||||
Presales = model.OrderPresales.Select(x => new OrderPresale
|
||||
{
|
||||
Presale = context.Presales.First(y => y.Id == x.Key)
|
||||
}).ToList()
|
||||
};
|
||||
}
|
||||
|
||||
public void Update(OrderBindingModel? model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
WorkerId = model.WorkerId;
|
||||
PaymentDate = model.PaymentDate;
|
||||
PaymentType = model.PaymentType;
|
||||
Sum = model.Sum;
|
||||
}
|
||||
public void UpdatePresales(CarCenterDatabase context, OrderBindingModel model)
|
||||
{
|
||||
var order = context.Orders.First(x => x.Id == Id);
|
||||
foreach (var pc in model.OrderPresales)
|
||||
{
|
||||
context.OrderPresales.Add(new OrderPresale
|
||||
{
|
||||
Order = order,
|
||||
Presale = context.Presales.First(x => x.Id == pc.Key),
|
||||
});
|
||||
context.SaveChanges();
|
||||
}
|
||||
_orderPresales = null;
|
||||
}
|
||||
public OrderViewModel GetViewModel => new()
|
||||
{
|
||||
Id = Id,
|
||||
WorkerId = WorkerId,
|
||||
WorkerName = Worker?.Name ?? string.Empty,
|
||||
PaymentType = PaymentType,
|
||||
PaymentStatus = PaymentStatus,
|
||||
BuyerFCS = BuyerFCS,
|
||||
PaymentDate = PaymentDate,
|
||||
Sum = Sum,
|
||||
OrderPresales = OrderPresales
|
||||
};
|
||||
}
|
||||
}
|
21
CarCenter/CarCenterDatabaseImplement/Models/OrderPresale.cs
Normal file
21
CarCenter/CarCenterDatabaseImplement/Models/OrderPresale.cs
Normal file
@ -0,0 +1,21 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace CarCenterDatabaseImplement.Models
|
||||
{
|
||||
public class OrderPresale
|
||||
{
|
||||
public int Id { get; set; }
|
||||
[Required]
|
||||
public int OrderId { get; set; }
|
||||
[Required]
|
||||
public int PresaleId { get; set; }
|
||||
[Required]
|
||||
public virtual Order Order { get; set; } = new();
|
||||
public virtual Presale Presale { get; set; } = new();
|
||||
}
|
||||
}
|
102
CarCenter/CarCenterDatabaseImplement/Models/Presale.cs
Normal file
102
CarCenter/CarCenterDatabaseImplement/Models/Presale.cs
Normal file
@ -0,0 +1,102 @@
|
||||
using CarCenterContracts.BindingModels;
|
||||
using CarCenterContracts.ViewModels;
|
||||
using CarCenterDataModels.Enums;
|
||||
using CarCenterDataModels.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace CarCenterDatabaseImplement.Models
|
||||
{
|
||||
public class Presale : IPresaleModel
|
||||
{
|
||||
public int Id { get; set; }
|
||||
[Required]
|
||||
public PresaleStatus PresaleStatus { get; set; } = PresaleStatus.Неизвестно;
|
||||
[Required]
|
||||
public string Description { get; set; } = string.Empty;
|
||||
[Required]
|
||||
public DateTime DueTill { get; set; }
|
||||
[Required]
|
||||
public double Price { get; set; }
|
||||
[ForeignKey("PresaleId")]
|
||||
public virtual List<Request> Requests { get; set; } = new();
|
||||
[ForeignKey("PresaleId")]
|
||||
public virtual List<OrderPresale> OrderPresales { get; set; } = new();
|
||||
|
||||
private Dictionary<int, IBundlingModel>? _presaleBundlings = null;
|
||||
[ForeignKey("PresaleId")]
|
||||
public virtual List<PresaleBundling> Bundlings { get; set; } = new();
|
||||
public Dictionary<int, IBundlingModel> PresaleBundlings
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_presaleBundlings == null)
|
||||
{
|
||||
_presaleBundlings = Bundlings.ToDictionary(recPc => recPc.BundlingId, recPc => recPc.Bundling as IBundlingModel);
|
||||
}
|
||||
return _presaleBundlings;
|
||||
}
|
||||
}
|
||||
public static Presale? Create(CarCenterDatabase context, PresaleBindingModel model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return new Presale()
|
||||
{
|
||||
Id = model.Id,
|
||||
PresaleStatus = model.PresaleStatus,
|
||||
Description = model.Description,
|
||||
Price = model.Price,
|
||||
DueTill = model.DueTill,
|
||||
Bundlings = model.PresaleBundlings.Select(x => new PresaleBundling
|
||||
{
|
||||
Bundling = context.Bundlings.First(y => y.Id == x.Key)
|
||||
}).ToList()
|
||||
};
|
||||
}
|
||||
|
||||
public void UpdateBundlings(CarCenterDatabase context, PresaleBindingModel model)
|
||||
{
|
||||
var presale = context.Presales.First(x => x.Id == Id);
|
||||
foreach (var pc in model.PresaleBundlings)
|
||||
{
|
||||
context.PresaleBundlings.Add(new PresaleBundling
|
||||
{
|
||||
Presale = presale,
|
||||
Bundling = context.Bundlings.First(x => x.Id == pc.Key),
|
||||
});
|
||||
context.SaveChanges();
|
||||
}
|
||||
_presaleBundlings = null;
|
||||
}
|
||||
|
||||
public void Update(PresaleBindingModel? model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
Description = model.Description;
|
||||
Price = model.Price;
|
||||
DueTill = model.DueTill;
|
||||
PresaleStatus = model.PresaleStatus;
|
||||
}
|
||||
|
||||
public PresaleViewModel GetViewModel => new()
|
||||
{
|
||||
Id = Id,
|
||||
PresaleStatus = PresaleStatus,
|
||||
Description = Description,
|
||||
DueTill = DueTill,
|
||||
Price = Price,
|
||||
PresaleBundlings = PresaleBundlings,
|
||||
};
|
||||
}
|
||||
}
|
@ -0,0 +1,22 @@
|
||||
using CarCenterContracts.SearchModels;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace CarCenterDatabaseImplement.Models
|
||||
{
|
||||
public class PresaleBundling
|
||||
{
|
||||
public int Id { get; set; }
|
||||
[Required]
|
||||
public int PresaleId { get; set; }
|
||||
[Required]
|
||||
public int BundlingId { get; set; }
|
||||
[Required]
|
||||
public virtual Presale Presale { get; set; } = new();
|
||||
public virtual Bundling Bundling { get; set; } = new();
|
||||
}
|
||||
}
|
59
CarCenter/CarCenterDatabaseImplement/Models/Request.cs
Normal file
59
CarCenter/CarCenterDatabaseImplement/Models/Request.cs
Normal file
@ -0,0 +1,59 @@
|
||||
using CarCenterContracts.BindingModels;
|
||||
using CarCenterContracts.ViewModels;
|
||||
using CarCenterDataModels.Enums;
|
||||
using CarCenterDataModels.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace CarCenterDatabaseImplement.Models
|
||||
{
|
||||
public class Request : IRequestModel
|
||||
{
|
||||
public int Id { get; set; }
|
||||
public int PresaleId { get; set; }
|
||||
[Required]
|
||||
public string Description { get; set; } = string.Empty;
|
||||
[Required]
|
||||
public RequestTypes RequestType { get; set; } = RequestTypes.Неизвестно;
|
||||
public virtual Presale Presale { get; set; }
|
||||
|
||||
public static Request? Create(RequestBindingModel? model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return new Request()
|
||||
{
|
||||
Id = model.Id,
|
||||
PresaleId = model.PresaleId,
|
||||
Description = model.Description,
|
||||
RequestType = model.RequestType,
|
||||
};
|
||||
}
|
||||
|
||||
public void Update(RequestBindingModel? model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
Description = model.Description;
|
||||
RequestType = model.RequestType;
|
||||
PresaleId = model.PresaleId;
|
||||
}
|
||||
|
||||
public RequestViewModel GetViewModel => new()
|
||||
{
|
||||
Id = Id,
|
||||
Description = Description,
|
||||
RequestType = RequestType,
|
||||
PresaleId = PresaleId,
|
||||
PresaleDescription = Presale?.Description ?? string.Empty,
|
||||
};
|
||||
}
|
||||
}
|
71
CarCenter/CarCenterDatabaseImplement/Models/Storekeeper.cs
Normal file
71
CarCenter/CarCenterDatabaseImplement/Models/Storekeeper.cs
Normal file
@ -0,0 +1,71 @@
|
||||
using CarCenterContracts.BindingModels;
|
||||
using CarCenterContracts.ViewModels;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using CarCenterDataModels.Models;
|
||||
|
||||
namespace CarCenterDatabaseImplement.Models
|
||||
{
|
||||
public class Storekeeper : IStorekeeperModel
|
||||
{
|
||||
public int Id { get; set; }
|
||||
[Required]
|
||||
public string Name { get; set; } = string.Empty;
|
||||
[Required]
|
||||
public string Surname { get; set; } = string.Empty;
|
||||
public string? Patronymic { get; set; }
|
||||
[Required]
|
||||
public string Password { get; set; } = string.Empty;
|
||||
[Required]
|
||||
public string Email { get; set; } = string.Empty;
|
||||
[Required]
|
||||
public long PhoneNumber { get; set; }
|
||||
[ForeignKey("StorekeeperId")]
|
||||
public virtual List<Car> Cars { get; set; } = new();
|
||||
|
||||
public static Storekeeper? Create(StorekeeperBindingModel? model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return new Storekeeper()
|
||||
{
|
||||
Id = model.Id,
|
||||
Name = model.Name,
|
||||
Surname = model.Surname,
|
||||
Patronymic = model.Patronymic,
|
||||
Password = model.Password,
|
||||
Email = model.Email,
|
||||
PhoneNumber = model.PhoneNumber,
|
||||
};
|
||||
}
|
||||
|
||||
public void Update(StorekeeperBindingModel? model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
Password = model.Password;
|
||||
Email = model.Email;
|
||||
PhoneNumber = model.PhoneNumber;
|
||||
}
|
||||
|
||||
public StorekeeperViewModel GetViewModel => new()
|
||||
{
|
||||
Id = Id,
|
||||
Name = Name,
|
||||
Surname = Surname,
|
||||
Patronymic = Patronymic,
|
||||
Password = Password,
|
||||
Email = Email,
|
||||
PhoneNumber = PhoneNumber,
|
||||
};
|
||||
}
|
||||
}
|
72
CarCenter/CarCenterDatabaseImplement/Models/Worker.cs
Normal file
72
CarCenter/CarCenterDatabaseImplement/Models/Worker.cs
Normal file
@ -0,0 +1,72 @@
|
||||
using CarCenterContracts.BindingModels;
|
||||
using CarCenterContracts.ViewModels;
|
||||
using CarCenterDataModels.Enums;
|
||||
using CarCenterDataModels.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace CarCenterDatabaseImplement.Models
|
||||
{
|
||||
public class Worker : IWorkerModel
|
||||
{
|
||||
public int Id { get; set; }
|
||||
[Required]
|
||||
public string Name { get; set; } = string.Empty;
|
||||
[Required]
|
||||
public string Surname { get; set; } = string.Empty;
|
||||
public string? Patronymic { get; set; }
|
||||
[Required]
|
||||
public string Password { get; set; } = string.Empty;
|
||||
[Required]
|
||||
public string Email { get; set; } = string.Empty;
|
||||
[Required]
|
||||
public long PhoneNumber { get; set; }
|
||||
[ForeignKey("WorkerId")]
|
||||
public virtual List<Order> Orders { get; set; } = new();
|
||||
|
||||
public static Worker? Create(WorkerBindingModel? model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return new Worker()
|
||||
{
|
||||
Id = model.Id,
|
||||
Name = model.Name,
|
||||
Surname = model.Surname,
|
||||
Patronymic = model.Patronymic,
|
||||
Password = model.Password,
|
||||
Email = model.Email,
|
||||
PhoneNumber = model.PhoneNumber,
|
||||
};
|
||||
}
|
||||
|
||||
public void Update(WorkerBindingModel? model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
Password = model.Password;
|
||||
Email = model.Email;
|
||||
PhoneNumber = model.PhoneNumber;
|
||||
}
|
||||
|
||||
public WorkerViewModel GetViewModel => new()
|
||||
{
|
||||
Id = Id,
|
||||
Name = Name,
|
||||
Surname = Surname,
|
||||
Patronymic = Patronymic,
|
||||
Password = Password,
|
||||
Email = Email,
|
||||
PhoneNumber = PhoneNumber,
|
||||
};
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user