Exemplo n.º 1
0
        public ActionResult Create(GigsFormViewModel viewModel)
        {
            if (!ModelState.IsValid)
            {
                viewModel.Genres = _applicationDbContext.Genres.ToList();
                return(View("GigForm", viewModel));
            }

            var gig = new Gig
            {
                ArtistId = User.Identity.GetUserId(),
                DateTime = viewModel.GetDateTime(),
                GenreId  = viewModel.Genre,
                Venue    = viewModel.Vanue
            };

            _applicationDbContext.Gigs.Add(gig);
            gig.Notify();
            _applicationDbContext.SaveChanges();

            return(RedirectToAction("Mine", "Gigs"));
        }