public ActionResult ChangeDisplayName(DisplayNameModel model) { if (ModelState.IsValid) { // Attempt to manage the user try { this.accountService.ChangeName(model.DisplayName); this.ViewBag.StatusMessage = "Изменения успешно сохранены"; var cookie = this.Request.Cookies[FormsAuthentication.FormsCookieName].Value; var ticket = FormsAuthentication.Decrypt(cookie); SetFormsAuthentication( ticket.Version, model.DisplayName, ticket.IssueDate, ticket.Expiration, ticket.IsPersistent, ticket.UserData); } catch (Exception e) { ModelState.AddModelError( "Exception", string.Format("Не удалось сохранить изменения: {0}", e.Message)); } } // If we got this far, something failed, redisplay form return(View(model)); }
public ActionResult ChangeDisplayName() { var user = this.principalProvider.Principal; var viewModel = new DisplayNameModel { DisplayName = user.Name }; return(this.View(viewModel)); }
public ActionResult Play(int id = -1) { if (id < 0 || !GameRepository.Instance.Exists(id) || !GameRepository.Instance.IsParticipant(id, User.Identity.Name)) { return(RedirectToAction($"ChooseGameTable", $"Game")); } User user = UserRepository.Instance.Get().FirstOrDefault(x => x.Value.Identifier == User.Identity.Name).Value; DisplayNameModel model = new DisplayNameModel { TableIdentifier = id, DisplayUser = user, ColorMeeplePath = GetUserMeeplePath(id) }; return(View(model)); }