2024-05-25 15:04:18 +04:00
|
|
|
|
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
|
|
|
|
|
{
|
2024-05-26 18:12:25 +04:00
|
|
|
|
public class Paymeant : IPaymentModel
|
2024-05-25 15:04:18 +04:00
|
|
|
|
{
|
|
|
|
|
public int ID { get; set; }
|
2024-05-25 22:32:22 +04:00
|
|
|
|
|
2024-05-25 15:04:18 +04:00
|
|
|
|
[ForeignKey("OrderID")]
|
|
|
|
|
public int OrderID { get; set; }
|
2024-05-25 22:32:22 +04:00
|
|
|
|
|
2024-06-01 06:31:02 +04:00
|
|
|
|
[ForeignKey("ClientID")]
|
2024-06-01 05:23:37 +04:00
|
|
|
|
public int ClientID { get; set; }
|
|
|
|
|
|
|
|
|
|
[Required]
|
2024-05-25 15:04:18 +04:00
|
|
|
|
public double SumPayment { get; set; }
|
2024-05-25 22:32:22 +04:00
|
|
|
|
|
2024-05-25 15:04:18 +04:00
|
|
|
|
[Required]
|
2024-05-25 17:47:14 +04:00
|
|
|
|
public PaymeantOption PayOption { get; set; } = PaymeantOption.Неоплачено;
|
2024-05-25 22:32:22 +04:00
|
|
|
|
|
2024-05-26 18:12:25 +04:00
|
|
|
|
public static Paymeant? Create(PaymeantBindingModel? model)
|
2024-05-25 15:04:18 +04:00
|
|
|
|
{
|
|
|
|
|
if (model == null)
|
|
|
|
|
{
|
|
|
|
|
return null;
|
|
|
|
|
}
|
2024-05-26 18:12:25 +04:00
|
|
|
|
return new Paymeant()
|
2024-05-25 15:04:18 +04:00
|
|
|
|
{
|
|
|
|
|
ID = model.ID,
|
|
|
|
|
OrderID = model.OrderID,
|
|
|
|
|
SumPayment = model.SumPayment,
|
|
|
|
|
PayOption = model.PayOption,
|
2024-06-01 05:23:37 +04:00
|
|
|
|
ClientID = model.ClientID,
|
2024-05-25 15:04:18 +04:00
|
|
|
|
};
|
|
|
|
|
}
|
2024-05-26 18:12:25 +04:00
|
|
|
|
public void Update(PaymeantBindingModel? model)
|
2024-05-25 15:04:18 +04:00
|
|
|
|
{
|
|
|
|
|
if (model == null)
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
OrderID = model.OrderID;
|
|
|
|
|
SumPayment = model.SumPayment;
|
|
|
|
|
PayOption = model.PayOption;
|
|
|
|
|
}
|
|
|
|
|
|
2024-05-26 18:12:25 +04:00
|
|
|
|
public PaymeantViewModel GetViewModel => new()
|
2024-05-25 15:04:18 +04:00
|
|
|
|
{
|
|
|
|
|
ID = ID,
|
|
|
|
|
OrderID = OrderID,
|
|
|
|
|
SumPayment = SumPayment,
|
|
|
|
|
PayOption = PayOption,
|
2024-06-01 05:23:37 +04:00
|
|
|
|
ClientID = ClientID,
|
2024-05-25 15:04:18 +04:00
|
|
|
|
};
|
2024-06-01 05:23:37 +04:00
|
|
|
|
}
|
2024-05-25 15:04:18 +04:00
|
|
|
|
}
|