Beispiel #1
0
        public async Task <IActionResult> PutMovie(int id, [FromBody] Movie movie)
        {
            if (!MovieExists(id))
            {
                return(BadRequest());
            }
            movie.ID = id;
            _context.Entry(movie).State = EntityState.Modified;

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

            return(CreatedAtAction("GetMovie", new { id = movie.ID }, movie));
        }
Beispiel #2
0
        public async Task <IActionResult> PutTopRatedMovies1Model(int id, TopRatedMovies1 topRatedMovies1Model)
        {
            if (id != topRatedMovies1Model.id)
            {
                return(BadRequest());
            }

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

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!TopRatedMovies1ModelExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
        public async Task <IActionResult> PutMovie(int id, Movie movie)
        {
            if (id != movie.MovieID)
            {
                return(BadRequest());
            }

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

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

            return(NoContent());
        }
Beispiel #4
0
        public async Task <TEntity> AddAsync(TEntity entity)
        {
            await _dbContext.Set <TEntity>().AddAsync(entity);

            await _dbContext.SaveChangesAsync();

            return(entity);
        }
Beispiel #5
0
        public async Task <CreateLanguageResponse> CreateLanguageAsync(string langCodeDescription)
        {
            var response = new CreateLanguageResponse();

            await _context.Lang.AddAsync(new Lang { LangCode = langCodeDescription });

            response.RowsAffected = await _context.SaveChangesAsync();

            return(response);
        }
Beispiel #6
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));
        }
Beispiel #7
0
 public async Task ApplyChagesAsync()
 {
     await _context.SaveChangesAsync();
 }