public async Task <IActionResult> PutMyLocationAPI(int id, MyLocationAPI myLocationAPI)
        {
            if (id != myLocationAPI.UserId)
            {
                return(BadRequest());
            }

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

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

            return(NoContent());
        }
Ejemplo n.º 2
0
        public async Task <ActionResult <Product> > UpdateProduct(Product product)
        {
            _context.Entry(product).State = EntityState.Modified;
            await _context.SaveChangesAsync();

            return(NoContent());
        }
        public async Task <IActionResult> Update(long id, Product product)
        {
            if (id != product.Id)
            {
                return(BadRequest());
            }

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

            return(NoContent());
        }
        public async Task <IActionResult> Update(int id, Product product)
        {
            if (id != product.Id)
            {
                return(BadRequest());
            }

            var prod = _context.Products.First(p => p.Id == product.Id);

            _context.Entry(prod).CurrentValues.SetValues(product);
            await _context.SaveChangesAsync();

            return(NoContent());
        }
Ejemplo n.º 5
0
        public async Task <bool> SetFulfilled(int id)
        {
            bool  isFulfilled = false;
            Order order       = await GetOrderById(id).FirstOrDefaultAsync();

            if (order != null)
            {
                order.OrderFulfilled        = DateTime.UtcNow;
                _context.Entry(order).State = EntityState.Modified;
                await _context.SaveChangesAsync();

                isFulfilled = true;
            }

            return(isFulfilled);
        }
Ejemplo n.º 6
0
        public async Task <IActionResult> Update(long id, Product product)
        {
            if (id != product.Id)
            {
                return(BadRequest());
            }
            _context.Entry(product).State = EntityState.Modified;
            // 上面一句等同于这个
            // product.Name = productIn.Name;
            // product.Price = productIn.Price;
            await _context.SaveChangesAsync();

            // return Ok("");
            // return CreatedAtAction(nameof(Update), "ok");
            return(Content("ok"));
        }