62 lines
1.7 KiB
C#
62 lines
1.7 KiB
C#
using Contracts.BindingModels;
|
|
using Contracts.ViewModels;
|
|
using Models.Models;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.ComponentModel.DataAnnotations;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace DatabaseImplement.Models
|
|
{
|
|
public class Provider : IProviderModel
|
|
{
|
|
public int Id { get; private set; }
|
|
|
|
[Required]
|
|
public string Name { get; private set; } = string.Empty;
|
|
|
|
[Required]
|
|
public string FurnitureType { get; private set; } = string.Empty;
|
|
|
|
[Required]
|
|
public string OrganisationType { get; private set; } = string.Empty;
|
|
|
|
public string? DateLastDelivery { get; private set; }
|
|
|
|
public static Provider? Create(ProviderBindingModel model)
|
|
{
|
|
if(model == null) return null;
|
|
|
|
return new Provider
|
|
{
|
|
Id = model.Id,
|
|
Name = model.Name,
|
|
FurnitureType = model.FurnitureType,
|
|
OrganisationType = model.OrganisationType,
|
|
DateLastDelivery = model.DateLastDelivery,
|
|
};
|
|
}
|
|
|
|
public void Update(ProviderBindingModel model)
|
|
{
|
|
if (model == null) return;
|
|
|
|
Name = model.Name;
|
|
FurnitureType = model.FurnitureType;
|
|
OrganisationType = model.OrganisationType;
|
|
DateLastDelivery = model.DateLastDelivery;
|
|
}
|
|
|
|
public ProviderViewModel GetViewModel => new()
|
|
{
|
|
Id = Id,
|
|
Name = Name,
|
|
FurnitureType = FurnitureType,
|
|
OrganisationType = OrganisationType,
|
|
DateLastDelivery = DateLastDelivery,
|
|
};
|
|
}
|
|
}
|