public ActionResult Delete(Employee model) { var us = _repositoryUser.Find(u => u.Email.Equals(model.Email)); var user = us.FirstOrDefault(); if (user == null) { _repositoryEmployee.Delete(model.EmployeeId); _repositoryProject_Task.DeleteTasksNoAuto(model.EmployeeId); } else { var usBos = _repositoryUser.Find(u => u.Email.Equals(User.Identity.Name)); var userBos = usBos.FirstOrDefault(); var projects = _repositoryProject.Get(userBos.Id); _repositoryUser_Employee.Delete(userBos, model); _repositoryProject_Task.DeleteTasks(model.EmployeeId, projects); } return(RedirectToAction("Index", "SanctumSanctorum")); }