コード例 #1
0
        public ActionResult Create(GigFormViewModel viewModel)
        {
            if (!ModelState.IsValid)
            {
                viewModel.Heading = "Add a Gig";
                viewModel.Genres  = _unitOfWork.Genres.GetGenres();
                return(View("GigForm", viewModel));
            }

            var artistId = User.Identity.GetUserId();

            var gig = new Gig(artistId, viewModel.Location, viewModel.GetDateTime(), viewModel.GenreId);

            _unitOfWork.Gigs.Add(gig);

            var followers = _unitOfWork.Followings.GetFollowersByArtist(artistId);

            gig.NotifyGigCreation(followers);

            _unitOfWork.Complete();

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