示例#1
0
        public ActionResult Update(GigForViewModel viewModel)
        {
            if (!ModelState.IsValid)
            {
                viewModel.Genres = new ApplicationDbContext().Genres.ToList();
                return(View("GigForm", viewModel));
            }

            var gig = _unitOfWork.Gigs.GetGigWithAttendace(viewModel.Id);

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

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

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

            _unitOfWork.Complete();

            return(RedirectToAction("Mine", "Gig"));
        }
示例#2
0
        public ActionResult Create(GigForViewModel viewModel)
        {
            if (!ModelState.IsValid)
            {
                viewModel.Genres = _unitOfWork.Genres.GetGenres();
                return(View("GigForm", viewModel));
            }

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

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

            //gig.Artist = _unitOfWork.Users.GetArtistById(userId);
            //gig.Artist.Followers = (ICollection<Relationship>) _unitOfWork.Relationships.GetFollowers(userId);

            gig.NotifyForANewGig(_unitOfWork.Relationships.GetFollowers(userId));

            _unitOfWork.Complete();

            return(RedirectToAction("Mine", "Gig"));
        }
示例#3
0
        public ActionResult Edit(int id)
        {
            var gig = _unitOfWork.Gigs.GetGig(id);

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

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

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

            return(View("GigForm", gigViewModel));
        }
示例#4
0
        public ActionResult GigForm()
        {
            var viewModel = new GigForViewModel
            {
                Genres  = _unitOfWork.Genres.GetGenres(),
                Heading = "Add a Gig",
            };

            return(View(viewModel));
        }