public async Task <ActionResult <Requests> > SetStatusReject(int id, Requests req) { if (id != req.Id) { return(BadRequest()); } _context.Entry(req).State = EntityState.Modified; req.Status = "Reject"; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!RequestsExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <IActionResult> PutRequest(int id, Request request) { if (id != request.Id) { return(BadRequest()); } _context.Entry(request).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!RequestExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <IActionResult> PutRequestLines(int id, RequestLines requestLines) { if (id != requestLines.Id) { return(BadRequest()); } _context.Entry(requestLines).State = EntityState.Modified; try { var success = RecalcuateRequestTotal(requestLines.RequestId); await _context.SaveChangesAsync(); if (!success) { return(this.StatusCode(500)); } } catch (DbUpdateConcurrencyException) { if (!RequestLinesExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public static bool Update(int id, Request request) { if (request == null) { throw new Exception("Request cannot be null."); } if (id != request.Id) { throw new Exception("ID must match Request's."); } context.Entry(request).State = EntityState.Modified; AttemptToSave(); return(true); }
public static bool Update(int id, User user) { if (user == null) { throw new Exception("User cannot be null."); } if (id != user.Id) { throw new Exception("ID must match User's."); } context.Entry(user).State = EntityState.Modified; AttemptToSave(); return(true); }
public static bool Update(int id, Product product) { if (product == null) { throw new Exception("Product cannot be null."); } if (id != product.Id) { throw new Exception("ID must match Product's."); } context.Entry(product).State = EntityState.Modified; AttemptToSave(); return(true); }
public static bool Update(int id, Vendor vendor) { if (vendor == null) { throw new Exception("Vendor cannot be null."); } if (id != vendor.Id) { throw new Exception("ID must match Vendor's."); } context.Entry(vendor).State = EntityState.Modified; AttemptToSave(); return(true); }
public static bool Update(int id, RequestLine requestline) { if (requestline == null) { throw new Exception("RequestLine cannot be null."); } if (id != requestline.Id) { throw new Exception("ID must match RequestLine's."); } context.Entry(requestline).State = EntityState.Modified; requestline.Product = context.Products.Find(requestline.ProductId); RecalcTotal(requestline.RequestId); return(true); }
public async Task <IActionResult> PutRequests(int id, Requests request) { if (id != request.Id) { return(BadRequest()); } _context.Entry(request).State = EntityState.Modified; try { await _context.SaveChangesAsync(); if (request.Status != ReqDen) { await SetStatusReview(id); } if (request.RequestLines.Count() > 0 && request.Status != ReqDen) { request.Status = ReqRev; } if (request.Total < 50 && request.Status != ReqDen) { request.Status = ReqApp; } await Recalc(id); } catch (DbUpdateConcurrencyException) { if (!RequestsExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
private async Task RefreshRequestline(Requestline requestline) { _context.Entry(requestline).State = EntityState.Detached; await _context.Requestline.FindAsync(requestline.Id); }