Zhelovanov_Dmitrii_COP/DatabaseImplement/Models/Shape.cs
2023-11-30 23:20:29 +04:00

52 lines
859 B
C#

using Contracts.BindingModels;
using Contracts.ViewModels;
using DataModels.Models;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace DatabaseImplement.Models
{
public class Shape : IShape
{
[Required]
public string Name { get; set; }=string.Empty;
public int Id { get; set; }
public static Shape? Create(ShapeBindingModel model)
{
if (model == null)
{
return null;
}
return new Shape()
{
Id = model.Id,
Name = model.Name
};
}
public void Update(ShapeBindingModel model)
{
if (model == null)
{
return;
}
Id = model.Id;
Name = model.Name;
}
public ShapeViewModel GetViewModel => new()
{
Id = Id,
Name = Name
};
}
}