Example #1
0
        public IHttpActionResult GetOffers()
        {
            var offers = db.Offers;
            List <OfferItem> offerItems = new List <OfferItem>();

            foreach (Offer offer in offers)
            {
                var offerItem = OfferItem.ConvertOfferToOfferItem(offer);
                offerItems.Add(offerItem);
            }
            return(Ok(offerItems));
        }
Example #2
0
            public static BindingBucketItem Convert(BucketItem bucketItem)
            {
                OfferItem         offer = OfferItem.ConvertOfferToOfferItem(bucketItem.Offer);
                BindingBucketItem item  = new BindingBucketItem
                {
                    BucketItemID = bucketItem.BucketItemID,
                    Quantity     = bucketItem.Quantity,
                    TotalPrice   = bucketItem.TotalPrice,
                    IsChosen     = bucketItem.IsChosen,
                    Offer        = offer
                };

                return(item);
            }
Example #3
0
        public IHttpActionResult GetOffersByCategory(int id)
        {
            var offers = db.Offers;
            List <OfferItem> offerItems = new List <OfferItem>();

            foreach (Offer offer in offers)
            {
                if (id == offer.Category.CategoryID)
                {
                    if (offer.IsActive && offer.InStockNow > 0)
                    {
                        var offerItem = OfferItem.ConvertOfferToOfferItem(offer);
                        offerItems.Add(offerItem);
                    }
                }
            }
            return(Ok(offerItems));
        }