protected override bool AuthorizeCore(HttpContextBase httpContext) { userProfileService = new UserProfileServices(new DealsDB()); bool authorize = false; if (HttpContext.Current.Session[KeyList.SessionKeys.UserID] != null) { var userSessionId = HttpContext.Current.Session[KeyList.SessionKeys.UserID].ToString(); var user = userProfileService.GetByID(Convert.ToInt32(userSessionId)); foreach (var role in allowedroles) { if (user != null && user.UserType1.UserTypeName.Contains(role)) { authorize = true; /* return true if Entity has current user(active) with specific role */ } } userProfileService.Dispose(); return(authorize); } else { return(authorize); } }
public bool UserActivate(string guid) { Guid userGuid = Guid.Parse(guid); UserVerification ActivateUser = DealDb.UserVerifications.Where(x => x.UserVerificationCode == userGuid).SingleOrDefault(); if (ActivateUser != null) { UserProfile getuserforactivation = DealDb.UserProfiles.Find(ActivateUser.Userid); getuserforactivation.isContactVerified = true; //var verifiedsucess = UserprofileService.UpdateUser(getuserforactivation); UserprofileService = new UserProfileServices(DealDb); if (UserprofileService.UpdateUser(getuserforactivation) == true) { Delete(ActivateUser); UserprofileService.Dispose(); return(true); } } return(false); }