public async Task <IActionResult> PutRequestLines(int id, RequestLines requestLines) { if (id != requestLines.Id) { return(BadRequest()); } _context.Entry(requestLines).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!RequestLinesExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <ActionResult <RequestLines> > PostRequestLines(RequestLines requestLines) { _context.RequestLines.Add(requestLines); await _context.SaveChangesAsync(); return(CreatedAtAction("GetRequestLines", new { id = requestLines.Id }, requestLines)); }
public async Task <IActionResult> Edit(int id, [Bind("Id,RequestId,ProductId,Quantity")] RequestLines requestLines) { if (id != requestLines.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(requestLines); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!RequestLinesExists(requestLines.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["ProductId"] = new SelectList(_context.Products, "Id", "Name", requestLines.ProductId); ViewData["RequestId"] = new SelectList(_context.Requests, "Id", "DeliveryMode", requestLines.RequestId); return(View(requestLines)); }
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 Insert(RequestLines requestline) { if (requestline == null) { throw new Exception("Request line cannot be null!"); } context.RequestLines.Add(requestline); RecalcReqTotal(requestline.Id); return(context.SaveChanges() == 1); }
public async Task <IActionResult> Create([Bind("Id,RequestId,ProductId,Quantity")] RequestLines requestLines) { if (ModelState.IsValid) { _context.Add(requestLines); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewData["ProductId"] = new SelectList(_context.Products, "Id", "Name", requestLines.ProductId); ViewData["RequestId"] = new SelectList(_context.Requests, "Id", "DeliveryMode", requestLines.RequestId); return(View(requestLines)); }
public async Task <ActionResult <RequestLines> > PostRequestLines(RequestLines requestLines) { _context.RequestLines.Add(requestLines); await _context.SaveChangesAsync(); /* CALL RECALC */ var success = RecalculateRequestTotal(requestLines.RequestId); if (!success) { return(this.StatusCode(500)); } return(CreatedAtAction("GetRequestLines", new { id = requestLines.Id }, requestLines)); }
public static bool Delete(RequestLines requestline) { if (requestline == null) { throw new Exception("RequestLine not found"); } var dbrequestline = context.RequestLines.Find(requestline.Id); if (dbrequestline == null) { throw new Exception("RequestLine not found"); } context.RequestLines.Remove(dbrequestline); RecalcReqTotal(requestline.Id); return(context.SaveChanges() == 1); }
public static bool Update(RequestLines requestline) { if (requestline == null) { throw new Exception("RequestLine not found"); } var dbrequestline = context.RequestLines.Find(requestline.Id); if (dbrequestline == null) { throw new Exception("RequestLine not found"); } dbrequestline.Id = requestline.Id; dbrequestline.RequestId = requestline.RequestId; dbrequestline.ProductId = requestline.ProductId; dbrequestline.Quantity = requestline.Quantity; RecalcReqTotal(requestline.Id); return(context.SaveChanges() == 1); }