/// <summary> /// 验证模块元素 /// </summary> /// <param name=""></param> /// <returns></returns> public Result CheckElement(PowerElement model) { if (model.ModuleId <= 0) { return(Result.Fail("模块不能为空")); } if (string.IsNullOrWhiteSpace(model.Name)) { return(Result.Fail("名称不能为空")); } if (model.Id <= 0) { if (_elementBusiness.Exist(p => p.ModuleId == model.ModuleId && p.Name == model.Name && p.Status == NomalStatus.Valid)) { return(Result.Fail("名称已存在")); } } else { if (_elementBusiness.Exist(p => p.ModuleId == model.ModuleId && p.Name == model.Name && p.Status == NomalStatus.Valid && p.Id != model.Id)) { return(Result.Fail("名称已存在")); } } return(Result.Success()); }
public Result AddOrEditElement(PowerElement model) { var result = CheckElement(model); if (!result.Succeed) { return(result); } model.Status = NomalStatus.Valid; if (model.Id <= 0) { return(_elementBusiness.Add(model)); } else { return(_elementBusiness.Update(model)); } }
public override IDeepCopyable CopyTo(IDeepCopyable other) { var dest = other as DispenseComponent; if (dest != null) { base.CopyTo(dest); if (Product != null) { dest.Product = (Hl7.Fhir.Model.Coding)Product.DeepCopy(); } if (EyeElement != null) { dest.EyeElement = (Code <Hl7.Fhir.Model.VisionPrescription.VisionEyes>)EyeElement.DeepCopy(); } if (SphereElement != null) { dest.SphereElement = (Hl7.Fhir.Model.FhirDecimal)SphereElement.DeepCopy(); } if (CylinderElement != null) { dest.CylinderElement = (Hl7.Fhir.Model.FhirDecimal)CylinderElement.DeepCopy(); } if (AxisElement != null) { dest.AxisElement = (Hl7.Fhir.Model.Integer)AxisElement.DeepCopy(); } if (PrismElement != null) { dest.PrismElement = (Hl7.Fhir.Model.FhirDecimal)PrismElement.DeepCopy(); } if (BaseElement != null) { dest.BaseElement = (Code <Hl7.Fhir.Model.VisionPrescription.VisionBase>)BaseElement.DeepCopy(); } if (AddElement != null) { dest.AddElement = (Hl7.Fhir.Model.FhirDecimal)AddElement.DeepCopy(); } if (PowerElement != null) { dest.PowerElement = (Hl7.Fhir.Model.FhirDecimal)PowerElement.DeepCopy(); } if (BackCurveElement != null) { dest.BackCurveElement = (Hl7.Fhir.Model.FhirDecimal)BackCurveElement.DeepCopy(); } if (DiameterElement != null) { dest.DiameterElement = (Hl7.Fhir.Model.FhirDecimal)DiameterElement.DeepCopy(); } if (Duration != null) { dest.Duration = (Hl7.Fhir.Model.SimpleQuantity)Duration.DeepCopy(); } if (ColorElement != null) { dest.ColorElement = (Hl7.Fhir.Model.FhirString)ColorElement.DeepCopy(); } if (BrandElement != null) { dest.BrandElement = (Hl7.Fhir.Model.FhirString)BrandElement.DeepCopy(); } if (NotesElement != null) { dest.NotesElement = (Hl7.Fhir.Model.FhirString)NotesElement.DeepCopy(); } return(dest); } else { throw new ArgumentException("Can only copy to an object of the same type", "other"); } }
public Result AddOrEditModule(PowerModule model) { var result = CheckModule(model); if (!result.Succeed) { return(result); } model.Status = NomalStatus.Valid; try { using (TransactionScope ts = new TransactionScope()) { //新增 if (model.Id <= 0) { model.Level = 1; model.LevelMap = "0"; _moduleBusiness.Add(model); } if (model.Pid <= 0) { model.LevelMap = ",0," + model.Id + ","; model.Level = 1; } else { var modelParent = _moduleBusiness.GetSingle(p => p.Id == model.Pid && p.Status == NomalStatus.Valid); if (modelParent == null) { return(Result.Fail("未查询到父级模块")); } model.LevelMap = modelParent.LevelMap + model.Id + ","; model.Level = modelParent.Level + 1; //删除父节点 模块元素中的 显示 _elementBusiness.Delete(p => p.ModuleId == modelParent.Id); } var showElemCount = _elementBusiness.Count(p => p.ModuleId == model.Id && p.DomId == "btnShow"); if (showElemCount <= 0 && model.Pid > 0) { var modelElement = new PowerElement() { Id = 0, ModuleId = model.Id, Name = "显示", DomId = "btnShow", Status = NomalStatus.Valid, IsSystem = IsSystem.Yes, Position = PowerElementPosition.Up, DisplayOrder = -9999 }; _elementBusiness.Add(modelElement); } _moduleBusiness.Update(model); ts.Complete(); return(Result.Success()); } } catch (Exception ex) { return(Result.Fail("操作失败:" + ex.Message)); } }
public Result EditElement([FromForm] PowerElement model) { return(_wrappers.AddOrEditElement(model)); }