public ActionResult UpdateUsername(CommentingUserAccountModel model) { if (ModelState.IsValid) { _commentInfoUiService.Save(model); model.Message = _stringResourceProvider.GetValue("Commenting App - Username successfully updated.", "Username successfully updated."); } else { model.Message = _stringResourceProvider.GetValue("Commenting App - Please ensure to fill out the usename.", "Please ensure to fill out the usename."); } TempData["message"] = model.Message; return(_uniquePageService.RedirectTo <UserAccountPage>()); }
public ActionResult Username() { var user = CurrentRequestData.CurrentUser; var commentsUserInfo = user.GetCommentsInfo(); if (!string.IsNullOrWhiteSpace(commentsUserInfo.Username)) { var model = new CommentingUserAccountModel { Id = commentsUserInfo.Id, Username = commentsUserInfo.Username }; ModelState.Clear(); return(View(model)); } return(View(new CommentingUserAccountModel())); }
public void Save(CommentingUserAccountModel model) { var currentUser = CurrentRequestData.CurrentUser; CommentsInfo commentsInfo; if (currentUser.Get <CommentsInfo>() != null) { commentsInfo = currentUser.Get <CommentsInfo>(); } else { commentsInfo = new CommentsInfo { User = currentUser }; _userProfileDataService.Add(commentsInfo); } _session.Transact(session => { commentsInfo.Username = model.Username; session.SaveOrUpdate(commentsInfo); }); }