示例#1
0
        public async Task <IActionResult> PutSparePartsCatalog(string id, SparePartsCatalog sparePartsCatalog)
        {
            if (id != sparePartsCatalog.NumPart)
            {
                return(BadRequest());
            }

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

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

            return(NoContent());
        }
示例#2
0
        public async Task <ActionResult <SparePartsCatalog> > PostSparePartsCatalog(SparePartsCatalog sparePartsCatalog)
        {
            _context.SparePartsCatalogs.Add(sparePartsCatalog);
            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateException)
            {
                if (SparePartsCatalogExists(sparePartsCatalog.NumPart))
                {
                    return(Conflict());
                }
                else
                {
                    throw;
                }
            }

            return(CreatedAtAction("GetSparePartsCatalog", new { id = sparePartsCatalog.NumPart }, sparePartsCatalog));
        }