71 lines
2.3 KiB
C#
Raw Normal View History

using BankContracts.BindingModels;
using BankContracts.StoragesModels;
using BankContracts.ViewModels.Cashier.ViewModels;
using BankDataModels.Models;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace BankDatabaseImplement.Models
{
public class CashWithdrawal : ICashWithdrawalModel
{
public int Id { get; set; }
[Required]
public int DebitingId { get; set; }
//для передачи номера заявки
public virtual Debiting Debiting { get; set; }
//я думаю нам стоит в пехе встретиться и обсудить наши модели, потому что реально странно, что наши операции не связаны с картами/счетами
//[Required]
//public int AccountId { get; set; }
//для передачи названия изделия
//public virtual Account Account { get; set; }
[Required]
public int CashierId { get; set; }
//для передачи данных о кассире
public virtual Cashier Cashier { get; set; }
[Required]
public double Sum { get; set; }
[Required]
public DateTime DateWithdrawal { get; set; }
public static CashWithdrawal Create(BankDatabase context, CashWithdrawalBindingModel model)
{
return new CashWithdrawal()
{
Id = model.Id,
DebitingId = model.DebitingId,
Debiting = context.Debitings.First(x => x.Id == model.DebitingId),
CashierId = model.CashierId,
Cashier = context.Cashiers.First(x => x.Id == model.CashierId),
Sum = model.Sum,
DateWithdrawal = model.DateWithdrawal
};
}
public void Update(CashWithdrawalBindingModel model)
{
DateWithdrawal = model.DateWithdrawal;
}
public CashWithdrawalViewModel GetViewModel => new()
{
Id = Id,
CashierId = CashierId,
DebitingId = DebitingId,
Sum = Sum,
DateWithdrawal = DateWithdrawal
};
}
}