(Sorry if all of these questions are stupid)
I have two methods in the controller
[HttpGet]
[Authorize]
public ActionResult Pokemon(int id)
{
var user = db.PDCUsers
.SingleOrDefault(x => x.Username == User.Identity.Name);
var pkmn = db.PlayerPkmns.SingleOrDefault(x => x.Id == id);
return View(new DetailedPokemonViewModel(pkmn, user.Id, user.StepsIncMult));
}
and
[HttpPost]
[ChildActionOnly]
[Authorize]
public ActionResult Pokemon(int id, int steps)
{
var user = db.PDCUsers.SingleOrDefault(x => x.Username == User.Identity.Name);
var pkmn = db.PlayerPkmns.SingleOrDefault(x => x.Id == id);
if (pkmn.CurrentTrainerId == user.Id)
{
pkmn.Experience = pkmn.Experience + steps;
db.SaveChanges();
}
return Pokemon(id);
}
I call Pokemon(int id, int steps)from within the view Pokemon(int id)on
<a href="@Url.Action("Pokemon", "PokemonView", new { id = Model.Id, steps = 5000 })">walk</a>
However, when I click on the link to Pokemon(int id, int steps), it does not update the value of the database - and when I put a breakpoint in it, it does not register. I don't think I even hit the method, but the URL at the top has parameters that are concatenated.
All I am trying to do is update the data row experience value by the number of steps passed as a parameter. I don't want a new view (for now) - I just want it to show the Pokemon view (int id) again.
, , ? , , / ?
:
RedirectToAction Pokemon(int id)
Pokemon(int id, int steps), HTTPget, !
!