예제 #1
0
        public async Task <IActionResult> PutStore(int id, Store store)
        {
            if (id != store.ID)
            {
                return(BadRequest());
            }

            store.ID = id;

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

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

            return(CreatedAtAction("GetStore", new { id = store.ID }, store));
            //return NoContent();
        }
예제 #2
0
        public async Task <IActionResult> PutProduct(int id, Product product)
        {
            if (id != product.ID)
            {
                return(BadRequest());
            }

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

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!ProductExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }
            return(CreatedAtAction("GetProduct", new { id = product.ID }, product));
            //return NoContent();
        }
        public async Task <IActionResult> PutCustomer(int id, Customer customer)
        {
            if (id != customer.ID)
            {
                return(BadRequest());
            }

            customer.ID = id;

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

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

            return(CreatedAtAction("GetCustomer", new { id = customer.ID }, customer));
            //return NoContent();
        }