Beispiel #1
0
        private void CreateDataAboutFilm(int id)
        {
            //Информация о выбранном дне сохраняется в HttpContext.Items["CurrentDay"]
            //По умолчанию равен дате сегодня
            var timeNow    = DateTime.Now;
            var currentDay = timeNow.Date; //new DateTime(timeNow.Year,timeNow.Month, timeNow.Day);

            if (Request.Query.ContainsKey("schedule_date"))
            {
                currentDay = DateTime.ParseExact(
                    Request.Query["schedule_date"],
                    "dd.MM.yyyy", CultureInfo.InvariantCulture);
            }
            HttpContext.Items["CurrentDay"] = currentDay;

            var film = FilmViewModelDAO.GetFilms($"WHERE id = {id}", false).FirstOrDefault();

            FilmViewModel = film;

            FilmViewModel.Actors    = FilmViewModelDAO.GetActorsByFilmId(FilmViewModel.Id);
            FilmViewModel.Producers = FilmViewModelDAO.GetProducersByFilmId(FilmViewModel.Id);
            FilmViewModel.Country   = FilmViewModelDAO.GetCounrtyById(FilmViewModel.CountryId);
            FilmViewModel.Reviews   = FilmViewModelDAO.GetReviewByFilmId(FilmViewModel.Id);
            FilmViewModel.Schedule  = ScheduleDAO.GetSchedule($"id_movie={id} AND date::DATE = '{currentDay:yyyy-MM-dd}'");
        }
Beispiel #2
0
 public IActionResult OnPost(int id, string review, int rating)
 {
     CreateDataAboutFilm(id);
     if (_authService.IsAuthenticated)
     {
         var userId        = _authService.Id;
         var sqlExpression = string.Format("INSERT INTO reviews(id_movie, author, text, raiting) VALUES({0}, {1}, '{2}', {3})",
                                           id, userId, review, rating);
         DAOFactory.AddData(sqlExpression);
         FilmViewModel.Reviews = FilmViewModelDAO.GetReviewByFilmId(id);
     }
     return(Page());
 }