예제 #1
0
        public IHttpActionResult GetBasket(string id)
        {
            var sessionBasket = BasketInMemorySorage.GetBasket(id);

            if (sessionBasket == null)
            {
                return(NotFound());
            }
            return(Ok(sessionBasket));
        }
예제 #2
0
 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")));
     }
 }