public void CanAddToBasket() { Guid basketId = repo.CreateBasket(); Item item = new Item { ItemName = string.Concat("JayTest", DateTime.Now.ToShortTimeString()), ItemQuantity = 10 }; var result = repo.AddToBasket(basketId, item); Assert.IsNotNull(result); Assert.IsTrue(!result.Items.Count.Equals(0)); }
public IHttpActionResult AddToBasket(Guid basketId, [FromBody] Item item) { if (basketId == Guid.Empty) { return(BadRequest("basketId is not valid")); } if (item == null) { return(BadRequest("item is not valid")); } if (item.ItemId.HasValue) { return(BadRequest("Item has an Id, please update the item instead")); } var currentBasket = repo.AddToBasket(basketId, item); return(Ok(currentBasket)); }