public ActionResult <BogoPromotion> Get(string itemName)
        {
            BogoPromotion item = _bogos.GetItem(itemName);

            if (item == null)
            {
                return(NotFound());
            }

            return(Ok(item));
        }
        public ActionResult <StoreItem> Get(string itemName)
        {
            StoreItem item = _store.GetItem(itemName);

            if (item == null)
            {
                return(NotFound());
            }

            return(Ok(item));
        }
        public ActionResult <CartItem> Get(string itemName)
        {
            CartItem item = _cart.GetItem(itemName);

            if (item == null)
            {
                return(NotFound());
            }

            return(Ok(item));
        }
Ejemplo n.º 4
0
        public ActionResult <MultiplesPromotion> Get(string itemName)
        {
            MultiplesPromotion item = _multiples.GetItem(itemName);

            if (item == null)
            {
                return(NotFound());
            }

            return(Ok(item));
        }
Ejemplo n.º 5
0
        public ActionResult <MarkdownPromotion> Get(string itemName)
        {
            MarkdownPromotion item = _markdowns.GetItem(itemName);

            if (item == null)
            {
                return(NotFound());
            }

            return(Ok(item));
        }
        public ActionResult Post([FromBody] CartItem value)
        {
            //validate item
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            //item needs set up in store to be valid
            if (_store.GetItem(value.Name) == null)
            {
                return(BadRequest($"The item ({value.Name}) has not been set up."));
            }


            CartItem item = _cart.Add(value);

            return(CreatedAtAction("Get", new { id = item.Name }, item));
        }
        public ActionResult Post([FromBody] BogoPromotion value)
        {
            //Validate item
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            //Check for duplicate item
            if (_bogos.GetItem(value.Name) != null)
            {
                return(BadRequest($"An item already exists with the name {value.Name}."));
            }

            //item needs set up in store to be valid
            if (_store.GetItem(value.Name) == null)
            {
                return(BadRequest($"The item ({value.Name}) has not been set up."));
            }

            BogoPromotion item = _bogos.Add(value);

            return(CreatedAtAction("Get", new { id = item.Name }, item));
        }