Exemplo n.º 1
0
        public ActionResult Edit(int id)
        {
            var gigs = _unitOfWork.Gigs.GetGig(id);

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

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

            var viewModel = new GIgFormViewModel()
            {
                Id      = gigs.Id,
                Genres  = new ApplicationDbContext().Genres.ToList(),
                Date    = gigs.DateTime.ToString("d MMM yyyy"),
                Time    = gigs.DateTime.ToString("HH:mm"),
                Venue   = gigs.Venue,
                Genre   = gigs.GenreId,
                Heading = "Edit a Gig"
            };

            return(View("Create", viewModel));
        }
Exemplo n.º 2
0
        public ActionResult Modified(GIgFormViewModel gIgFormViewModel)
        {
            if (!ModelState.IsValid)
            {
                gIgFormViewModel.Genres = _unitOfWork.Genre.GetGenres();
                return(View("Create", gIgFormViewModel));
            }

            var gigs = _unitOfWork.Gigs.GetGigWithAttendees(gIgFormViewModel.Id);

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

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

            gigs.Modify(gIgFormViewModel.GetDateTime(), gIgFormViewModel.Venue, gIgFormViewModel.Genre);

            _unitOfWork.Complete();

            return(RedirectToAction("Mine", "Gigs"));
        }
Exemplo n.º 3
0
        public ActionResult Edit(GIgFormViewModel gIgFormViewModel)
        {
            if (!ModelState.IsValid)
            {
                gIgFormViewModel.Genres = new ApplicationDbContext().Genres.ToList();
                return(View("Create", gIgFormViewModel));
            }

            var user = User.Identity.GetUserId();
            var gig  = _unitOfWork.Gigs.GetGig(gIgFormViewModel.Id);

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

            if (gig.ArtistId != user)
            {
                return(new HttpUnauthorizedResult());
            }

            gig.Venue    = gIgFormViewModel.Venue;
            gig.GenreId  = gIgFormViewModel.Genre;
            gig.DateTime = gIgFormViewModel.GetDateTime();

            _unitOfWork.Complete();

            return(RedirectToAction("Mine", "Gigs"));
        }
Exemplo n.º 4
0
        public ActionResult Create()
        {
            var viewModel = new GIgFormViewModel()
            {
                Genres  = _unitOfWork.Genre.GetGenres(),
                Heading = "Add a Gig"
            };

            return(View(viewModel));
        }
Exemplo n.º 5
0
        public ActionResult Create(GIgFormViewModel gIgFormViewModel)
        {
            if (!ModelState.IsValid)
            {
                gIgFormViewModel.Genres = _unitOfWork.Genre.GetGenres();
                return(View(gIgFormViewModel));
            }
            var gig = new Gig()
            {
                ArtistId = User.Identity.GetUserId(),
                Venue    = gIgFormViewModel.Venue,
                GenreId  = gIgFormViewModel.Genre,
                DateTime = gIgFormViewModel.GetDateTime()
            };

            _unitOfWork.Gigs.AddGig(gig);
            _unitOfWork.Complete();

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