public async Task <IActionResult> PutOrderline2177(int id, Orderline2177 orderline2177) { if (id != orderline2177.Orderid) { return(BadRequest()); } _context.Entry(orderline2177).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!Orderline2177Exists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <int> DeleteOrderline2177(Orderline2177 ol) { // var orderline2177 = await _context.Orderline2177.FindAsync(id); var order = await _context.Database.ExecuteSqlRawAsync("EXEC REMOVE_PRODUCT_FROM_ORDER " + "@PORDERID = " + ol.Orderid + ", @PPRODIID = " + ol.Productid); /* * if (order == null) * { * return NotFound(); * }*/ if (order == 0) { return(-1); } // _context.Orderline2177.Remove(orderline2177); // await _context.SaveChangesAsync(); return(1); }
public async Task <ActionResult <Orderline2177> > PostOrderline2177(Orderline2177 ol) { // _context.Orderline2177.Add(ol); try { await _context.Database.ExecuteSqlRawAsync("EXEC ADD_PRODUCT_TO_ORDER @PORDERID = " + ol.Orderid + ", @PPRODIID = " + ol.Productid + ", @PQTY = " + ol.Quantity + ", @DISCOUNT = " + ol.Discount); } catch (DbUpdateException) { if (Orderline2177Exists(ol.Orderid)) { return(Conflict()); } else { throw; } } return(CreatedAtAction("GetOrderline2177", new { id = ol.Orderid }, ol)); }