53 lines
1.2 KiB
C#
53 lines
1.2 KiB
C#
using UniversityContracts.BindingModels;
|
|
using UniversityContracts.ViewModels;
|
|
using UniversityDataModels;
|
|
using System.ComponentModel.DataAnnotations;
|
|
using System.Diagnostics;
|
|
using BankContracts.ViewModels;
|
|
|
|
namespace UniversityDatabaseImplement.Models
|
|
{
|
|
public class Payment : IPaymentModel
|
|
{
|
|
[Required]
|
|
public int ClassByPurchaseId { get; private set; }
|
|
|
|
[Required]
|
|
public DateOnly Date { get; private set; }
|
|
|
|
[Required]
|
|
public double PaidPrice { get; private set; }
|
|
|
|
public int Id { get; private set; }
|
|
|
|
[Required]
|
|
public ClassByPurchase? ClassByPurchase { get; private set; }
|
|
|
|
public static Payment Create(PaymentBindingModel model)
|
|
{
|
|
if (model == null)
|
|
{
|
|
return null;
|
|
}
|
|
return new Payment()
|
|
{
|
|
|
|
Date = model.Date,
|
|
PaidPrice = model.PaidPrice,
|
|
Id = model.Id,
|
|
ClassByPurchaseId = model.ClassByPurchaseId,
|
|
};
|
|
}
|
|
public PaymentViewModel GetViewModel => new()
|
|
{
|
|
Operation = ClassByPurchase?.Class?.GetViewModel,
|
|
ClassByPurchase = ClassByPurchase,
|
|
FullPrice = ClassByPurchase?.Class?.Price ?? -1,
|
|
Date = Date,
|
|
PaidPrice = PaidPrice,
|
|
Id = Id,
|
|
ClassByPurchaseId = ClassByPurchaseId,
|
|
};
|
|
}
|
|
}
|