public ActionResult Update(GigFormViewModel viewModel) { if (!ModelState.IsValid) { viewModel.Genres = _genreRepository.GetAllGenres(); return(View("GigForm", viewModel)); } var gig = _gigRepository.GetGigWithAttendees(viewModel.Id); if (gig == null) { return(HttpNotFound()); } if (gig.ArtistId != User.Identity.GetUserId()) { return(new HttpUnauthorizedResult()); } gig.Update(viewModel.GetDateTime(), viewModel.Venue, viewModel.Genre); _unitOfWork.Complete(); return(RedirectToAction("Mine", "Gigs")); }
public ActionResult Update(GigFormViewModel model) { if (ModelState.IsValid) { Gig gig = gigRepository.GetGigWithAttendees(model.Id); if (gig == null) { return(HttpNotFound()); } if (gig.ArtistId != User.Identity.GetUserId()) { return(new HttpUnauthorizedResult()); } gig.Modify(model, gig); gigRepository.UpdateGig(gig); return(RedirectToAction("Mine", "Gigs")); } else { model.Genres = genreRepository.GetAllGenres(); return(View("GigForm", model)); } }