Compare commits

..

2 Commits

6 changed files with 316 additions and 0 deletions

View File

@ -11,6 +11,7 @@ namespace CarCenterContracts.BindingModels
public class CarBindingModel : ICarModel
{
public int Id { get; set; }
public int StorekeeperId { get; set; }
public CarBrand CarBrand { get; set; } = CarBrand.Неизвестно;
public string Model { get; set; } = string.Empty;
public CarClass CarClass { get; set; } = CarClass.Неизвестно;

View File

@ -12,6 +12,12 @@ namespace CarCenterContracts.ViewModels
public class CarViewModel : ICarModel
{
public int Id { 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("Модель")]

View 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;
using System.ComponentModel.DataAnnotations;
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; }
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,
};
}
}

View File

@ -0,0 +1,90 @@
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.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? 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 Dictionary<int, IBundlingModel> CarBundlings { get; set; } = new();
public virtual Storekeeper Storekeeper { get; set; }
public virtual Feature Feature { get; set; }
public static Car? Create(CarBindingModel model)
{
if (model == null)
{
return null;
}
return new Car()
{
Id = model.Id,
StorekeeperId = model.StorekeeperId,
FeatureId = model.FeatureID,
CarBrand = model.CarBrand,
Model = model.Model,
CarClass = model.CarClass,
Year = model.Year,
Price = model.Price,
VINnumber = model.VINnumber,
FeatureID = model.FeatureID,
};
}
public void Update(CarBindingModel model)
{
if (model == null)
{
return;
}
StorekeeperId = model.StorekeeperId;
FeatureId = model.FeatureID;
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,
CarBrand = CarBrand,
Model = Model,
CarClass = CarClass,
Year = Year,
Price = Price,
VINnumber = VINnumber,
FeatureID = FeatureID,
};
}
}

View 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,
};
}
}

View 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,
};
}
}