public static bool SavePersonalInfo(PersonalInfoVM model, ProviderMember aMember) { // save username and bio. everything else is saved asynchronously through other methods aMember.Bio = model.Bio; aMember.Save(); if (string.IsNullOrWhiteSpace(model.UserName)) { // If someone blanked out their username then delete it. // Otherwise it was just blank so do nothing. if (aMember.UserNames.Count > 0) { aMember.UserNames[0].Delete(); } } else { // If the user name was not blank then create it ProviderUserName userName; if (aMember.UserNames.Count > 0) { userName = aMember.UserNames[0]; } else { userName = new ProviderUserName(); userName.MemberId = aMember.Id.Value; userName.CreateDate = DateTime.UtcNow; } userName.EditDate = DateTime.UtcNow; userName.UserName = model.UserName; userName.Save(); } return true; }
public static bool Save(RegisterVM model, ref ProviderMember registerMember) { registerMember.Password = model.Password; registerMember.CreateDate = DateTime.UtcNow; registerMember.EditDate = DateTime.UtcNow; registerMember.Save(); if (!string.IsNullOrWhiteSpace(model.Email)) { ProviderEmail anEmail = new ProviderEmail(); anEmail.MemberId = registerMember.Id.Value; anEmail.IsValidated = false; anEmail.CreateDate = DateTime.UtcNow; anEmail.EditDate = DateTime.UtcNow; anEmail.Email = new MailAddress(model.Email); anEmail.Save(); } if(!string.IsNullOrWhiteSpace(model.UserName)) { ProviderUserName aUserName = new ProviderUserName(); aUserName.MemberId = registerMember.Id.Value; aUserName.CreateDate = DateTime.UtcNow; aUserName.EditDate = DateTime.UtcNow; aUserName.UserName = model.UserName; aUserName.Save(); } return true; }