Esempio n. 1
0
        private async Task DeleteInput(DataInputViewModel viewModel)
        {
            string type = viewModel.Type == "F" ? "Fund :" : "Expense :";

            if (await _pageService.DisplayAlert("Warning", $"Are you sure you want to delete {type} {viewModel.Description} : {viewModel.Amount}?", "YES", "NO"))
            {
                var data = await _dataInputInterface.GetDataInput(viewModel.Id);

                await _dataInputInterface.DeleteData(data);

                ListViewData.Remove(viewModel);
            }
            SelectedDataInput = null;
            DataInput         = null;
            Amount            = 0;
            Description       = null;
        }
Esempio n. 2
0
        public DashboardViewModel(IDataInputInterface dataInputInterface, IPageService pageService, string type = "", DataInputViewModel data = null, string mode = "")
        {
            _dataInputInterface = dataInputInterface;
            _pageService        = pageService;
            _mode = mode;

            Savings = Globals.currentUser.Savings;

            if (type != "")
            {
                InitializeControls(type);
            }

            DeleteDataInputCommand = new Command <DataInputViewModel>(async c => await DeleteInput(c));
            LoadDataInputCommand   = new Command(async() => await LoadData());
            SaveDataInputCommand   = new Command(async() => await SaveData(type));
            RefreshDataCommand     = new Command(async() => await RefreshData());
            LoadPayDayDataCommand  = new Command(async() => await LoadDataByEntryDate(SelectedPayday));
            if (mode != "new")
            {
                if (data != null)
                {
                    Amount       = data.Amount;
                    Description  = data.Description;
                    SelectedDate = data.EntryDate;

                    DataInput = new DataInput
                    {
                        Id          = data.Id,
                        Description = data.Description,
                        EntryDate   = data.EntryDate,
                        UpdateDate  = data.UpdateDate,
                        Amount      = data.Amount,
                        Type        = data.Type,
                        UserId      = data.UserId
                    };
                }
                else
                {
                    SelectedDate = DateTime.Now;
                }
            }

            InitializePaydays();
        }