public IActionResult AddAiringMovie([FromBody] AddAiringMovieViewModel addAiringMovieViewModel) { var movie = _movieLogic.GetAllMovies().First(m => m.Title.Equals(addAiringMovieViewModel.SelectedMovie)); var returnMessage = ""; DateTime.TryParseExact(addAiringMovieViewModel.SelectedDate, "dd/MM/yyyy", CultureInfo.InvariantCulture, DateTimeStyles.AssumeUniversal, out var date); if (ModelState.IsValid) { var addedAiringMovies = 0; for (var x = 0; x < Convert.ToInt32(addAiringMovieViewModel.AmountOfTimes); x++) { var successful = _movieLogic.TryToAddAiring(movie, date, addAiringMovieViewModel.SelectedRoomType); if (successful) { addedAiringMovies++; } } returnMessage = $"Added {addedAiringMovies} airings for {movie.Title}!"; } return(new JsonResult(new { message = returnMessage })); }
public IActionResult AddAiringMovie() { var movies = _movieLogic.GetAllMovies(); var roomTypes = _movieLogic.GetAllRoomTypes(); var returnModel = new AddAiringMovieViewModel(movies, roomTypes); return(View("AddAiringMovie", returnModel)); }