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()); }
private async void RecalcRequestTotal(int requestId) { var request = _context.Request.Find(requestId); request.Total = _context.RequestLine.Include(l => l.Product) .Where(l => l.RequestId == requestId) .Sum(l => l.Quantity * l.Product.Price); // request.Total = request.RequestLines.Sum(x => x.Quantity * x.Product.Price); await _context.SaveChangesAsync(); }