예제 #1
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"));
        }