public async Task <ActionResult <Request> > SetStatusReview(int id) { var request = await _context.Request.FindAsync(id); if (request == null) { return(NotFound()); } request.Status = "Review"; _context.SaveChanges(); return(Ok()); }
//Recalculate the total in the Request private bool RecalculateRequestTotal(int requestId) { var request = _context.Request.SingleOrDefault(r => r.Id == requestId); if (request == null) { return(false); } request.Total = _context.RequestLine .Include(l => l.Product) .Where(l => l.RequestId == requestId) .Sum(l => l.Quantity * l.Product.Price); if (request.Status == "Review") { request.Status = "Revised"; } _context.SaveChanges(); return(true); }