// GET: Profile/Details/5 public ActionResult Details(int id) { if (_rolesManager.SetCurrentEmployee(_employeeDataAccess, GetCurrentUserEmail())) { var accessLevel = _rolesManager.IdentifyRole(); if (accessLevel == "FullAccess" || accessLevel == "FullView" || accessLevel == "TeamView") { var employee = new Employee(); if (!_rolesManager.GetEmployeeDetails(_employeeDataAccess, ref employee, id)) { ViewBag.ErrorMsg = "You are not authorized to view this page"; return(View("Error")); } if (employee != null) { if (employee.Profile == null) { employee.Profile = new Profile { Id = employee.Id }; _profileDataAccess.CreateProfile(employee.Profile); ViewBag.Access = accessLevel; return(RedirectToAction("Details", id)); // HACK: reload to avoid ununderstandable Null exception!! } ViewBag.Access = accessLevel; ViewBag.ProfilePic = _rolesManager.LoggedInEmployee.Profile.ProfilePic; return(View(employee)); } ViewBag.ErrorMsg = "No such page exists."; return(View("Error")); } ViewBag.ErrorMsg = "You are not authorized to view this page"; return(View("Error")); } ViewBag.ErrorMsg = "You are not registered on our system. Plz contact the system administrator if u think this is wrong."; return(View("Error")); }
// GET: Employees/Details/5 public ActionResult Details(int?id) { if (_rolesManager.SetCurrentEmployee(_employeeDataAccess, GetCurrentUserEmail())) { var accessLevel = _rolesManager.IdentifyRole(); if (accessLevel == "FullAccess" || accessLevel == "FullView" || accessLevel == "TeamView") { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } if (_rolesManager.SetCurrentEmployee(_employeeDataAccess, GetCurrentUserEmail())) { var employee = new Employee(); if (!_rolesManager.GetEmployeeDetails(_employeeDataAccess, ref employee, id)) { ViewBag.ErrorMsg = "You are not authorized to view this page"; return(View("Error")); } if (employee == null) //When HR, and returns no results! { return(HttpNotFound()); } //found! ViewBag.Access = _rolesManager.IdentifyRole(); ViewBag.ProfilePic = _rolesManager.LoggedInEmployee.Profile.ProfilePic; return(View(employee)); } } ViewBag.ErrorMsg = "You are not authorized to view this page"; return(View("Error")); } ViewBag.ErrorMsg = "You are not registered on our system. Plz contact the system administrator if u think this is wrong."; return(View("Error")); }