Example #1
0
        public async Task <IActionResult> Create([Bind("Id,Username,Rating,MovieId")] MovieRatingModel movieRatingModel)
        {
            if (string.IsNullOrWhiteSpace(movieRatingModel.Username))
            {
                movieRatingModel.Username = "******";
            }
            movieRatingModel.MovieId = _contextService.GetCurrentContext();

            if (ModelState.IsValid)
            {
                movieRatingModel.Id = Guid.NewGuid();
                _context.Add(movieRatingModel);
                await _context.SaveChangesAsync();

                return(RedirectToAction("Details", "Movie", _contextService.GetCurrentContext()));
            }
            return(View(movieRatingModel));
        }
 public async Task <ActionResult> AddReviewer(Reviewer model)
 {
     if (ModelState.IsValid)
     {
         Reviewer reviewer = new Reviewer
         {
             Name = model.Name,
             Age  = model.Age
         };
         _context.Add(reviewer);
         await _context.SaveChangesAsync();
     }
     else
     {
         return(View("Index"));
     }
     return(RedirectToAction("Index", "Home"));
 }
 public async Task <ActionResult> AddMovie(Movie model)
 {
     if (ModelState.IsValid)
     {
         Movie movie = new Movie
         {
             Title       = model.Title,
             Genre       = model.Genre,
             ReleaseDate = model.ReleaseDate
         };
         _context.Add(movie);
         await _context.SaveChangesAsync();
     }
     else
     {
         return(View("Index"));
     }
     return(RedirectToAction("Index", "Home"));
 }
 public async Task <ActionResult> AddRating(Rating model)
 {
     if (ModelState.IsValid)
     {
         Rating rating = new Rating
         {
             MovieId       = model.MovieId,
             ReviewerId    = model.ReviewerId,
             RatingStar    = model.RatingStar,
             ReviewComment = model.ReviewComment
         };
         _context.Add(rating);
         await _context.SaveChangesAsync();
     }
     else
     {
         return(View("Index"));
     }
     return(RedirectToAction("Index", "Home"));
 }