COP3PLUSSagirov/DatabaseImplements/Models/Delivery.cs
2024-11-06 15:40:33 +04:00

52 lines
1.5 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 DatabaseImplements.Models
{
public class Delivery : IDeliveryModel
{
public int Id { get; private set; }
[Required]
public string CourierFIO { get; private set; } = string.Empty;
[Required]
public string Phone { get; private set; } = string.Empty;
[Required]
public string Image { get; private set; } = string.Empty;
[Required]
public string Type { get; private set; } = string.Empty;
public static Delivery? Create(DeliveryBindingModel model)
{
return new Delivery()
{
Id = model.Id,
CourierFIO = model.CourierFIO,
Image = model.Image,
Phone = model.Phone,
Type = model.Type,
};
}
public void Update(DeliveryBindingModel model)
{
CourierFIO = model.CourierFIO;
Image = model.Image;
Phone = model.Phone;
Type = model.Type;
}
public DeliveryViewModel GetViewModel => new()
{
Id = Id,
CourierFIO = CourierFIO,
Image = Image,
Phone = Phone,
Type = Type,
};
}
}