public object PostAddEdit(VariableDTO variableDTO) { int RelationTypeLU = base.MyRequest.Form["RelationTypeLU"].ToIntObj(); variableDTO.ListDependencies = variableDTO.ListDependencies ?? new List <VariableDependencyDTO>(); if (variableDTO.ProcessID.HasValue || variableDTO.ApplicationPageID.HasValue) { if (RelationTypeLU == (int)sysBpmsVariable.e_RelationTypeLU.Local && variableDTO.VarTypeLU == (int)sysBpmsVariable.e_VarTypeLU.List) { variableDTO.Collection = variableDTO.ListItems.BuildXml(); } //set ViewBags using (VariableService variableService = new VariableService()) { using (ProcessService processService = new ProcessService()) { sysBpmsVariable variable = variableDTO.ID != Guid.Empty ? variableService.GetInfo(variableDTO.ID) : new sysBpmsVariable(); if (!base.ProcessId.HasValue || processService.GetInfo(base.ProcessId.Value).AllowEdit()) { ResultOperation resultOperation = variable.Update(variableDTO.ProcessID, variableDTO.ApplicationPageID, variableDTO.Name, variableDTO.VarTypeLU, variableDTO.EntityDefID, variableDTO.FieldName, variableDTO.Query, variableDTO.FilterTypeLU, variableDTO.Collection, variableDTO.DBConnectionID, variableDTO.DefaultValue, variableDTO.WhereClause, variableDTO.OrderByClause); if (!resultOperation.IsSuccess) { return(new PostMethodMessage(resultOperation.GetErrors(), DisplayMessageType.error)); } List <sysBpmsVariableDependency> VariableDependencies = new List <sysBpmsVariableDependency>(); if (variableDTO.ID != Guid.Empty) { foreach (var item in variableDTO.ListDependencies) { sysBpmsVariableDependency variableDependency = new sysBpmsVariableDependency(); resultOperation = variableDependency.Update(item.ID, variableDTO.ID, item.DependentPropertyName, item.ToVariableID, item.ToPropertyName, item.Description); if (!resultOperation.IsSuccess) { return(new PostMethodMessage(resultOperation.GetErrors(), DisplayMessageType.error)); } VariableDependencies.Add(variableDependency); } resultOperation = variableService.Update(variable, VariableDependencies); } else { foreach (var item in variableDTO.ListDependencies) { sysBpmsVariableDependency variableDependency = new sysBpmsVariableDependency(); resultOperation = variableDependency.Update(item.ID, item.DependentVariableID, item.DependentPropertyName, item.ToVariableID, item.ToPropertyName, item.Description); if (!resultOperation.IsSuccess) { return(new PostMethodMessage(resultOperation.GetErrors(), DisplayMessageType.error)); } VariableDependencies.Add(variableDependency); } resultOperation = variableService.Add(variable, VariableDependencies); } if (resultOperation.IsSuccess) { return(new PostMethodMessage(SharedLang.Get("Success.Text"), DisplayMessageType.success, new { name = variable.Name, id = variable.ID, comboTree = variableService.GetVariableAsComboTree(base.ProcessId, base.ApplicationPageId, null).AsJson(), entityVariables = variableService.GetList(base.ProcessId, base.ApplicationPageId, (int)sysBpmsVariable.e_VarTypeLU.Object, "", null, true).Select(c => new { text = c.Name, value = c.ID }).ToList(), listVariables = variableService.GetList(base.ProcessId, base.ApplicationPageId, (int)sysBpmsVariable.e_VarTypeLU.List, "", null, true).Select(c => new { text = c.Name, value = c.Name }).ToList() })); } else { return(new PostMethodMessage(resultOperation.GetErrors(), DisplayMessageType.error)); } } else { return(new PostMethodMessage(LangUtility.Get("NotAllowEdit.Text", nameof(sysBpmsProcess)), DisplayMessageType.error)); } } } } return(new PostMethodMessage(SharedLang.Get("NotFound.Text"), DisplayMessageType.error)); }