public IActionResult Delete(int taskId)
        {
            Task model = _unitOfWork.Tasks.GetById(taskId);

            model.Project = _unitOfWork.Projects.GetById(model.ProjectId);
            return(View(model));
        }
        public IActionResult DeleteConfirm(int taskId)
        {
            Task model = _unitOfWork.Tasks.GetById(taskId);

            if (model == null)
            {
                return(NotFound());
            }
            _unitOfWork.Tasks.Delete(model);
            _unitOfWork.Save();
            return(RedirectToAction(nameof(List)));
        }
 private bool UpdateTask(Task task)
 {
     try
     {
         _unitOfWork.Tasks.Update(task);
         _unitOfWork.Save();
         return(true);
     }
     catch (ValidationException ex)
     {
         return(false);
     }
 }
        public bool CheckButtons(IUnitOfWork uow, int employeeId, int taskId, EmployeesFinishOrPassViewModel model)
        {
            Task editTask = model.Task; EmployeeTask employeeTask = _unitOfWork.EmployeeTasks.GetByEmployeeIdAndTaskId(employeeId, taskId);

            if (model.Pass != null)
            {
                if (model.PassConfirmed == true)
                {
                    if (model.RecipientEmployee != null)
                    {
                        model.RecipientEmployee = _unitOfWork.Employees.GetById(model.RecipientEmployee.Id);

                        DashboardDisplay dashboardDisplay = _unitOfWork.DashboardDisplays.GetByEmployeeIdAndTaskId(employeeId, taskId);
                        DeleteDashBoardTask(dashboardDisplay);

                        employeeTask.PassedTask = model.RecipientEmployee;
                        UpdateEmployeeTask(employeeTask);

                        EmployeeTask recipientEmployeeTask = _unitOfWork.EmployeeTasks.GetByEmployeeIdAndTaskId(model.RecipientEmployee.Id, taskId);

                        if (model.FixedTask == false)
                        {
                            if (recipientEmployeeTask == null)
                            {
                                recipientEmployeeTask        = GenerateEmployeetask(model.RecipientEmployee.Id, taskId);
                                recipientEmployeeTask.Picked = false;
                                CreateEmployeeTask(recipientEmployeeTask);
                            }
                            else
                            {
                                recipientEmployeeTask.Picked = false;
                                UpdateEmployeeTask(recipientEmployeeTask);
                            }

                            recipientEmployeeTask.Task.Status = Core.Enum.TaskStatusType.Open;
                        }
                        else
                        {
                            if (recipientEmployeeTask == null)
                            {
                                recipientEmployeeTask        = GenerateEmployeetask(model.RecipientEmployee.Id, taskId);
                                recipientEmployeeTask.Picked = true;
                                CreateEmployeeTask(recipientEmployeeTask);
                            }
                            else
                            {
                                recipientEmployeeTask.Picked = true;
                                UpdateEmployeeTask(recipientEmployeeTask);
                            }

                            DashboardDisplay recipientDashboardDisplay = GenerateDashboardTask(recipientEmployeeTask);
                            CreateDashboardDisplay(recipientDashboardDisplay);
                        }

                        recipientEmployeeTask.Task.Information = model.Task.Information;
                        recipientEmployeeTask.Task.Priority    = model.Task.Priority;
                        recipientEmployeeTask.Task.ValuedTime  = model.Task.ValuedTime;
                        UpdateTask(recipientEmployeeTask.Task);
                    }
                    else
                    {
                        return(false);
                    }
                }
                else
                {
                    model.PassClicked = true;
                    model.LoadSelectList(uow, employeeId, taskId);
                }
            }
            else if (model.Finish != null)
            {
                if (model.FinishConfirmed == true)
                {
                    DashboardDisplay dashboardDisplay = _unitOfWork.DashboardDisplays.GetByEmployeeIdAndTaskId(employeeId, taskId);
                    DeleteDashBoardTask(dashboardDisplay);

                    employeeTask.Task.Status  = Core.Enum.TaskStatusType.Completed;
                    employeeTask.Task.Enddate = DateTime.Now;
                    UpdateTask(employeeTask.Task);
                }
                else
                {
                    model.FinishClicked = true;
                }
            }

            return(true);
        }