2023-05-13 06:06:53 -07:00

48 lines
1023 B
C#

using FurnitureAssemblyContracts.BindingModels;
using FurnitureAssemblyContracts.ViewModels;
using FurnitureAssemblyDataModels.Models;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace FurnitureAssemblyDatabaseImplement.Models
{
public class Scope : IScopeModel
{
public int Id { get; set; }
[Required]
public string Name { get; set; } = string.Empty;
[ForeignKey("ScopeId")]
public virtual List<Material> Materials { get; set; } = new();
public static Scope? Create(ScopeBindingModel? model)
{
if (model == null)
{
return null;
}
return new Scope()
{
Id = model.Id,
Name = model.Name
};
}
public void Update(ScopeBindingModel? model)
{
if (model == null)
{
return;
}
Name = model.Name;
}
public ScopeViewModel GetViewModel => new()
{
Id = Id,
Name = Name
};
}
}