PIbd-21_Medvedkov_Coursach/ComputerShopDatabaseImplement/Models/Batch.cs

52 lines
1.2 KiB
C#
Raw Normal View History

2024-05-01 04:42:57 +04:00
using ComputerShopContracts.BindingModels;
using ComputerShopContracts.ViewModels;
using ComputerShopDataModels.Models;
using Microsoft.IdentityModel.Tokens;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ComputerShopDatabaseImplement.Models
{
public class Batch : IBatchModel
{
public int Id { get; set; }
[Required]
public DateTime DateBatch { get; set; } = DateTime.Now;
[Required]
public int ProductId { get; set; }
public static Batch Create(ComputerShopDatabase context, BatchBindingModel model)
{
return new Batch()
{
Id = model.Id,
DateBatch = model.DateBatch,
ProductId = model.ProductId,
};
}
public void Update(BatchBindingModel model)
{
if (model == null)
{
return;
}
ProductId = model.ProductId;
DateBatch = model.DateBatch;
}
public BatchViewModel GetViewModel => new()
{
Id = Id,
DateBatch = DateBatch,
ProductId = ProductId
};
}
}