70 lines
1.9 KiB
C#
70 lines
1.9 KiB
C#
using ElectronicsShopContracts.BindingModels;
|
||
using ElectronicsShopContracts.ViewModels;
|
||
using ElectronicsShopDataModels.Enums;
|
||
using ElectronicsShopDataModels.Models;
|
||
using System;
|
||
using System.Collections.Generic;
|
||
using System.ComponentModel.DataAnnotations;
|
||
using System.ComponentModel.DataAnnotations.Schema;
|
||
using System.Diagnostics;
|
||
using System.Linq;
|
||
using System.Text;
|
||
using System.Threading.Tasks;
|
||
|
||
namespace ElectronicsShopDataBaseImplement.Models
|
||
{
|
||
public class Paymeant : IPaymentModel
|
||
{
|
||
public int ID { get; set; }
|
||
|
||
[ForeignKey("OrderID")]
|
||
public int OrderID { get; set; }
|
||
|
||
[ForeignKey("ClientID")]
|
||
public int ClientID { get; set; }
|
||
|
||
[Required]
|
||
public double SumPayment { get; set; }
|
||
|
||
[Required]
|
||
public PaymeantOption PayOption { get; set; } = PaymeantOption.Неоплачено;
|
||
|
||
public DateTime DatePaymeant { get; set; }
|
||
|
||
public static Paymeant? Create(PaymeantBindingModel? model)
|
||
{
|
||
if (model == null)
|
||
{
|
||
return null;
|
||
}
|
||
return new Paymeant()
|
||
{
|
||
ID = model.ID,
|
||
OrderID = model.OrderID,
|
||
SumPayment = model.SumPayment,
|
||
PayOption = model.PayOption,
|
||
ClientID = model.ClientID,
|
||
DatePaymeant = model.DatePaymeant,
|
||
};
|
||
}
|
||
public void Update(PaymeantBindingModel? model)
|
||
{
|
||
if (model == null)
|
||
{
|
||
return;
|
||
}
|
||
SumPayment = model.SumPayment;
|
||
PayOption = model.PayOption;
|
||
}
|
||
|
||
public PaymeantViewModel GetViewModel => new() {
|
||
ID = ID,
|
||
OrderID = OrderID,
|
||
SumPayment = SumPayment,
|
||
PayOption = PayOption,
|
||
ClientID = ClientID,
|
||
DatePaymeant = DatePaymeant,
|
||
};
|
||
}
|
||
}
|