Ejemplo n.º 1
0
        public ActionResult Update(ConcertFormViewModel viewModel)
        {
            if (!ModelState.IsValid)
            {
                viewModel.Genres = _unitOfWork.Genres.GetGenres();
                return(View("ConcertForm", viewModel));
            }

            var concert = _unitOfWork.Concerts.GetConcertWithAttendees(viewModel.Id);

            if (concert == null)
            {
                return(HttpNotFound());
            }

            if (concert.ArtistId != User.Identity.GetUserId())
            {
                return(new HttpUnauthorizedResult());
            }

            concert.Modify(viewModel.GetDateTime(), viewModel.Venue, viewModel.Genre);

            _unitOfWork.Complete();

            return(RedirectToAction("Mine", "Concerts"));
        }
Ejemplo n.º 2
0
        public ActionResult Create(ConcertFormViewModel viewModel)
        {
            if (!ModelState.IsValid)
            {
                viewModel.Genres = _dbContext.Genres.ToList();
                return(View("Create", viewModel));
            }
            var concert = new Concert
            {
                ArtistId = User.Identity.GetUserId(),
                DateTime = viewModel.GetDateTime(),
                GenreId  = viewModel.Genre,
                Venue    = viewModel.Venue
            };

            _dbContext.Concerts.Add(concert);
            _dbContext.SaveChanges();

            return(RedirectToAction("Index", "Home"));
        }
Ejemplo n.º 3
0
        public ActionResult Create(ConcertFormViewModel viewModel)
        {
            if (!ModelState.IsValid)
            {
                viewModel.Genres = _unitOfWork.Genres.GetGenres();
                return(View("ConcertForm", viewModel));
            }

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

            _unitOfWork.Concerts.Add(concert);
            _unitOfWork.Complete();

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