Пример #1
0
        public async Task <IActionResult> PutYouItem(long id, YouItem youItem)
        {
            if (id != youItem.Id)
            {
                return(BadRequest());
            }

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

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

            return(NoContent());
        }
Пример #2
0
        public async Task <ActionResult <YouItem> > PostYouItem(YouItem youItem)
        {
            _context.YouItem.Add(youItem);
            await _context.SaveChangesAsync();

            return(CreatedAtAction(nameof(GetYouItem), new { id = youItem.Id }, youItem));
            // return CreatedAtAction("GetYouItem", new { id = youItem.Id }, youItem);
        }