public IHttpActionResult GetBasket(string id) { var sessionBasket = BasketInMemorySorage.GetBasket(id); if (sessionBasket == null) { return(NotFound()); } return(Ok(sessionBasket)); }
public IHttpActionResult AddItemToBasket(BasketItemModel item) { try { var sessionBasket = BasketInMemorySorage.GetBasket(item.BasketId); var basket = MapBasketFromModel(sessionBasket); basket.AddItem(MapBasketItemModel(item)); sessionBasket = BasketInMemorySorage.UpdateBasket(item.BasketId, sessionBasket); return(Ok(sessionBasket)); } catch (Exception e) { return(InternalServerError(new Exception("there was an error mapping the basket item"))); } }