//[CacheDependency("cms.user|byname|{0}")] public IUserInfo GetUserByUsername(string Username, string[] Columns = null) { return(_UserInfoProvider.Get() .WhereEquals("Username", Username) .ColumnsNullHandled(Columns) .FirstOrDefault()); }
public UserInfo GetOrCreate() { var currentPrincipal = _userPrincipalProvider.Get(); var userInfo = _userInfoProvider.Get(currentPrincipal.Sid); if (userInfo != null) { if (userInfo.Login.Equals(currentPrincipal.Name, StringComparison.InvariantCultureIgnoreCase)) { return(userInfo); } var existsUserAdInfo = _adUserInfoProvider.Get(currentPrincipal.Sid); _userInfoProvider.Update(userInfo.Id, existsUserAdInfo.Login, existsUserAdInfo.DisplayName, existsUserAdInfo.Email); return(userInfo); } var newUserAdInfo = _adUserInfoProvider.Get(currentPrincipal.Sid); return(_userInfoProvider.Create( new UserInfo { DisplayName = newUserAdInfo.DisplayName, Email = newUserAdInfo.Email, Login = newUserAdInfo.Login, Sid = currentPrincipal.Sid })); }
/* CTB routring: End */ public override void MapDtoProperties(CMS.DocumentEngine.Types.MedioClinic.Doctor page, Doctor dto) { dto.UrlSlug = page.UrlSlug; dto.UserId = page.UserAccount; dto.UserName = _userInfoProvider.Get(page.UserAccount)?.UserName; dto.EmergencyShift = GetShiftDayOfWeek(page.Fields.EmergencyShift); dto.EmergencyShiftString = page.Fields.EmergencyShift.FirstOrDefault().DocumentName; dto.Degree = page.Degree; dto.Biography = page.Fields.Biography; dto.Specialty = page.Specialty; if (page.Fields.BackdropPicture != null) { dto.BackdropPictureUrl = _repositoryServices.PageAttachmentUrlRetriever.Retrieve(page.Fields.BackdropPicture); } var culture = Thread.CurrentThread.CurrentUICulture.ToSiteCulture(); if (culture != null) { /* CTB routring: Begin */ dto.DoctorDetailUrl = _repositoryServices.PageUrlRetriever.Retrieve(page, culture.IsoCode).RelativePath; /* CTB routing: End */ /* Conventional routing: Begin */ //dto.DoctorDetailUrl = _navigationRepository.GetUrlByNodeId(page.NodeID, culture); /* Conventional routing: End */ } }
public IList <Course> GetCoursesByUserEnrollment(int userId) { var user = _userInfoProvider.Get(userId); var allCourses = _courseRepository.GetAll(); var enrolledCourseIds = _enrollmentRepository.GetUserCourseEnrollment(userId); return(allCourses.Where(c => enrolledCourseIds.Contains(c.CourseId)).ToList()); }
public async Task <ChatMessageModel> SendAsync(string message) { var currentDateTimeUtc = _timeService.GetUtc(); var user = _userInfoProvider.Get(); var chatMessage = new ChatMessageModel(message, currentDateTimeUtc, user); await _chatMessageStorage.PushAsync(chatMessage); await _notificationService.PushAsync(chatMessage); return(chatMessage); }
public async Task <ActionResult> Register(RegisterWithConsentViewModel model) { // Validates the received user data based on the view model if (!ModelState.IsValid) { model.ConsentShortText = consent.GetConsentText("en-US").ShortText; return(View("RegisterWithConsent", model)); } // Prepares a new user entity using the posted registration data Kentico.Membership.User user = new User { UserName = model.UserName, Email = model.Email, FirstName = model.FirstName, LastName = model.LastName, Enabled = true // Enables the new user directly }; // Attempts to create the user in the Kentico database IdentityResult registerResult = IdentityResult.Failed(); try { registerResult = await KenticoUserManager.CreateAsync(user, model.Password); } catch (Exception ex) { // Logs an error into the Kentico event log if the creation of the user fails eventLogService.LogException("MvcApplication", "UserRegistration", ex); ModelState.AddModelError(String.Empty, "Registration failed"); } // If the registration was not successful, displays the registration form with an error message if (!registerResult.Succeeded) { foreach (string error in registerResult.Errors) { ModelState.AddModelError(String.Empty, error); } model.ConsentShortText = consent.GetConsentText("en-US").ShortText; return(View("RegisterWithConsent", model)); } // Creates a consent agreement if the consent checkbox was selected in the registration form if (model.ConsentIsAgreed) { // Gets the current contact var currentContact = ContactManagementContext.GetCurrentContact(); // Creates an agreement for the specified consent and contact // Passes the UserInfo object of the new user as a parameter, which is used to map the user's values // to a new contact in cases where the contact parameter is null, // e.g. for visitors who have not given an agreement with the site's tracking consent. formConsentAgreementService.Agree(currentContact, consent, userInfoProvider.Get(user.Id)); } // If the registration was successful, signs in the user and redirects to a different action await KenticoSignInManager.SignInAsync(user, true, false); return(RedirectToAction("Index", "Home")); }
public UserInfo GetUser(int UserID) { return(_userInfoProvider.Get(UserID)); }