public void AddMovie(Movie_GenreTheaterDTO model) { var intervals = new List<TimeInterval>(); foreach (string item in model.TimeIntervalsId) { var currentId = Int32.Parse(item); var tempInterval = _timeIntervalRepository.GetById(currentId); intervals.Add(tempInterval); } Movie movie = new Movie() { Title = model.Movie.Title, PictureUrl = model.Movie.PictureUrl, Description = model.Movie.Description, StartingDate = model.Movie.StartingDate, EndingDate = model.Movie.EndingDate, Theater = _theaterRepository.GetById(model.TheaterId), Genre = _genreRepository.GetById(model.GenreId), TimeIntervals = intervals }; _movieRepository.Add(movie); _movieRepository.Save(); }
public ActionResult AddMovie(Movie_GenreTheaterDTO model) { if (ModelState.IsValid) { _movieService.AddMovie(model); return RedirectToAction("Index", "Home", new {area = ""}); } return View(model); }
public ActionResult AddMovie() { Movie_GenreTheaterDTO model = new Movie_GenreTheaterDTO() { Movie = new Movie(), Genres = _genreService.GetAllGenres().Select(x => new SelectListItem() { Text = x.Description, Value = x.Id.ToString() }).ToList(), Theater = _theaterService.GetAllTheaters().Select(x => new SelectListItem() { Text = x.Name, Value = x.Id.ToString() }).ToList(), TimesList = _timeIntervalRepository.GetAll(), TimeIntervals = _timeIntervalRepository.GetAll() }; return View(model); }