2024-05-01 01:54:31 +04:00

57 lines
1.7 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 BankContracts.BindingModels.Client;
using BankContracts.ViewModels.Client.ViewModels;
using BankDataModels.Models.Client;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace BankDatabaseImplement.Models.ClientModels
{
// Класс, реализующий интерфейс модели снятие с карты
public class Debiting : IDebitingModel
{
public int Id { get; set; }
[Required]
public int CardId { get; set; }
public virtual Card Card { get; set; }
[Required]
public double Sum { get; set; }
[Required]
public DateTime DateDebit { get; set; } = DateTime.Now;
public DebitingViewModel GetViewModel => new()
{
Id = Id,
CardId = CardId,
CardNumber = Card.Number,
Sum = Sum,
DateDebit = DateDebit,
};
public static Debiting Create(BankDatabase context, DebitingBindingModel model)
{
return new Debiting()
{
Id = model.Id,
CardId = model.CardId,
Card = context.Cards.First(x => x.Id == model.CardId),
Sum = model.Sum,
DateDebit = model.DateDebit,
};
}
// вот тут надо ли обновлять эту операцию..., если судить чисто логически, то не надо ОБДУМАТЬ!!!!!!!! По идее лишним не будет, а может и будет
public void Update(DebitingBindingModel model)
{
DateDebit = model.DateDebit;
}
}
}