COP-17/WinFormsProject/DateBaseImplement/Models/Provider.cs

63 lines
1.4 KiB
C#
Raw Permalink Normal View History

2023-11-15 22:51:44 +04:00
using Contracts.BindingModels;
using Contracts.ViewModels;
using DataModels.Models;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace DateBaseImplement.Models
{
public class Provider : IProviderModel
{
public int Id { get; set; }
[Required]
public string Name { get; set; }
[Required]
public byte[] Logo { get; set; }
[Required]
public string Type { get; set; }
[Required]
public string Number { get; set; }
public static Provider? Create(ProviderBindingModel model)
{
if (model == null) return null;
return new Provider()
{
Id = model.Id,
Name = model.Name,
Type = model.Type,
Logo = model.Logo,
Number = model.Number,
};
}
public void Update(ProviderBindingModel model)
{
if (model == null) return;
Name = model.Name;
Type = model.Type;
Logo = model.Logo;
Number = model.Number;
}
public ProviderViewModel GetViewModel => new()
{
Id = Id,
Name = Name,
Type = Type,
Logo = Logo,
Number = Number,
};
}
}