string getMailerIdFor(string userId) { if (userId.IsNullOrWhiteSpace()) { return(""); } ApplicationUser user = UserBiz.Find(userId); user.IsNullThrowException("User not found"); user.PersonId.IsNullOrWhiteSpaceThrowException("No person attached to user."); string personId = user.PersonId; Mailer mailer = FindAll().FirstOrDefault(x => x.PersonId == personId); if (mailer.IsNull()) { return(""); } return(mailer.Id); }
public void UpdateUserGeneralSettings(UserIdentity userIdentity, ProfileGeneralSettingsPM generalSettings) { // Update User var user = UserBiz.Find(userIdentity.UserId); user.FirstName = generalSettings.FirstName; user.LastName = generalSettings.LastName; // Update Profile var profileKeyValues = new List <ProfileKeyValue>(); profileKeyValues.Add(new ProfileKeyValue() { Type = ProfileKeyValueType.MobileNumber, Value = string.IsNullOrWhiteSpace(generalSettings.MobileNumber) ? "" : generalSettings.MobileNumber.Trim() }); profileKeyValues.Add(new ProfileKeyValue() { Type = ProfileKeyValueType.WebSiteUrl, Value = string.IsNullOrWhiteSpace(generalSettings.WebSiteUrl) ? "" : generalSettings.WebSiteUrl.Trim() }); profileKeyValues.Add(new ProfileKeyValue() { Type = ProfileKeyValueType.AboutMe, Value = string.IsNullOrWhiteSpace(generalSettings.AboutMe) ? "" : generalSettings.AboutMe.Trim() }); profileKeyValues.Add(new ProfileKeyValue() { Type = ProfileKeyValueType.Sexuality, Value = generalSettings.Sexuality.HasValue ? ((int)generalSettings.Sexuality).ToString() : null }); ProfileBiz.SetUserProfile(userIdentity.UserId, profileKeyValues); UnitOfWork.SaveChanges(); userIdentity.FirstName = user.FirstName; userIdentity.LastName = user.LastName; }
/// <summary> /// This creates and saves a mailer. It makes sure that there is only one created. /// Also, it ensures that deposit/account are taken care of /// </summary> /// <param name="vm"></param> public void CreateAndSaveMailer(CreateMailerVM vm) { //ControllerCreateEditParameter para vm.UserId.IsNullOrWhiteSpaceThrowArgumentException("User is required!"); ApplicationUser user = UserBiz.Find(vm.UserId); user.IsNullThrowException("User not found"); user.PersonId.IsNullOrWhiteSpaceThrowException("No person attached to user"); string personId = user.PersonId; //first check if a mailer exists for the mailer bool mailerExists = FindAll().Any(x => x.PersonId == personId); if (mailerExists) { ErrorsGlobal.Add("Mailer already exists for user!", MethodBase.GetCurrentMethod(), null); string error = ErrorsGlobal.ToString(); throw new Exception(error); } //Make sure user has enough deposit etc to become a mailer //todo ErrorsGlobal.AddMessage("Financial checks need to be done!"); Mailer mailer = new Mailer(); mailer.Name = user.UserName; mailer.PersonId = user.PersonId; mailer.TrustLevelEnum = vm.TrustLevelEnum; //user.Mailers.Add(mailer); //user.MailerId = mailer.Id; CreateAndSave(mailer); ErrorsGlobal.AddMessage(string.Format("Mailer created for {0}", user.UserName)); }
public ApplicationUser GetUser(string userId) { ApplicationUser user = UserBiz.Find(userId); return(user); }