Пример #1
0
 public ActionResult ChangeName([Bind(Include = "Id,NewName")] ChangeNameViewModel viewModel)
 {
     if (ModelState.IsValid)
     {
         viewModel.NewName = viewModel.NewName.Trim();
         ApplicationUser user   = userRepository.GetUser(User.Identity.GetUserId());
         Island          island = islandRepository.GetIsland(viewModel.Id);
         if (island != null && island.Property.Player.Id == user.Id)
         {
             if (island.ChangeName(viewModel.NewName))
             {
                 viewModel.NameUsed = true;
                 return(View(viewModel));
             }
             gameRepository.Save();
             return(RedirectToAction("Island", new { id = viewModel.Id }));
         }
     }
     return(View(viewModel));
 }