public async Task <ActionResult> Index() { var userId = System.Web.HttpContext.Current.User.Identity.GetUserId(); var _userService = new UserService(); var _applicationRole = new ApplicationRoleService(); var user = await _userService.GetAsync(x => x.Id == userId); var roleType = RoleType.SuperAdmin; var roleID = user.Roles.FirstOrDefault().RoleId; var role = await _applicationRole.FindByIdAsync(roleID); switch (role.Name) { case "SuperAdmin": roleType = RoleType.SuperAdmin; break; case "Supervisor": roleType = RoleType.SuperVisor; break; case "Security": roleType = RoleType.Security; break; case "BuildingAdmin": roleType = RoleType.BuildingAdmin; break; default: break; } var userSessionData = new UserSessionDataVM { ThemeName = (string.IsNullOrEmpty(user.ThemeName) ? "theme1" : user.ThemeName), ImageLogoPath = (user.Organization == null ? "~\\images\\logo\\main_logo.png" : (string.IsNullOrEmpty(user.Organization.ImagePath) ? "~\\images\\logo\\main_logo.png" : user.Organization.ImagePath)), UserRole = roleType, ProfilePicPath = user.ProfilePicturePath, FullName = user.FullName, IsImageAvailable = System.IO.File.Exists(Server.MapPath("\\") + "" + (!string.IsNullOrEmpty(user.ProfilePicturePath)? user.ProfilePicturePath.Replace("/", "\\"):Server.MapPath("~/images/avatar.jpg"))) //user.ProfilePicturePath.Replace("/", "\\")) }; Session["UserSession"] = userSessionData; return(View()); // IsImageAvailable = System.IO.File.Exists( Server.MapPath("\\") + "" + user.ProfilePicturePath.Replace("/", "\\")) }
public async Task <VisitorDataVM> GetVisitorCheckInHistory(long visitorId)//, int pageIndex, int pageSize, string sortField = "", string sortOrder = "ASC") { var userId = System.Web.HttpContext.Current.User.Identity.GetUserId(); var visitorDataVMData = _visitorCheckInCheckOutHelper.GetVisitorCheckInHistory(visitorId, userId); if (visitorDataVMData != null) { var _userService = new UserService(); var _applicationRole = new ApplicationRoleService(); var user = await _userService.GetAsync(x => x.Id == userId); var roleID = user.Roles.FirstOrDefault().RoleId; var role = await _applicationRole.FindByIdAsync(roleID); if (role.Name == "Security") { visitorDataVMData.IsSecurityPerson = true; } } return(visitorDataVMData); }