public ActionResult FilterUsers(int?idCompany, int?activeFilterVal) { List <UserDTO> users; switch (activeFilterVal) { case 0: users = userLogic.ListUnactive(); break; case 2: users = userLogic.ListAll(); break; default: users = userLogic.ListActive(); break; } if (idCompany != null) { users = users.FindAll(u => u.Id_Company == idCompany); } UtilisateurIndexViewModel vm = new UtilisateurIndexViewModel { Users = UsersDTOToTuple(users), Companies = companyLogic.List(), Roles = roleLogic.List(), FilterUserByActiveVal = activeFilterVal, FilterUserByCompanyId = idCompany ?? null }; return(View("Index", vm)); }
public ActionResult Index() { int idCurrentUser = (int)Session["userId"]; Session["notifs"] = notifLogic.ListAllForUser(idCurrentUser).FindAll(n => n.IsRead == 0).Count; List <UserDTO> users = userLogic.ListActive(); List <CompanyDTO> companies = companyLogic.List(); List <RoleDTO> roles = roleLogic.List(); Tuple <UserDTO, CompanyDTO, List <RoleDTO> > userToEdit = null; if (TempData["userToEdit"] != null) { int userId = (int)TempData["UserToEdit"]; UserDTO usr = userLogic.Get(userId); userToEdit = UserDTOTOTuple(usr); } UtilisateurIndexViewModel vm = new UtilisateurIndexViewModel { Users = UsersDTOToTuple(users), Companies = companies, Roles = roles, UserToEdit = userToEdit }; if (TempData["FormError"] != null) { ViewBag.FormError = TempData["FormError"].ToString(); } if (TempData["SuccessModal"] != null) { ViewBag.SuccessModal = TempData["SuccessModal"].ToString(); } if (TempData["ErrorModal"] != null) { ViewBag.ErrorModal = TempData["ErrorModal"].ToString(); } return(View("Index", vm)); }
public ActionResult SearchUser(string searchVal) { if (searchVal != null) { List <UserDTO> users = userLogic.Search(searchVal); UtilisateurIndexViewModel vm = new UtilisateurIndexViewModel { Users = UsersDTOToTuple(users), Companies = companyLogic.List(), Roles = roleLogic.List(), UserToEdit = null }; return(View("Index", vm)); } else { return(RedirectToAction("Index")); } }