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

76 lines
2.4 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.Cashier;
using BankContracts.StoragesModels;
using BankContracts.ViewModels.Cashier.ViewModels;
using BankDatabaseImplement.Models.ClientModels;
using BankDataModels.Models.Cashier;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace BankDatabaseImplement.Models.CashierModels
{
// Класс, реализующий интерфейс модели снятие наличных
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,
AccountId = model.AccountId,
Account = context.Accounts.First(x => x.Id == model.AccountId),
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,
AccountId = AccountId,
CashierId = CashierId,
DebitingId = DebitingId,
Sum = Sum,
DateWithdrawal = DateWithdrawal
};
}
}