/// <summary> /// Delete the current Step. /// </summary> private void DeleteStep() { var step = this.GetStep(); if (step == null) { return; } var dataContext = GetRockContext(); var stepService = new StepService(dataContext); string errorMessage; if (!stepService.CanDelete(step, out errorMessage)) { mdDeleteWarning.Show(errorMessage, ModalAlertType.Information); return; } stepService.Delete(step); dataContext.SaveChanges(); GoToSuccessPage(null); }
/// <summary> /// Handles the Click event of the delete/archive button in the grid /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="Rock.Web.UI.Controls.RowEventArgs" /> instance containing the event data.</param> protected void DeleteStep_Click(object sender, Rock.Web.UI.Controls.RowEventArgs e) { var dataContext = GetDataContext(); var stepService = new StepService(dataContext); var step = stepService.Get(e.RowKeyId); if (step != null) { string errorMessage; if (!stepService.CanDelete(step, out errorMessage)) { mdGridWarning.Show(errorMessage, ModalAlertType.Information); return; } stepService.Delete(step); dataContext.SaveChanges(); } BindParticipantsGrid(); }
/// <summary> /// Delete the step with the given Id and then re-render the lists of steps /// </summary> /// <param name="stepId"></param> private void DeleteStep(int stepId) { var rockContext = GetRockContext(); var service = new StepService(rockContext); var step = service.Get(stepId); string errorMessage; if (step == null) { return; } if (!service.CanDelete(step, out errorMessage)) { ShowError(errorMessage); return; } service.Delete(step); rockContext.SaveChanges(); ClearBlockData(); }
public object PostAddEditUserTask(PostAddEditUserTaskDTO userTaskDTO) { using (ProcessService processService = new ProcessService()) { if (!processService.GetInfo(userTaskDTO.ProcessID).AllowEdit()) { return(new PostMethodMessage(LangUtility.Get("NotAllowEdit.Text", nameof(sysBpmsProcess)), DisplayMessageType.error)); } } ResultOperation resultOperation = new ResultOperation(); using (TaskService taskService = new TaskService()) { //save access sysBpmsTask task = taskService.GetInfo(userTaskDTO.ID); UserTaskRuleModel userTaskRuleModel = new UserTaskRuleModel(); if (userTaskDTO.OwnerTypeLU.HasValue) { switch ((sysBpmsTask.e_OwnerTypeLU)userTaskDTO.OwnerTypeLU) { case sysBpmsTask.e_OwnerTypeLU.User: userTaskRuleModel.AccessType = userTaskDTO.UserAccessType.ToIntObj(); switch ((UserTaskRuleModel.e_UserAccessType)userTaskDTO.UserAccessType) { case UserTaskRuleModel.e_UserAccessType.Static: //userTaskDTO.UserID is filled automativally break; case UserTaskRuleModel.e_UserAccessType.Variable: userTaskRuleModel.Variable = userTaskDTO.ddlUserVariable; break; } break; case sysBpmsTask.e_OwnerTypeLU.Role: userTaskRuleModel.AccessType = userTaskDTO.RoleAccessType.ToIntObj(); switch ((UserTaskRuleModel.e_RoleAccessType)userTaskDTO.RoleAccessType) { case UserTaskRuleModel.e_RoleAccessType.Static: //userTaskRuleModel.RoleCode = Request.Form["RoleName"]; userTaskRuleModel.SpecificDepartmentId = userTaskDTO.SpecificDepartmentID; break; case UserTaskRuleModel.e_RoleAccessType.Variable: userTaskRuleModel.Variable = userTaskDTO.ddlRoleVariable; userTaskRuleModel.SpecificDepartmentId = userTaskDTO.SpecificDepartmentID; break; case UserTaskRuleModel.e_RoleAccessType.CorrespondentRole: userTaskRuleModel.RoleCode = userTaskDTO.ddlRoleRuleRoleName; userTaskRuleModel.UserType = userTaskDTO.ddlRoleRuleUserType; userTaskRuleModel.GoUpDepartment = userTaskDTO.GoUpDepartment; break; } break; } userTaskDTO.Rule = userTaskRuleModel.BuildXml(); resultOperation = task.Update(userTaskDTO.RoleName, userTaskDTO.SpecificDepartmentID, userTaskDTO.OwnerTypeLU, userTaskDTO.UserID, userTaskDTO.Rule); if (!resultOperation.IsSuccess) { return(new PostMethodMessage(resultOperation.GetErrors(), DisplayMessageType.error)); } } resultOperation = taskService.Update(task); //save step int index = 0; userTaskDTO.ListSteps = userTaskDTO.ListSteps ?? new List <StepDTO>(); userTaskDTO.ListSteps.ForEach(c => { c.Position = ++index; }); using (StepService stepService = new StepService()) { List <sysBpmsStep> CurrentSteps = stepService.GetList(userTaskDTO.ID, null); foreach (sysBpmsStep item in CurrentSteps.Where(c => !userTaskDTO.ListSteps.Any(d => d.ID == c.ID))) { resultOperation = stepService.Delete(item.ID); if (!resultOperation.IsSuccess) { return(new PostMethodMessage(resultOperation.GetErrors(), DisplayMessageType.error)); } } foreach (StepDTO item in userTaskDTO.ListSteps) { resultOperation = null; if (item.ID != Guid.Empty) { resultOperation = stepService.Update(new sysBpmsStep(item.ID, item.TaskID, item.Position, item.DynamicFormID, item.Name)); } else { resultOperation = stepService.Add(new sysBpmsStep(item.ID, item.TaskID, item.Position, item.DynamicFormID, item.Name)); } if (!resultOperation.IsSuccess) { return(new PostMethodMessage(resultOperation.GetErrors(), DisplayMessageType.error)); } } if (resultOperation.IsSuccess) { return(new PostMethodMessage(SharedLang.Get("Success.Text"), DisplayMessageType.success)); } else { return(new PostMethodMessage(resultOperation.GetErrors(), DisplayMessageType.error)); } } } }