Exemplo n.º 1
0
        private async void PredictionButton_Clicked(object sender, EventArgs e)
        {
            await ActivityIndicatorPage.ToggleIndicator(true);

            var dto = new ExpenseDto
            {
                Value      = double.Parse(Value.Text),
                Date       = Date.Date,
                CategoryId = ((CategoryDto)Category.SelectedItem).Id
            };

            try
            {
                var result = await _predictionService.MakePrediction(dto);

                ShowResult(result);
            }
            catch (RestException exc)
            {
                await DisplayAlert("Error", exc.Message, "OK");
            }
            finally
            {
                await ActivityIndicatorPage.ToggleIndicator(false);
            }
        }
Exemplo n.º 2
0
        private async void SubmitClicked(object sender, EventArgs e)
        {
            try
            {
                await ActivityIndicatorPage.ToggleIndicator(true);

                var passwordChangeDto = new PasswordChangeDto
                {
                    CurrentPassword     = OldPass.Text,
                    NewPassword         = NewPass.Text,
                    NewPasswordRepeated = NewPassRepeated.Text
                };
                await _accountService.ChangePasswordAsync(passwordChangeDto);
                await DisplayAlert("Success", "Success", "OK");

                await Navigation.PopAsync();
            }
            catch (RestException exception)
            {
                await DisplayAlert("Error", exception.Message, "OK");
            }
            finally
            {
                await ActivityIndicatorPage.ToggleIndicator(false);
            }
        }
Exemplo n.º 3
0
        private async void SignInClicked(object sender, EventArgs e)
        {
            await ActivityIndicatorPage.ToggleIndicator(true);

            var loginDto = new LoginDto
            {
                Username = Username.Text,
                Password = Password.Text
            };

            try
            {
                void Navigate()
                {
                    Application.Current.MainPage = new StartPage();
                }

                await _authService.LoginAsync(loginDto, Navigate);
            }
            catch (RestException re)
            {
                await DisplayAlert("Error", re.Message, "OK");
            }
            finally
            {
                await ActivityIndicatorPage.ToggleIndicator(false);
            }
        }
Exemplo n.º 4
0
        private async void SubmitClicked(object sender, EventArgs e)
        {
            await ActivityIndicatorPage.ToggleIndicator(true);

            var dto = new UserEditDto
            {
                FirstName   = FirstName.Text,
                LastName    = LastName.Text,
                PhoneNumber = Phone.Text
            };

            try
            {
                await _userService.EditUser(dto);
                await DisplayAlert("Success", "Success", "OK");

                await Navigation.PopAsync();
            }
            catch (RestException exception)
            {
                await DisplayAlert("Error", exception.Message, "OK");
            }
            finally
            {
                await ActivityIndicatorPage.ToggleIndicator(false);
            }
        }
        public async Task Initialize()
        {
            await ActivityIndicatorPage.ToggleIndicator(true);

            var data = await _userService.GetUserDetailsAsync();

            SetUserData(data);
            await ActivityIndicatorPage.ToggleIndicator(false);
        }
Exemplo n.º 6
0
        private async void GetIncomesClicked(object sender, EventArgs e)
        {
            await ActivityIndicatorPage.ToggleIndicator(true);

            var incomes = await _incomeService.GetIncomesAsync(DateFrom.Date, DateTo.Date);

            IncomesList.ItemsSource = incomes.OrderByDescending(i => i.Date)
                                      .Select(i => new { i.Description, Value = i.Value.ToString("F2") + " zł", i.Date, i.Id, i.CategoryId });
            await ActivityIndicatorPage.ToggleIndicator(false);
        }
Exemplo n.º 7
0
        private async void AddIncomeClicked(object sender, EventArgs e)
        {
            await ActivityIndicatorPage.ToggleIndicator(true);

            var page = new AddTransactionPage(DataTransferObjects.Category.CategoryType.IncomeCategory, AddIncome);
            await page.Initialize();

            await ActivityIndicatorPage.ToggleIndicator(false);

            await Navigation.PushAsync(page);
        }
