63 lines
1.4 KiB
C#
63 lines
1.4 KiB
C#
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,
|
|
};
|
|
}
|
|
}
|