public ActionResult ShowEmployees(int?idCompany = null) { EmployeesFilter filter = new EmployeesFilter(); if (idCompany != null) { var result = CompanyManager.GetManager().LoadEntity(idCompany); if (!result.Success) { return(HttpNotFound()); } Session["Company"] = filter.Company = result.ResultEntity; } else { Session["Company"] = null; } Result <Employee> resultLoadList = EmployeesManager.GetManager().LoadEntityList(filter); if (!resultLoadList.Success) { return(HttpNotFound()); } ; return(View(resultLoadList.Entitys)); }
public ActionResult EditEmployee(Employee employee) { EmployeesManager.GetManager().Save(employee); //сессии использую для того, чтобы запоминать какая въюха была до перехода на форму редактирования //(если мы перешли в редактирование пользователя из вьюхи со списком работников конкретной компании, то вернемся потом на эту же вьюху) Company company = (Company)Session["Company"]; return(RedirectToAction("ShowEmployees", new { idCompany = (company != null) ? company.Id : null })); }
/// <summary> /// Удаление работника /// </summary> /// <param name="idEmployee"></param> /// <returns></returns> public ActionResult DeleteEmployee(int idEmployee) { var result = EmployeesManager.GetManager().LoadEntity(idEmployee); if (!result.Success) { return(HttpNotFound()); } EmployeesManager.GetManager().Delete(result.ResultEntity); //сессии использую для того, чтобы запоминать какая въюха была до перехода на форму редактирования //(если мы перешли в редактирование пользователя из вьюхи со списком работников конкретной компании, то вернемся потом на эту же вьюху) Company company = (Company)Session["Company"]; return(RedirectToAction("ShowEmployees", new { idCompany = (company != null) ? company.Id : null })); }
public ActionResult EditEmployee(int?idEmployee = null) { //Эту штуку добавил для того, чтобы мы могли заполнить список имеющихся компаний на вьюхе var result = CompanyManager.GetManager().LoadEntityList(null); if (!result.Success) { return(HttpNotFound()); } ViewData["Companys"] = from company in result.Entitys select new SelectListItem { Text = company.Name, Value = company.Id.ToString() }; var resultLoadEntity = EmployeesManager.GetManager().LoadEntity((int)idEmployee); if (!resultLoadEntity.Success) { return(View()); } return(View(resultLoadEntity.ResultEntity)); }