コード例 #1
0
        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());
        }
コード例 #2
0
        public async Task <ActionResult <Product> > UpdateProduct(Product product)
        {
            _context.Entry(product).State = EntityState.Modified;
            await _context.SaveChangesAsync();

            return(NoContent());
        }
コード例 #3
0
        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());
        }
コード例 #4
0
        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());
        }
コード例 #5
0
ファイル: OrderService.cs プロジェクト: kgisme170/mynet
        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);
        }
コード例 #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"));
        }