public void Save()
{
using (CarrotCMSDataContext _db = CarrotCMSDataContext.Create()) {
bool bNew = false;
carrot_UserData usr = CompiledQueries.cqFindUserTblByID(_db, this.UserId);
if (usr == null) {
usr = new carrot_UserData();
usr.UserKey = this.UserKey;
usr.UserId = Guid.NewGuid();
bNew = true;
}
usr.UserNickName = this.UserNickName;
usr.FirstName = this.FirstName;
usr.LastName = this.LastName;
usr.UserBio = this.UserBio;
if (bNew) {
_db.carrot_UserDatas.InsertOnSubmit(usr);
}
_db.SubmitChanges();
this.UserId = usr.UserId;
//grab fresh copy from DB
vw_carrot_UserData rc = CompiledQueries.cqFindUserByID(_db, usr.UserId);
LoadUserData(rc);
}
}
private IdentityResult AttemptCreateApplicationUser(ApplicationUser user, string password, out ExtendedUserData newusr) { newusr = null; var result = new IdentityResult(); lock (newUsrLock) { if (user != null && !String.IsNullOrEmpty(user.Id)) { using (var securityHelper = new SecurityHelper()) { result = securityHelper.UserManager.Create(user, password); if (result.Succeeded) { user = securityHelper.UserManager.FindByName(user.UserName); newusr = new ExtendedUserData(); newusr.UserKey = user.Id; newusr.Id = user.Id; newusr.Save(); newusr = ExtendedUserData.FindByUserID(newusr.UserId); } } } } return(result); }