public async Task <ActionResult> DeleteStatus(string id, bool safeDelete = false) { try { var item = await _taskStatusGetOperations.GetById(id); await _taskStatusService.Delete(id, safeDelete); var folder = await _folderGetOperations.GetById(item.FolderId); int newStatus = folder.StatusesOrder.LastIndexOf(id) - 1; if (newStatus < 0) { newStatus = 0; } var issues = await _issueGetOperations.ByStatus(id); issues.ToList().ForEach(async x => { await _issueService.ChangeStatus(new Core.Contract.Issue.Dtos.ChangeStatusDto() { IssueId = x.Id, StatusId = folder.StatusesOrder.ElementAt(newStatus) }); }); folder.StatusesOrder.Remove(id); await _folderWriteOperations.Update(folder.Id, folder); } catch (Exception e) { return(View("Error", ErrorViewModel.WithError(e.Message))); } return(Redirect("/Folder/Folders/" + id)); }
public async Task <ActionResult <bool> > Delete(int id) { return(Ok(await _taskStatusService.Delete(await GetUserId(), id, GetPermissionId()))); }