public async Task <IActionResult> Create([Bind("CineplexId,ImageUrl,Location,LongDescription,ShortDescription")] Cineplex cineplex)
        {
            if (ModelState.IsValid)
            {
                _context.Add(cineplex);
                await _context.SaveChangesAsync();

                return(RedirectToAction("Index"));
            }
            return(View(cineplex));
        }
Exemple #2
0
        // POST http://localhost:40221/Movies/
        public async Task <IHttpActionResult> Post(Movie movie)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }
            db.Movies.Add(movie);
            await db.SaveChangesAsync();

            return(Created(movie));
        }
Exemple #3
0
        public async Task <IActionResult> Create([Bind("ID,Title,ReleaseDate,Genre,Price")] Movie movie)
        {
            if (ModelState.IsValid)
            {
                _context.Add(movie);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(movie));
        }
        public async Task <IActionResult> Create([Bind("MovieComingSoonId,ImageUrl,LongDescription,ShortDescription,Title")] MovieComingSoon movieComingSoon)
        {
            if (ModelState.IsValid)
            {
                _context.Add(movieComingSoon);
                await _context.SaveChangesAsync();

                return(RedirectToAction("Index"));
            }
            return(View(movieComingSoon));
        }
        public async Task <IActionResult> Create([Bind("EnquiryId,Email,Message")] Enquiry enquiry)
        {
            if (ModelState.IsValid)
            {
                _context.Add(enquiry);
                await _context.SaveChangesAsync();

                return(RedirectToAction("Index"));
            }
            return(View(enquiry));
        }
        public async Task <IActionResult> Create([Bind("MovieID,Category,Title,Year,Director,Rating,Edited,LentTo,Notes")] Movies movies)
        {
            if (ModelState.IsValid)
            {
                _context.Add(movies);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(EnteredList)));
            }
            return(View(movies));
        }
Exemple #7
0
        public async Task <IActionResult> Create([Bind("Id,Title,Description,Year,Poster")] Movie movie)
        {
            if (ModelState.IsValid)
            {
                _context.Add(movie);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(movie));
        }
        public async Task <IActionResult> Create([Bind("Id,Name,ReleaseDate,Director,Email,Language,Category")] MovieTble movieTble)
        {
            if (ModelState.IsValid)
            {
                _context.Add(movieTble);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["Category"] = new SelectList(_context.CategoryTble, "Code", "Code", movieTble.Category);
            return(View(movieTble));
        }
        public async Task <IActionResult> Create([Bind("CineplexId,MovieId,SessionId")] CineplexMovie cineplexMovie)
        {
            if (ModelState.IsValid)
            {
                _context.Add(cineplexMovie);
                await _context.SaveChangesAsync();

                return(RedirectToAction("Index"));
            }
            ViewData["CineplexId"] = new SelectList(_context.Cineplex, "CineplexId", "Location", cineplexMovie.CineplexId);
            ViewData["MovieId"]    = new SelectList(_context.Movie, "MovieId", "LongDescription", cineplexMovie.MovieId);
            ViewData["SessionId"]  = new SelectList(_context.SessionMovie, "SessionId", "SessionId", cineplexMovie.SessionId);
            return(View(cineplexMovie));
        }
Exemple #10
0
        public async Task <ActionResult> EditActor(int id, ActorDto actor)
        {
            Actor updateActor = new Actor()
            {
                Id          = id,
                FirstName   = actor.FirstName,
                LastName    = actor.LastName,
                BirthDate   = actor.BirthDate,
                MovieActors = context.MovieActors.Where(ma => ma.ActorId == actor.Id).ToList()
            };

            context.Entry(updateActor).State = EntityState.Modified;
            await context.SaveChangesAsync();

            return(Ok());
        }
Exemple #11
0
        public async Task <Movies> Post(Movies movie)
        {
            _context.Movies.Add(movie);
            await _context.SaveChangesAsync();

            return(movie);
        }
Exemple #12
0
        public async Task <IActionResult> OnPostAsync()
        {
            if (!ModelState.IsValid)
            {
                return(Page());
            }

            _context.Attach(Movie).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!MovieExists(Movie.ID))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(RedirectToPage("./Index"));
        }
Exemple #13
0
        public async Task <Movie> Create(Movie movie)
        {
            var data = new Movie
            {
                Title       = movie.Title,
                Genre       = movie.Genre,
                Cert        = movie.Cert,
                ReleaseDate = movie.ReleaseDate,
                AvgRating   = movie.AvgRating
            };
            await _dbContext.Movies.AddAsync(data);

            await _dbContext.SaveChangesAsync();

            return(data);
        }
        public async Task AddNewMovieRole(MovieRole role)
        {
            var movie = await _moviesContext.Movies.FindAsync(role.MovieId);

            if (movie == null)
            {
                throw new MovieApiException("Invalid movie Id");
            }
            var actor = await _moviesContext.Actors.FindAsync(role.ActorId);

            if (actor == null)
            {
                throw new MovieApiException("Invalid actor Id");
            }

            _moviesContext.MovieRoles.Add(role);
            await _moviesContext.SaveChangesAsync();
        }
        public async Task <IActionResult> PutMovie(long id, Movie movie)
        {
            if (id != movie.ID)
            {
                return(BadRequest());
            }

            if (!MovieExists(id))
            {
                return(NotFound());
            }

            _context.Entry(movie).State = EntityState.Modified;

            await _context.SaveChangesAsync();

            return(Ok(movie));
        }
        public async Task <IActionResult> Add(Movie movie)
        {
            _dbContext.Movies.Add(movie);
            await _dbContext.SaveChangesAsync();

            var movies = await _dbContext.Movies.ToListAsync();

            return(View("Index", movies));
        }
