/// <summary> /// Initializes a new reservation for the user /// </summary> /// <param name="userId">Id of the user</param> /// <param name="projectionId">Id of the specific projection </param> /// <returns>the new reservation</returns> public static Reservation AddNewReservation(string userId, int projectionId) { Projection projection = context.Projections.Find(projectionId); if (projection != null) { string city = context.Cinemas.Find(projection.CinemaId).City; string cinema = context.Cinemas.Find(projection.CinemaId).Name; string movie = OmdbAdapters.GetMovieInfo(projection.ImdbId).Title; Reservation reservation = new Reservation() { Projection = projection, ProjectionId = projectionId, StatusType = Reservation.Status.InProcess, UserId = userId, TimeStamp = DateTime.Now, ProjectionDateTime = projection.Date, ProjectionCity = city, ProjectionCinema = cinema, ProjectionMovie = movie }; context.Reservations.Add(reservation); context.SaveChanges(); return(reservation); } return(null); }
public ActionResult Create([Bind(Include = "CinemaId,Name,Address,Latitude,Longitude,PhoneNumber,Region,Province,City,State")] Cinema cinema) { if (ModelState.IsValid) { db.Cinemas.Add(cinema); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(cinema)); }
public ActionResult Create([Bind(Include = "ProjectionId,CinemaId,ImdbId,Date,FreeSeats")] Projection projection) { if (ModelState.IsValid) { db.Projections.Add(projection); db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.CinemaId = new SelectList(db.Cinemas, "CinemaId", "Name", projection.CinemaId); ViewBag.ImdbId = new SelectList(db.Movies, "ImdbId", "Title", projection.ImdbId); return(View(projection)); }
public ActionResult Create([Bind(Include = "ImdbId")] Movie movieId) { Movie movie = OmdbAdapters.GetMovieInfo(movieId.ImdbId); movie.ImdbId = movieId.ImdbId; if (ModelState.IsValid) { db.Movies.Add(movie); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(movie)); }
/// <summary> /// Adds a genre to the list of preferred genres associated to /// a user /// </summary> /// <param name="userId">id of the user on whose profile is adding the genre</param> /// <param name="genreId"> id of the genre to add</param> public static void AddGenre(string userId, int genreId) { FavoriteGenres profile = RetrieveGenresFavorites(userId); if (profile.Genres == null) { profile.Genres = new List <Genre>(); } Genre genre = context.Genres.Find(genreId); if (genre != null) { if (!profile.Genres.Contains(genre)) { profile.Genres.Add(genre); } } context.SaveChanges(); }
public ActionResult addProjectionsForDay([Bind(Include = "StartDate,EndDate")] DateRangeInputModel dateRange) { MovieBotContext context = new MovieBotContext(); foreach (var date in DatabaseAdapter.EachDay(dateRange.StartDate, dateRange.EndDate)) { IEnumerable <Movie> movies = context.Movies.ToList(); IEnumerable <Cinema> cinemas = context.Cinemas.ToList(); IEnumerable <CinemaProjections> cprojections = getDummyCinemaProjections(movies, cinemas, date); cprojections.ToList <CinemaProjections>().ForEach( c => c.MovieProjections.ToList().ForEach( m => m.Projections.ToList().ForEach( p => context.Projections.Add(p) ) ) ); } context.SaveChanges(); return(View()); }