示例#1
0
        public async Task <ActionResult <Waretype> > PostWaretype(Waretype waretype)
        {
            _context.Waretypes.Add(waretype);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetWaretype", new { id = waretype.Barcode }, waretype));
        }
示例#2
0
        public async Task <IActionResult> PutWaretype(int id, Waretype waretype)
        {
            if (id != waretype.Barcode)
            {
                return(BadRequest());
            }

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

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

            return(NoContent());
        }