using Step.Model.DatabaseModels; using System.Collections.Generic; using System.ComponentModel.DataAnnotations; 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 short Id { get; set; } [Range(1, byte.MaxValue)] public byte? MagazineId { get; set; } [Range(1, ushort.MaxValue)] public int? PositionId { get; set; } [Range(1, byte.MaxValue)] public byte? OriginMagazineId { get; set; } [Range(1, ushort.MaxValue)] public int? OriginPositionId { get; set; } public int MaxLeft { get; set; } public int MaxRight { get; set; } public List ChildsTools { get; set; } public static explicit operator DTONcShankModel(DbNcShankModel obj) { List tools = new List(); if (obj.Tools != null) foreach (DbNcToolModel 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, OriginMagazineId = obj.OriginMagazineId, OriginPositionId = obj.OriginPositionId, 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, OriginMagazineId = obj.OriginMagazineId, OriginPositionId = obj.OriginPositionId, }; } } }