AccountingWarehouseProducts.../AccountingWarehouseProducts/AccountingWarehouseProductsDatabaseImplement/Models/Supplier.cs

57 lines
1.5 KiB
C#
Raw Normal View History

using AccountingWarehouseProductsContracts.BindingModels;
using AccountingWarehouseProductsContracts.ViewModels;
using AccountingWarehouseProductsDataModels.Models;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;
namespace AccountingWarehouseProductsDatabaseImplement.Models
{
public class Supplier : ISupplierModel
{
public int Id { get; set; }
[Required]
public string SupplierName { get; set; } = string.Empty;
[Required]
public string ContactPerson { get; set; } = string.Empty;
[Required]
public string Phone { get; set; } = string.Empty;
public static Supplier? Create(SupplierBindingModel model)
{
if (model == null) return null;
return new Supplier()
{
Id = model.Id,
SupplierName = model.SupplierName,
ContactPerson = model.ContactPerson,
Phone = model.Phone
};
}
public void Update(SupplierBindingModel model)
{
if (model == null) return;
SupplierName = model.SupplierName;
ContactPerson = model.ContactPerson;
Phone = model.Phone;
}
public SupplierViewModel GetViewModel => new()
{
Id = Id,
SupplierName = SupplierName,
ContactPerson = ContactPerson,
Phone = Phone
};
}
}