чиппи чиппи чаппа чаппа
This commit is contained in:
parent
0989b27c5f
commit
1bde67b265
40
CarCenterDatabaseImplement/Models/Account.cs
Normal file
40
CarCenterDatabaseImplement/Models/Account.cs
Normal file
@ -0,0 +1,40 @@
|
||||
using CarCenterContracts.BindingModels;
|
||||
using CarCenterContracts.Extensions;
|
||||
using CarCenterContracts.ViewModels;
|
||||
using CarCenterDataModels;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
|
||||
namespace CarCenterDatabaseImplement.Models
|
||||
{
|
||||
public class Account : IAccountModel
|
||||
{
|
||||
[Required]
|
||||
public int ClientByCarId { get; private set; }
|
||||
|
||||
[Required]
|
||||
public DateOnly DateOfAccount { get; private set; }
|
||||
|
||||
[Required]
|
||||
public double Price { get; private set; }
|
||||
|
||||
public int Id { get; private set; }
|
||||
|
||||
[Required]
|
||||
public ClientByCar? ClientByCar { get; private set; }
|
||||
|
||||
public static Account Create(AccountBindingModel model) => model.CastWithCommonProperties<Account, AccountBindingModel>();
|
||||
|
||||
public static implicit operator AccountViewModel(Account? model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
throw new ArgumentNullException("Возникла ошибка при попытки получить View-модель из null-объекта", nameof(model));
|
||||
}
|
||||
var res = model.CastWithCommonProperties<AccountViewModel, Account>();
|
||||
res.ClientByCar = model.ClientByCar;
|
||||
res.Client = model.ClientByCar?.Client;
|
||||
res.Car = model.ClientByCar?.Car;
|
||||
return res;
|
||||
}
|
||||
}
|
||||
}
|
16
CarCenterDatabaseImplement/Models/ClientByCar.cs
Normal file
16
CarCenterDatabaseImplement/Models/ClientByCar.cs
Normal file
@ -0,0 +1,16 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using CarCenterDataModels.ProxyModels;
|
||||
|
||||
namespace CarCenterDatabaseImplement.Models
|
||||
{
|
||||
public class ClientByCar : ClientByCarModel
|
||||
{
|
||||
[Required]
|
||||
public Client? Client { get; private set; }
|
||||
[Required]
|
||||
public Car? Car { get; private set; }
|
||||
|
||||
[Required]
|
||||
public List<Account>? Accounts { get; private set; }
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user