예제 #1
0
        public async Task <ActionResult <FilmsItem> > PostFilmsItem(FilmsItem filmsItem)
        {
            _context.filmsItems.Add(filmsItem);
            await _context.SaveChangesAsync();

            return(CreatedAtAction(nameof(GetFilmsItem), new { id = filmsItem.Id }, filmsItem));
        }
예제 #2
0
        public async Task <IActionResult> PutFilmsItem(int id, FilmsItem filmsItem)
        {
            if (id != filmsItem.Id)
            {
                return(BadRequest());
            }

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

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

            return(NoContent());
        }