private void CreateNewSize() { try { for (int i = 0; i < _template.SizeTotalRows; i++) { var item = new EST_Item_Specification_Size() { EstItemID = _estItemID, Pc = 0, IsHeightEnabled = _template.IsHeightEnabled, IsPcEnabled = _template.IsPcEnabled, IsThicknessEnabled = _template.IsThicknessEnabled, IsWidthEnabled = _template.IsWidthEnabled, IsHeightMandatory = _template.IsHeightMandatory, IsPcMandatory = _template.IsPcEnabledMandatory, IsThicknessMandatory = _template.IsThicknessMandatory, IsWidthMandatory = _template.IsWidthMandatory, IsValidated = true, }; _db.EST_Item_Specification_Size.Add(item); } _db.SaveChanges(); } catch (DbEntityValidationException dbEx) { var s = dbEx.Message; throw; } }
private void CopySize() { var objs = _db.EST_Item_Specification_Size.Where(x => x.EstItemID == _originalItem.EstItemID).ToList(); foreach (var obj in objs) { var newObj = new EST_Item_Specification_Size(); MyReflection.Copy(obj, newObj); newObj.EstItemSizeID = 0; newObj.EstItemID = NewEstItem.EstItemID; _db.EST_Item_Specification_Size.Add(newObj); } _db.SaveChanges(); }
//Single Size private bool IsSizeValidated(EST_Item_Specification_Size size) { var b = true; if (size.IsWidthMandatory) { if (MyConvert.ConvertToInteger(size.WidthFeet) == 0 && MyConvert.IsNullString(size.WidthInch)) { b = false; } } if (size.IsHeightEnabled) { if (MyConvert.ConvertToInteger(size.WidthFeet) == 0 && MyConvert.IsNullString(size.WidthInch)) { b = false; } } if (size.IsThicknessEnabled) { if (MyConvert.ConvertToInteger(size.HeightFeet) == 0 && MyConvert.IsNullString(size.HeightInch)) { b = false; } } if (size.IsPcEnabled) { if (MyConvert.ConvertToDouble(size.Pc) < 1) { b = false; } } return(b); }