public virtual ActionResult SetBoardGameGeekUser(BoardGameGeekIntegrationModel model, ApplicationUser currentUser) { var parentViewModel = GetBaseManageAccountViewModel(); parentViewModel.BoardGameGeekIntegrationModel = model; if (ModelState.IsValid) { var bggResponse = _boardGameGeekApiClient.GetUserDetails(model.BoardGameGeekUserName); if (bggResponse == null) { ModelState.AddModelError("BoardGameGeekUserName", "The user name given doesn't exist on BoardGameGeek"); } else { try { var saverResult = _boardGameGeekUserSaver.CreateUserDefintion( new CreateBoardGameGeekUserDefinitionRequest() { Avatar = bggResponse.Avatar, Name = bggResponse.Name, BoardGameGeekUserId = bggResponse.UserId }, currentUser); if (saverResult != null) { return RedirectToAction(MVC.Account.ActionNames.Manage, new { Message = ManageMessageId.SetBoardGameGeekUserSuccess }); } } catch (ArgumentException argumentException) { ModelState.AddModelError(nameof(model.BoardGameGeekUserName), argumentException.Message); } } } SetViewBag(); return View(MVC.Account.Views.Manage, parentViewModel); }
public ManageAccountViewModel() { BoardGameGeekIntegrationModel = new BoardGameGeekIntegrationModel(); }