Reputation: 6626
Problem: ModelState is not valid, complaining that there is no Event.
I've tried associating it and done a TryUpdateModel
Inspecting raceViewModel it does look fine.
[HttpPost]
public ActionResult Create(RaceViewModel raceViewModel, Guid idEvent)
{
Event _event = uow.Events.Single(e => e.Id == idEvent);
raceViewModel.RaceInVM.EventU = _event;
TryUpdateModel<RaceViewModel>(raceViewModel);
if (!ModelState.IsValid)
{
SetupDropDownsStronglyTyped(raceViewModel);
return View(raceViewModel);
}
Upvotes: 1
Views: 1008
Reputation: 32094
I think that your idEvent
parameter may not be what you expect it to be. The uow.Events.Single
call then fails and throws an exception (there is no Event
with the provided Id
).
Upvotes: 1