コード例 #1
0
        public JsonResult GetWalletCurrencyAmount(int walletID, int currencyID)
        {
            try
            {
                var result = walletService.CanAccessWallet(walletID, SessionHelper.CurrentEntity.EntityID);
                if (result.IsError)
                {
                    return(JsonError(result));
                }

                decimal amount = walletRepository.GetMoneyAmount(walletID, currencyID);

                return(JsonData(amount));
            }
            catch (Exception e)
            {
                return(JsonDebugOnlyError(e));
            }
        }
コード例 #2
0
        public ActionResult BuyOfferWithWallet(int entityID, int offerID, int amount, int walletID)
        {
            var result = walletService.CanAccessWallet(walletID, SessionHelper.CurrentEntity.EntityID);

            if (result.IsError)
            {
                return(RedirectBackWithError(result));
            }

            var offer = marketOfferRepository.GetById(offerID);

            var entity = entityRepository.GetById(entityID);

            result = marketService.CanBuyOffer(offer, amount, entity, walletID);

            if (result.IsError)
            {
                return(RedirectBackWithError(result));
            }

            marketService.Buy(offer, entity, amount, walletID);

            return(RedirectBackWithInfo(string.Format("You sucessfuly bought {0} {1}", amount, MarketOfferExtensions.GetProductType(offer).ToHumanReadable())));
        }