52 lines
1.2 KiB
C#
52 lines
1.2 KiB
C#
|
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
|
|||
|
};
|
|||
|
}
|
|||
|
}
|