2023-04-01 16:30:10 +04:00
|
|
|
|
using BankYouBankruptContracts.BindingModels;
|
2023-05-18 17:56:47 +04:00
|
|
|
|
using BankYouBankruptContracts.ViewModels.Client.Default;
|
2023-05-14 15:14:30 +04:00
|
|
|
|
using BankYouBankruptDataModels.Enums;
|
2023-04-01 16:30:10 +04:00
|
|
|
|
using BankYouBankruptDataModels.Models;
|
2023-04-01 15:33:39 +04:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
2023-04-01 16:30:10 +04:00
|
|
|
|
using System.ComponentModel.DataAnnotations;
|
2023-04-01 15:33:39 +04:00
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
|
|
|
|
|
namespace BankYouBankruptDatabaseImplement.Models
|
|
|
|
|
{
|
|
|
|
|
public class Debiting : IDebitingModel
|
|
|
|
|
{
|
2023-04-01 16:30:10 +04:00
|
|
|
|
public int Id { get; set; }
|
2023-04-01 15:33:39 +04:00
|
|
|
|
|
2023-04-01 16:30:10 +04:00
|
|
|
|
[Required]
|
|
|
|
|
public int CardId { get; set; }
|
2023-05-14 15:14:30 +04:00
|
|
|
|
|
2023-05-14 18:27:41 +04:00
|
|
|
|
public virtual Card Card { get; set; }
|
2023-04-01 15:33:39 +04:00
|
|
|
|
|
2023-04-01 16:30:10 +04:00
|
|
|
|
[Required]
|
|
|
|
|
public int Sum { get; set; }
|
2023-04-01 15:33:39 +04:00
|
|
|
|
|
2023-04-01 16:30:10 +04:00
|
|
|
|
[Required]
|
2023-05-14 15:14:30 +04:00
|
|
|
|
public DateTime DateOpen { get; set; } = DateTime.Now;
|
|
|
|
|
|
2023-05-14 16:34:14 +04:00
|
|
|
|
public DateTime? DateClose { get; set; }
|
2023-04-01 16:30:10 +04:00
|
|
|
|
|
2023-05-14 15:14:30 +04:00
|
|
|
|
[Required]
|
2023-05-14 19:31:53 +04:00
|
|
|
|
public StatusEnum Status { get; set; }
|
2023-04-01 16:30:10 +04:00
|
|
|
|
|
2023-05-14 15:14:30 +04:00
|
|
|
|
public DebitingViewModel GetViewModel => new()
|
2023-04-01 16:30:10 +04:00
|
|
|
|
{
|
|
|
|
|
Id = Id,
|
|
|
|
|
CardId = CardId,
|
2023-05-14 19:31:53 +04:00
|
|
|
|
CardNumber = Card.Number,
|
2023-04-01 16:30:10 +04:00
|
|
|
|
Sum = Sum,
|
2023-05-14 15:14:30 +04:00
|
|
|
|
DateOpen = DateOpen,
|
|
|
|
|
DateClose = DateClose,
|
|
|
|
|
Status = Status
|
2023-04-01 16:30:10 +04:00
|
|
|
|
};
|
|
|
|
|
|
2023-04-01 16:49:22 +04:00
|
|
|
|
public static Debiting Create(BankYouBancruptDatabase context, DebitingBindingModel model)
|
2023-04-01 16:30:10 +04:00
|
|
|
|
{
|
|
|
|
|
return new Debiting()
|
|
|
|
|
{
|
|
|
|
|
Id = model.Id,
|
|
|
|
|
CardId = model.CardId,
|
2023-05-14 19:07:43 +04:00
|
|
|
|
Card = context.Cards.First(x => x.Id == model.CardId),
|
2023-04-01 16:30:10 +04:00
|
|
|
|
Sum = model.Sum,
|
2023-05-14 15:14:30 +04:00
|
|
|
|
DateOpen = model.DateOpen,
|
2023-05-14 18:27:41 +04:00
|
|
|
|
Status = StatusEnum.Открыта
|
2023-05-14 15:14:30 +04:00
|
|
|
|
};
|
2023-04-01 16:30:10 +04:00
|
|
|
|
}
|
2023-04-01 19:28:58 +04:00
|
|
|
|
|
|
|
|
|
public void Update(DebitingBindingModel model)
|
|
|
|
|
{
|
2023-05-14 15:14:30 +04:00
|
|
|
|
DateClose = model.DateClose;
|
2023-05-14 16:34:14 +04:00
|
|
|
|
|
|
|
|
|
Status = model.Status;
|
2023-04-01 19:28:58 +04:00
|
|
|
|
}
|
2023-04-01 15:33:39 +04:00
|
|
|
|
}
|
|
|
|
|
}
|