55 lines
1.6 KiB
C#
55 lines
1.6 KiB
C#
|
using BankDataModels.Models;
|
|||
|
using System.ComponentModel.DataAnnotations.Schema;
|
|||
|
using System.ComponentModel.DataAnnotations;
|
|||
|
using BankContracts.BindingModels;
|
|||
|
using BankContracts.ViewModels;
|
|||
|
|
|||
|
namespace BankDatabaseImplement.Models
|
|||
|
{
|
|||
|
public class Refill : IRefillModel
|
|||
|
{
|
|||
|
public int Id { get; set; }
|
|||
|
[Required]
|
|||
|
public int DepositId { get; set; }
|
|||
|
public virtual Deposit? Deposit { get; set; }
|
|||
|
[Required]
|
|||
|
public int WorkerId { get; set; }
|
|||
|
public virtual Worker? Worker { get; set; }
|
|||
|
[Required]
|
|||
|
public double Sum { get; set; }
|
|||
|
[Required]
|
|||
|
public DateOnly RefillDate { get; set; }
|
|||
|
public static Refill? Create(RefillBindingModel model)
|
|||
|
{
|
|||
|
if (model == null)
|
|||
|
return null;
|
|||
|
return new Refill
|
|||
|
{
|
|||
|
Id = model.Id,
|
|||
|
DepositId = model.DepositId,
|
|||
|
WorkerId = model.WorkerId,
|
|||
|
Sum = model.Sum,
|
|||
|
RefillDate = model.RefillDate,
|
|||
|
};
|
|||
|
}
|
|||
|
public void Update(RefillBindingModel model)
|
|||
|
{
|
|||
|
if (model == null)
|
|||
|
return;
|
|||
|
Id = model.Id;
|
|||
|
DepositId = model.DepositId;
|
|||
|
WorkerId = model.WorkerId;
|
|||
|
Sum = model.Sum;
|
|||
|
RefillDate = model.RefillDate;
|
|||
|
}
|
|||
|
public RefillViewModel GetViewModel => new()
|
|||
|
{
|
|||
|
Id = Id,
|
|||
|
DepositId = DepositId,
|
|||
|
WorkerId = WorkerId,
|
|||
|
Sum = Sum,
|
|||
|
RefillDate = RefillDate,
|
|||
|
};
|
|||
|
}
|
|||
|
}
|