public ActionResult Create(GigFormViewModel viewModel) { if (!ModelState.IsValid) { viewModel.Genres = _genreRepository.GetAllGenres(); return(View("GigForm", viewModel)); } var gig = new Gig { ArtistId = User.Identity.GetUserId(), DateTime = viewModel.GetDateTime(), GenreId = viewModel.Genre, Venue = viewModel.Venue, }; _gigRepository.AddGig(gig); _unitOfWork.Complete(); return(RedirectToAction("Mine", "Gigs")); }
public ActionResult Create(GigFormViewModel model) { if (ModelState.IsValid) { Gig gig = new Gig(); gig.ArtistId = User.Identity.GetUserId(); gig.DateTime = model.GetDateTime(); gig.GenreId = model.Genre; gig.Venue = model.Venue; gigRepository.AddGig(gig); return(RedirectToAction("Mine", "Gigs")); } else { model.Genres = genreRepository.GetAllGenres(); return(View("GigForm", model)); } }