Ejemplo n.º 1
0
        private async Task EditPathAsync(Path path)
        {
            try
            {
                var result = await PathService.EditPathAsync(path);

                var item = Paths.FirstOrDefault(x => x.Id == result.Id);
                if (item != null)
                {
                    item = result;
                }
                SnackbarHelper.PrintSuccess(localizer["PathUpdated"]);
            }
            catch (ApiError e)
            {
                if (e.ProblemDetails.Status == 422)
                {
                    SnackbarHelper.PrintErrorDetails((e.ProblemDetails as UnprocessableEntityProblemDetails).Errors);
                }
            }
            catch (Exception e)
            {
                SnackbarHelper.PrintError(e.Message);
            }
            StateHasChanged();
        }
Ejemplo n.º 2
0
        protected void OnClick_Deposit(object sender, EventArgs e)
        {
            var service = new CreditWebService.CreditWebService();

            double money = double.Parse(DepositText.Text);

            try
            {
                service.DepositMoney(bankAccount.Id, money);
                BalanceLabel.Text = "$" + (bankAccount.Balance + money);
            }
            catch
            {
                SnackbarHelper.DisplaySnackBar(this, "Deposit Failed...");
            }
        }
Ejemplo n.º 3
0
        private async Task DeletePath(Path pathItem)
        {
            try
            {
                var result = await PathService.DeletePath(pathItem);

                if (result)
                {
                    Paths.Remove(pathItem);
                    SnackbarHelper.PrintWarning(localizer["PathDeleted"]);
                }
                StateHasChanged();
            }
            catch (Exception e)
            {
                SnackbarHelper.PrintError(e.Message);
            }
        }
Ejemplo n.º 4
0
        private async Task LoadDataAsync(int pageNum)
        {
            try
            {
                _lastPageRequest = pageNum;

                _state = State.Loading;
                var result = await PathService.GetListAsync(false, pageNum, PAGE_SIZE);

                Paths = result.Data;
                PaginationMetadata = result.Metadata;
                _state             = State.ContentReady;
            }
            catch (Exception ex)
            {
                SnackbarHelper.PrintError(ex.Message);
                _state = State.Error;
            }
        }
Ejemplo n.º 5
0
        private async Task ChangePathVisibilityAsync(Path pathItem)
        {
            try
            {
                var result = await PathService.ChangeVisibility(pathItem);

                var changed = Paths.FirstOrDefault(x => x.Id == pathItem.Id);
                if (changed != null)
                {
                    changed.IsVisible = result.IsVisible;
                }

                StateHasChanged();
            }
            catch (Exception e)
            {
                SnackbarHelper.PrintError(e.Message);
            }
        }
Ejemplo n.º 6
0
        private async Task AddNewPathAsync(Path resultData)
        {
            try
            {
                var result = await PathService.AddNewPathAsync(resultData);

                Paths.Add(result);
                SnackbarHelper.PrintSuccess(localizer["PathCreated"]);
            }
            catch (ApiError e)
            {
                if (e.ProblemDetails.Status == 422)
                {
                    SnackbarHelper.PrintErrorDetails((e.ProblemDetails as UnprocessableEntityProblemDetails).Errors);
                }
            }
            catch (Exception e)
            {
                SnackbarHelper.PrintError(e.Message);
            }
            StateHasChanged();
        }
Ejemplo n.º 7
0
        protected void PayButton_OnClick(object sender, EventArgs e)
        {
            var user = (User)Session["user"];

            if (user == null)
            {
                Response.Redirect("Login.aspx");
            }

            if (!UseBalance.Checked)
            {
                var service = new CreditWebService.CreditWebService();
                var details = new CreditCardDto
                {
                    CardNumber            = cardnumber.Text.Replace(" ", ""),
                    CardVerificationValue = securitycode.Text,
                    Month = int.Parse(expirationdate.Text.Substring(0, 2)),
                    Year  = 2000 + int.Parse(expirationdate.Text.Substring(3, 2))
                };

                var transaction = service.Pay(details, service.GetBankAccount(3), amount);
                if (transaction == null)
                {
                    SnackbarHelper.DisplaySnackBar(this, "Payment Failed");
                    return;
                }
            }
            else
            {
                user.UpdateBalance(user.Balance - amount);
            }

            string paymentSuccessPage = "./PaymentSuccess.aspx";
            var    queryString        = HttpUtility.ParseQueryString(string.Empty);

            switch (payingFor)
            {
            case "bal":
                user.UpdateBalance(amount + user.Balance);
                queryString.Add("balance", "" + amount);
                break;

            case "game":
                if (BuyGift.Checked)
                {
                    var code        = GameCode.GenerateCode(game.Id);
                    var codeEncoded = EncodingHelper.Base64Encode(code.Code);
                    queryString.Add("code", HttpUtility.UrlEncode(codeEncoded));
                }
                else
                {
                    UserGame.AddGame(user.Id, game.Id, amount);
                    queryString.Add("game", "" + game.Id);
                    user.AddActivity("Bought " + game.GameName);
                }

                break;
            }


            Response.Redirect(paymentSuccessPage + "?" + queryString);
        }