[ProducesResponseType(500)] //Error in the repo public ActionResult AddCartLine(long orderId, CartLine record) { if (record == null || orderId != record.OrderId || !ModelState.IsValid) { return(BadRequest()); } record.OrderId = orderId; _repo.Context.OrderId = orderId; _repo.Add(record); return(Ok()); }
public void ShouldAddAnItemToShoppingCart() { Context.OrderId = 1; var item = new CartLine() { ProductId = 3, Quantity = 1, OrderId = 1 }; _cartLineRepo.Add(item); var shoppingCartRecords = _cartLineRepo.GetCartLinesByOrder(Context.OrderId).ToList(); Assert.Equal(3, shoppingCartRecords.Count); Assert.Equal(2, shoppingCartRecords[0].ProductId); Assert.Equal(4, shoppingCartRecords[0].Quantity); Assert.Equal(1, shoppingCartRecords[1].ProductId); Assert.Equal(3, shoppingCartRecords[1].Quantity); Assert.Equal(3, shoppingCartRecords[2].ProductId); Assert.Equal(1, shoppingCartRecords[2].Quantity); }