using Step.Model.DatabaseModels; using System; using System.Collections.Generic; using System.ComponentModel.DataAnnotations; using System.Linq; using System.Text; using System.Threading.Tasks; namespace Step.Model.DTOModels.ToolModels { public class DTONewNcShankModel { [Required] public ushort? Balluf { get; set; } [Required] public byte MagazinePositionType { get; set; } public static explicit operator DTONewNcShankModel(DbNcShankModel obj) { return new DTONewNcShankModel() { Balluf = (ushort)obj.Balluf, MagazinePositionType = obj.MagazinePositionType }; } public static explicit operator DbNcShankModel(DTONewNcShankModel obj) { return new DbNcShankModel() { Balluf = obj.Balluf, MagazinePositionType = obj.MagazinePositionType }; } } public class DTONcShankModel : DTONewNcShankModel { public int Id { get; set; } [Range(1, byte.MaxValue)] public byte? MagazineId { get; set; } [Range(1, byte.MaxValue)] public byte? PositionId { get; set; } public List ChildsTools { get; set; } public static explicit operator DTONcShankModel(DbNcShankModel obj) { List tools = new List(); if (obj.Tools != null) foreach (var tool in obj.Tools) { tools.Add((DTONcToolModel)tool); } return new DTONcShankModel() { Id = obj.ShankId, Balluf = (ushort)obj.Balluf, MagazinePositionType = obj.MagazinePositionType, MagazineId = obj.MagazineId, PositionId = obj.PositionId, ChildsTools = tools }; } public static explicit operator DbNcShankModel(DTONcShankModel obj) { return new DbNcShankModel() { ShankId = obj.Id, Balluf = obj.Balluf, MagazinePositionType = obj.MagazinePositionType, MagazineId = obj.MagazineId, PositionId = obj.PositionId }; } } }