CourseWorkElectronicsShop/ElectronicsShop/ElectronicsShopDataBaseImplement/Models/Paymeant.cs
Илья Федотов e07a12bf92 set paymeant
2024-05-26 18:12:25 +04:00

70 lines
1.9 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

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("ProductID")]
public int ProductID { get; set; }
[ForeignKey("OrderID")]
public int OrderID { get; set; }
[Required]
public double SumPayment { get; set; }
[Required]
public PaymeantOption PayOption { get; set; } = PaymeantOption.Неоплачено;
public static Paymeant? Create(PaymeantBindingModel? model)
{
if (model == null)
{
return null;
}
return new Paymeant()
{
ID = model.ID,
ProductID = model.ProductID,
OrderID = model.OrderID,
SumPayment = model.SumPayment,
PayOption = model.PayOption,
};
}
public void Update(PaymeantBindingModel? model)
{
if (model == null)
{
return;
}
ProductID = model.ProductID;
OrderID = model.OrderID;
SumPayment = model.SumPayment;
PayOption = model.PayOption;
}
public PaymeantViewModel GetViewModel => new()
{
ID = ID,
ProductID = ProductID,
OrderID = OrderID,
SumPayment = SumPayment,
PayOption = PayOption,
};
}
}