2023-04-06 22:52:23 +04:00
|
|
|
|
using SchoolContracts.BindingModel;
|
|
|
|
|
using SchoolContracts.ViewModels;
|
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.ComponentModel.DataAnnotations;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
|
|
|
|
|
namespace SchoolDatabaseImplement.Models
|
|
|
|
|
{
|
|
|
|
|
public class Payment
|
|
|
|
|
{
|
|
|
|
|
public int Id { get; private set; }
|
|
|
|
|
[Required]
|
2023-04-07 23:28:12 +04:00
|
|
|
|
public int CircleLessonId { get; private set; }
|
|
|
|
|
[Required]
|
|
|
|
|
public double PaySum { get; private set; }
|
2023-04-06 22:52:23 +04:00
|
|
|
|
[Required]
|
|
|
|
|
public DateTime? DateOfPayment { get; private set; } = DateTime.Now;
|
2023-04-07 23:28:12 +04:00
|
|
|
|
public virtual CircleLesson CircleLesson { get; private set; } = new();
|
2023-04-06 22:52:23 +04:00
|
|
|
|
public static Payment? Create(SchoolDatabase context, PaymentBindingModel? model)
|
|
|
|
|
{
|
|
|
|
|
if (model == null)
|
|
|
|
|
{
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return new Payment()
|
|
|
|
|
{
|
|
|
|
|
Id = model.Id,
|
2023-04-07 23:28:12 +04:00
|
|
|
|
CircleLesson = context.CircleLessons.First(x => x.Id == model.CircleLessonId),
|
|
|
|
|
PaySum = model.PaySum,
|
2023-04-06 22:52:23 +04:00
|
|
|
|
DateOfPayment = model.DateOfPayment
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
public void Update(PaymentBindingModel? model)
|
|
|
|
|
{
|
|
|
|
|
if (model == null)
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
Id = model.Id;
|
2023-04-07 23:28:12 +04:00
|
|
|
|
CircleLessonId = model.CircleLessonId;
|
|
|
|
|
PaySum = model.PaySum;
|
2023-04-06 22:52:23 +04:00
|
|
|
|
DateOfPayment = model.DateOfPayment;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public PaymentViewModel GetViewModel
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
|
|
|
|
var context = new SchoolDatabase();
|
|
|
|
|
return new()
|
|
|
|
|
{
|
|
|
|
|
Id = Id,
|
2023-04-07 23:28:12 +04:00
|
|
|
|
CircleLessonId = CircleLessonId,
|
|
|
|
|
PaySum = PaySum,
|
2023-04-06 22:52:23 +04:00
|
|
|
|
DateOfPayment = DateOfPayment
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|