Exemple #17
0
        public async Task <IActionResult> UsersPut(int id, Users item)
        {
            if (id != item.Id)
            {
                return(BadRequest());
            }
            _context.Entry(item).State = EntityState.Modified;
            await _context.SaveChangesAsync();

            return(Content("Users details has been updated. Thank You. How you see you new updated details"));
        }
Exemple #18
0
        // To protect from overposting attacks, please enable the specific properties you want to bind to, for
        // more details see https://aka.ms/RazorPagesCRUD.
        public async Task <IActionResult> OnPostAsync()
        {
            if (!ModelState.IsValid)
            {
                return(Page());
            }

            _context.Movie.Add(Movie);
            await _context.SaveChangesAsync();

            return(RedirectToPage("./Index"));
        }
Exemple #19
0
        public async Task <bool> AddAsync(Movie movie)
        {
            if (movie == null)
            {
                return(false);
            }

            context_.Add(movie);

            await context_.SaveChangesAsync();

            return(true);
        }
Exemple #20
0
        public async Task <ActionResult> Create(MovieEditModel model)
        {
            if (ModelState.IsValid)
            {
                var movie = new Movie()
                {
                    Name           = model.Name,
                    ProductionYear = model.ProductionYear ?? 0,
                    Director       = model.Director,
                    Description    = model.Description
                };

                movie.User = await _userManager.FindByNameAsync(User.Identity.Name);

                if (model.BannerImage != null)
                {
                    using (var stream = new MemoryStream())
                    {
                        model.BannerImage.CopyTo(stream);
                        movie.Banner = stream.ToArray();
                    }
                }

                context.Movies.Add(movie);
                await context.SaveChangesAsync();

                return(Ok());
            }
            else
            {
                ViewData["Title"]     = "Добавление нового фильма";
                ViewData["BannerBtn"] = "Добавить постер";
                ViewData["Action"]    = "Create";
                return(PartialView("_EditPartial", model));
            }
        }
Exemple #21
0
        public async Task <IActionResult> OnPostAsync(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            Movie = await _context.Movie.FindAsync(id);

            if (Movie != null)
            {
                _context.Movie.Remove(Movie);
                await _context.SaveChangesAsync();
            }

            return(RedirectToPage("./Index"));
        }
        public async Task <int> AddRangeMovies(List <Movie> list)
        {
            int count = 0;

            foreach (var movie in list)
            {
                if (await GetMovieWithYearAndTitle(movie.Title, movie.Year) == null)
                {
                    count++;
                    AddNewMovie(movie);
                }
            }

            await _moviesContext.SaveChangesAsync();

            return(count);
        }
        private static async Task <MoviesContext> SetupDatabaseAsync()
        {
            var optionsBuilder = new DbContextOptionsBuilder <MoviesContext>();

            optionsBuilder.UseInMemoryDatabase("databaseName");

            var context = new MoviesContext(optionsBuilder.Options);

            context.Movies.Add(new MovieEntity
            {
                Id       = MovieId,
                Director = Director1,
                Title    = Movie1
            });
            await context.SaveChangesAsync();

            return(context);
        }
Exemple #24
0
        public async Task <IActionResult> DeleteMovie([FromRoute] string name)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            var movie = await _context.Movie.FindAsync(name);

            if (movie == null)
            {
                return(NotFound());
            }

            _context.Movie.Remove(movie);
            await _context.SaveChangesAsync();

            return(Ok(movie));
        }
Exemple #25
0
        public async Task <IActionResult> OnPostAsync()
        {
            // Perform an initial check to catch FileUpload class
            // attribute violations.
            if (!ModelState.IsValid)
            {
                Schedule = await _context.Schedule.AsNoTracking().ToListAsync();

                return(Page());
            }

            var publicScheduleData =
                await FileHelpers.ProcessFormFile(FileUpload.UploadPublicSchedule, ModelState);

            var privateScheduleData =
                await FileHelpers.ProcessFormFile(FileUpload.UploadPrivateSchedule, ModelState);

            // Perform a second check to catch ProcessFormFile method
            // violations.
            if (!ModelState.IsValid)
            {
                Schedule = await _context.Schedule.AsNoTracking().ToListAsync();

                return(Page());
            }

            var schedule = new Schedule()
            {
                PublicSchedule      = publicScheduleData,
                PublicScheduleSize  = FileUpload.UploadPublicSchedule.Length,
                PrivateSchedule     = privateScheduleData,
                PrivateScheduleSize = FileUpload.UploadPrivateSchedule.Length,
                Title    = FileUpload.Title,
                UploadDT = DateTime.UtcNow
            };

            _context.Schedule.Add(schedule);
            await _context.SaveChangesAsync();

            return(RedirectToPage("./Index"));
        }
Exemple #26
0
 public async Task <bool> SaveChangesAsync()
 {
     // return true if 1 or more entities were changed
     return(await _context.SaveChangesAsync() > 0);
 }
Exemple #27
0
 public Task Save()
 {
     return(_context.SaveChangesAsync());
 }
Exemple #28
0
 public async Task <int> SaveChangesAsync()
 {
     return(await _moviesContext.SaveChangesAsync());
 }
Exemple #29
0
 public async Task <bool> SaveChangesAsync()
 {
     return(await _context.SaveChangesAsync() > 0);
 }
Exemple #30
0
 public async Task AddNewActor(Actor actor)
 {
     _moviesContext.Actors.Add(actor);
     await _moviesContext.SaveChangesAsync();
 }