Example #1
0
        public Result <ItemData> GetItemData(int itemID)
        {
            var itemDataResult = _donateAccessor.GetItemData(itemID);

            if (!itemDataResult.IsSuccess)
            {
                return(itemDataResult);
            }
            var itemData = itemDataResult.Payload;

            if (itemData.SelectedItemType == "direct")
            {
                var invItem = _inventoryAccessor.GetItem(itemID).Payload;
                itemData.GoalAmount      = invItem.GoalAmount;
                itemData.CurrentAmount   = invItem.ActualAmount;
                itemData.AutoDecrement   = invItem.AutoDecrement;
                itemData.DecrementPerDay = invItem.DecrementPerDay;
            }
            else
            {
                var campaignItem = _donateAccessor.GetCampaignItem(itemID).Payload;
                itemData.GoalAmount    = campaignItem.GoalAmount;
                itemData.CurrentAmount = campaignItem.ActualAmount;
            }

            return(new Result <ItemData>(itemData));
        }
        public Result <Item> GetItem(int itemID, string languageName, string currencyCode)
        {
            var result = _donateAccessor.GetItem(itemID, languageName, currencyCode);

            if (!result.IsSuccess)
            {
                return(result);
            }

            var item = result.Payload;

            if (item.ItemType == "direct")
            {
                var invItemResult = _inventoryAccessor.GetItem(itemID);
                if (!invItemResult.IsSuccess)
                {
                    return(new Result <Item>(false, invItemResult.Message));
                }
                var invItem = invItemResult.Payload;

                item.GoalAmount   = invItem.GoalAmount;
                item.ActualAmount = (int)Math.Ceiling(invItem.ActualAmount);
            }
            else
            {
                var campaignItemResult = _donateAccessor.GetCampaignItem(itemID);
                if (!campaignItemResult.IsSuccess)
                {
                    return(new Result <Item>(false, campaignItemResult.Message));
                }
                var campaignItem = campaignItemResult.Payload;

                item.GoalAmount   = campaignItem.GoalAmount;
                item.ActualAmount = campaignItem.ActualAmount;
            }

            return(new Result <Item>(item));
        }