32 lines
694 B
C#
Raw Normal View History

2024-11-27 23:43:53 +04:00
using Contracts.BindingModels;
using Contracts.ViewModels;
using DataModels;
using System.ComponentModel.DataAnnotations;
namespace DataBaseImplements.Models
{
public class City : ICityModel
{
public int Id { get; set; }
[Required]
public string Name { get; set; } = string.Empty;
public static City? Create(CityBindingModel model)
{
return new City { Id = model.Id, Name = model.Name };
}
public void Update(CityBindingModel model)
{
Name = model.Name;
}
public CityViewModel GetViewModel => new()
{
Id = Id,
Name = Name,
};
}
}