Esempio n. 1
0
        public async Task <IActionResult> PutWishCategory([FromRoute] int id, [FromBody] WishCategory wishCategory)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != wishCategory.Id)
            {
                return(BadRequest());
            }

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

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

            return(NoContent());
        }
Esempio n. 2
0
        public async Task <IActionResult> PostWishCategory([FromBody] WishCategory wishCategory)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            _context.WishCategory.Add(wishCategory);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetWishCategory", new { id = wishCategory.Id }, wishCategory));
        }