public async Task <IActionResult> EditAppropriationTask([FromRoute] int id, [FromForm] TaskViewModel model) { if (ModelState.IsValid) { var task = model.Task; var userTaskAnalyst = new UserTask { TaskId = task.Id, UserId = model.AnalystId, RoleId = (int)RolesEnum.Analyst, CreatedAt = DateTime.Now, UpdatedAt = DateTime.Now }; var userTaskCoordinator = new UserTask { TaskId = task.Id, UserId = model.CoordinatorId, RoleId = (int)RolesEnum.Coordinator, CreatedAt = DateTime.Now, UpdatedAt = DateTime.Now }; try { userTaskAnalyst = await _userTaskSvc.UpsertAndSave(userTaskAnalyst); userTaskCoordinator = await _userTaskSvc.UpsertAndSave(userTaskCoordinator); } catch (Exception e) { Console.WriteLine(e); throw; } task.StatusId = (int)StatusesEnum.ReviewByAnalists; task.UpdatedAt = DateTime.Now; try { task = await _tasksSvc.UpsertAndSave(task); } catch (Exception e) { Console.WriteLine(e); throw; } return(RedirectToAction("TasksForAppropriationList")); } return(RedirectToAction("TasksForAppropriationList")); }