Пример #1
0
        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"));
        }
Пример #2
0
        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));
            }
        }