Esempio n. 1
0
        public ActionResult Create(GigFormViewModel viewModel)
        {
            var a = User.Identity.GetUserId();

            if (!ModelState.IsValid)
            {
                viewModel.Genres = _unitOfWork.GenreRepository.GetGenres();
                return(View("GigForm", viewModel));
            }

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



            _unitOfWork.GigsRepository.AddGigToRepostory(gig);
            _unitOfWork.Complete();

            return(RedirectToAction("Mine", "Gigs"));
        }
Esempio n. 2
0
        public ActionResult Update(GigFormViewModel viewModel)
        {
            if (!ModelState.IsValid)
            {
                viewModel.Genres = _unitOfWork.GenreRepository.GetGenres();
                return(View("GigForm", viewModel));
            }

            var gigInDb = _unitOfWork.GigsRepository.GetGigWithAttendees(viewModel.Id);

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

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



            gigInDb.Modify(viewModel.ToDateTime(), viewModel.Venue, viewModel.Genre);

            _unitOfWork.Complete();

            return(RedirectToAction("Mine", "Gigs"));
        }
Esempio n. 3
0
        public ActionResult Update(GigFormViewModel model)
        {
            if (!ModelState.IsValid)
            {
                model.Genres = _context.Genres.ToList();
                return(View("GigForm", model));
            }

            var userId = User.Identity.GetUserId();
            var gig    = _context.Gigs.Single(g => g.Id == model.Id && g.ArtistId == userId);

            gig.Venue    = model.Venue;
            gig.DateTime = model.ToDateTime();
            gig.GenreId  = model.Genre;

            _context.SaveChanges();

            return(RedirectToAction("Mine", "Gigs"));
        }
Esempio n. 4
0
        public ActionResult Create(GigFormViewModel model)
        {
            if (!ModelState.IsValid)
            {
                model.Genres = _context.Genres.ToList();
                return(View("GigForm", model));
            }

            var newGig = new Gig
            {
                Venue    = model.Venue,
                ArtistId = User.Identity.GetUserId(),
                GenreId  = model.Genre,
                DateTime = model.ToDateTime()
            };

            _context.Gigs.Add(newGig);
            _context.SaveChanges();

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