Exemplo n.º 8
0
        private async void ExpenseClicked(object sender, ItemTappedEventArgs e)
        {
            var action = await DisplayActionSheet("Options", "Back", null, new[] { "Edit", "Delete" });

            dynamic item = e.Item;
            var     dto  = new TransactionDto()
            {
                CategoryId  = item.CategoryId,
                Date        = item.Date,
                Description = item.Description,
                Id          = item.Id,
                Value       = double.Parse(item.Value.Substring(0, item.Value.Length - 3))
            };

            try
            {
                switch (action)
                {
                case "Edit":
                    await ActivityIndicatorPage.ToggleIndicator(true);

                    var page = new EditTransactionPage(CategoryType.ExpenseCategory, dto, () => GetExpensesClicked(null, null));
                    await page.Initialize();

                    await ActivityIndicatorPage.ToggleIndicator(false);

                    await Navigation.PushAsync(page);

                    break;

                case "Delete":
                    var choice = await DisplayAlert("Delete", "Are you sure?", "Yes", "No");

                    if (choice)
                    {
                        await ActivityIndicatorPage.ToggleIndicator(true);

                        await _expenseService.DeleteExpenseAsync(dto.Id);

                        GetExpensesClicked(sender, e);
                    }
                    break;
                }
            }
            catch (RestException exception)
            {
                await DisplayAlert("Error", exception.Message, "OK");
            }
            finally
            {
                await ActivityIndicatorPage.ToggleIndicator(false);
            }
        }
Exemplo n.º 9
0
        private async void SignUpClicked(object sender, EventArgs e)
        {
            await ActivityIndicatorPage.ToggleIndicator(true);

            if (!Password.Text.Equals(PasswordConfirm.Text, StringComparison.InvariantCulture))
            {
                await DisplayAlert("Error", "Passwords don't match", "OK");

                await ActivityIndicatorPage.ToggleIndicator(false);

                return;
            }

            var registerDto = new RegisterDto
            {
                Email       = Email.Text,
                Username    = Username.Text,
                Password    = Password.Text,
                FirstName   = FirstName.Text,
                LastName    = LastName.Text,
                PhoneNumber = Phone.Text
            };

            try
            {
                void Navigate()
                {
                    Application.Current.MainPage = new StartPage();
                }

                await _authService.RegisterAsync(registerDto, Navigate);
            }
            catch (RestException re)
            {
                await DisplayAlert("Error", re.Message, "OK");
            }
            finally
            {
                await ActivityIndicatorPage.ToggleIndicator(false);
            }
        }
        private async void AddTransactionClicked(object sender, EventArgs e)
        {
            await ActivityIndicatorPage.ToggleIndicator(true);

            var dto = new TransactionDto
            {
                Description = Description.Text,
                Value       = double.Parse(Value.Text),
                Date        = Date.Date,
                CategoryId  = ((CategoryDto)Category.SelectedItem).Id
            };

            try
            {
                switch (_type)
                {
                case CategoryType.IncomeCategory:
                    await _incomeService.AddIncomeAsync(dto);

                    break;

                case CategoryType.ExpenseCategory:
                    await _expenseService.AddExpenseAsync(dto);

                    break;
                }
            }
            catch (RestException re)
            {
                await DisplayAlert("Error", re.Message, "OK");
            }
            finally
            {
                await ActivityIndicatorPage.ToggleIndicator(false);
                await Close();
            }
        }
        private async void SubmitClicked(object sender, EventArgs e)
        {
            var dto = new TransactionDto
            {
                CategoryId  = ((CategoryDto)Category.SelectedItem).Id,
                Date        = Date.Date.Date,
                Description = Description.Text,
                Id          = _dto.Id,
                Value       = double.Parse(Value.Text)
            };

            await ActivityIndicatorPage.ToggleIndicator(true);

            try
            {
                if (_type == CategoryType.IncomeCategory)
                {
                    await _incomeService.EditIncome(dto);
                }
                else
                {
                    await _expenseService.EditExpense(dto);
                }

                _refresh();
                BackClicked(sender, e);
            }
            catch (RestException exception)
            {
                await DisplayAlert("Error", exception.Message, "OK");
            }
            finally
            {
                await ActivityIndicatorPage.ToggleIndicator(false);
            }
        }