public int removeFromCart(Instrument instrument) { LineOrder lineOr = GetLineOrder(instrument); int localAmount = 0; if (lineOr != null) { if (lineOr.Quantity > 1) { lineOr.Quantity--; localAmount = lineOr.Quantity; } else { _context.LineOrder.Remove(lineOr); } } _context.SaveChanges(); return(localAmount); }
public void addToCart(Instrument instrument, int amount = 1) { LineOrder lineOr = GetLineOrder(instrument); if (lineOr == null) { lineOr = new LineOrder //Order,OrderId no set (link when pay?) { Name = instrument.Name, Quantity = amount, UnitaryPrice = instrument.Price, TotalPrice = instrument.Price, InstrumentId = instrument.Id, Instrument = instrument }; _context.LineOrder.Add(lineOr); //No store on db? volatile LineOrders until Pay? } else { lineOr.Quantity++; } _context.SaveChanges(); //LineOrders.Add(lineOr); }