public void OnActionExecuting(ActionExecutingContext filterContext) { if (_shareTill.HasValue) { if (DateTime.Now.Date.CompareTo(_shareTill.Value.Date) <= 0) { IUsersRepository usersRepository = NinjectWebCommon.GetInstance <IUsersRepository>(); IProfilesRepository profilesRepository = NinjectWebCommon.GetInstance <IProfilesRepository>(); User authenticatedUser = usersRepository.GetUserByPhone(filterContext.HttpContext.User.Identity.Name); if (authenticatedUser != null) { if (authenticatedUser.Apartments.Count < 1) { Profile shareProfile = profilesRepository.GetProfileByName(_shareProfileName); if (shareProfile != null && _shareProfileExpires != null) { authenticatedUser.Profile = shareProfile; authenticatedUser.ProfileExpires = _shareProfileExpires; usersRepository.SaveChanges(); } } } } } }