Esempio n. 1
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;
         }
     }
     //var requests = await _context.RequestLines.Where(r => r.ProductId == id).ToListAsync();
     //foreach (var r in requests) {
     //    RequestLinesController.CalculateTotal(r.RequestId);
     //}
     return(NoContent());
 }
Esempio n. 2
0
 public async Task <IActionResult> PutRequestLine(int id, RequestLine requestline)
 {
     if (id != requestline.Id)
     {
         return(BadRequest());
     }
     _context.Entry(requestline).State = EntityState.Modified;
     try {
         await _context.SaveChangesAsync();
     } catch (DbUpdateConcurrencyException) {
         if (!RequestLineExists(id))
         {
             return(NotFound());
         }
         else
         {
             throw;
         }
     }
     CalculateTotal(requestline.RequestId);
     return(NoContent());
 }
Esempio n. 3
0
        public async Task <IActionResult> PutUser(int id, User user)
        {
            if (id != user.Id)
            {
                return(BadRequest());
            }

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

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

            return(NoContent());
        }