2024-06-20 22:32:22 +04:00
|
|
|
|
using Contracts.BindingModels;
|
2024-06-23 20:39:28 +04:00
|
|
|
|
using Contracts.Converters;
|
2024-06-20 22:32:22 +04:00
|
|
|
|
using Contracts.ViewModels;
|
|
|
|
|
using DataModels.Models;
|
|
|
|
|
using System;
|
2024-06-11 12:18:10 +04:00
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
|
|
|
|
|
namespace DatabaseImplement.Models
|
|
|
|
|
{
|
2024-06-20 22:32:22 +04:00
|
|
|
|
public class Sell : ISell
|
2024-06-11 12:18:10 +04:00
|
|
|
|
{
|
2024-06-20 22:32:22 +04:00
|
|
|
|
public Guid Id { get; set; }
|
|
|
|
|
public DateTime DateSell { get; set; }
|
2024-06-23 20:39:28 +04:00
|
|
|
|
public Guid? SupplyDocId { get; set; }
|
|
|
|
|
|
|
|
|
|
public virtual SupplyDoc? SupplyDoc { get; set; }
|
|
|
|
|
public static Sell Create(Database context, SellBindingModel model)
|
|
|
|
|
{
|
|
|
|
|
return new Sell()
|
|
|
|
|
{
|
|
|
|
|
Id = model.Id,
|
|
|
|
|
DateSell = model.DateSell,
|
|
|
|
|
SupplyDocId = model.SupplyDocId,
|
|
|
|
|
};
|
|
|
|
|
}
|
2024-06-20 22:32:22 +04:00
|
|
|
|
|
2024-06-24 01:07:53 +04:00
|
|
|
|
public SellBindingModel GetBindingModel => new()
|
2024-06-20 22:32:22 +04:00
|
|
|
|
{
|
|
|
|
|
Id = Id,
|
2024-06-23 20:39:28 +04:00
|
|
|
|
DateSell = DateSell,
|
|
|
|
|
SupplyDocId = SupplyDocId,
|
2024-06-20 22:32:22 +04:00
|
|
|
|
};
|
2024-06-24 01:07:53 +04:00
|
|
|
|
public SellViewModel GetViewModel => new()
|
2024-06-23 20:39:28 +04:00
|
|
|
|
{
|
|
|
|
|
Id = Id,
|
|
|
|
|
DateSell = DateSell,
|
|
|
|
|
SupplyDocId = SupplyDocId,
|
|
|
|
|
|
|
|
|
|
};
|
|
|
|
|
public static Sell ToSellFromView(SellViewModel model, Sell sell) => new()
|
2024-06-20 22:32:22 +04:00
|
|
|
|
{
|
|
|
|
|
Id = model.Id,
|
|
|
|
|
DateSell = model.DateSell
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
public static Sell ToSellFromBinding(SellBindingModel model, Sell sell) => new()
|
|
|
|
|
{
|
|
|
|
|
Id = model.Id,
|
|
|
|
|
DateSell = model.DateSell,
|
|
|
|
|
};
|
|
|
|
|
|
2024-06-23 20:39:28 +04:00
|
|
|
|
public void Update(SellBindingModel model)
|
2024-06-20 22:32:22 +04:00
|
|
|
|
{
|
|
|
|
|
if (model is null)
|
|
|
|
|
{
|
|
|
|
|
throw new ArgumentNullException("Update user: binding model is null");
|
|
|
|
|
}
|
|
|
|
|
|
2024-06-23 20:39:28 +04:00
|
|
|
|
DateSell = model.DateSell;
|
|
|
|
|
SupplyDocId = model.SupplyDocId;
|
2024-06-20 22:32:22 +04:00
|
|
|
|
}
|
2024-06-11 12:18:10 +04:00
|
|
|
|
}
|
|
|
|
|
}
|