/// <summary> /// Добавляет новое списение ОСП. /// </summary> /// <param name="newExpense">Новое списание ОСП</param> public void AddNewOspExpense(ExpenseDTO newExpense) { if (newExpense != null) { Expenses.Add(newExpense); } }
private void SubscribeForEvents() { MessagingCenter.Subscribe <NewExpensePage, Expense>(this, "AddExpense", async(obj, expense) => { var newExpense = expense as Expense; Expenses.Add(newExpense); await AzureDataStore.AddItemAsync(newExpense); }); MessagingCenter.Subscribe <FamilyAllExpensesPage, Expense>(this, "AddExpense2", async(obj, expense) => { var newExpense = expense as Expense; Expenses.Insert(0, newExpense); await AzureDataStore.AddItemAsync(newExpense); }); MessagingCenter.Subscribe <ExpenseService, UpdateStatusMessage>(this, "UpdateStatusMessage", (obj, args) => { UpdateStatusMessage updateStatusMessage = args as UpdateStatusMessage; if (updateStatusMessage != null) { if (updateStatusMessage.UpdateStatus == Enums.UpdateStatus.Completed) { } StatusMessage = updateStatusMessage; } }); }
void ExecuteLoadExpensesCommand() { if (IsBusy) { return; } IsBusy = true; try { Expenses.Clear(); var expenses = DataStore.Get(true).OrderByDescending(x => x.Date); foreach (var item in expenses) { item.BackgroundColor = Color.FromRgb(218, 56, 53); Expenses.Add(item); } } catch (Exception ex) { Debug.WriteLine(ex); } finally { IsBusy = false; } }
public async Task AddExpense(string name) { try { await ThreadPool.RunAsync((workItem) => { try { var expense = ExpenseRepository.Factory(name); var vm = new ExpenseViewModel(expense); Vehicle.Expenses.Add(expense); Expenses.Add(vm); SelectedExpense = vm; } catch (Exception ex) { App.Telemetry.TrackException(ex); SelectedExpense = null; } finally { Vehicle.Expenses.OrderBy(x => x.Name); Expenses.OrderBy(x => x.Expense.Name); } }); } catch (Exception ex) { App.Telemetry.TrackException(ex); } }
protected override async Task ExecuteLoadExpensesCommand() { if (IsBusy) { return; } IsBusy = true; try { await LoadCategories(); Expenses.Clear(); var expenses = await GetExpenses(); var sortedExpenses = expenses.Cast <Expense>().OrderByDescending((x) => x.CreationDateTime).Select(x => x); foreach (var expense in sortedExpenses) { Expenses.Add(expense); } } catch (Exception ex) { Debug.WriteLine(ex); //throw; } finally { IsBusy = false; } }
public virtual Expense AddExpense(CashFlow flow, decimal value, string description, DateTime date) { Expense expense = Expense.CreateExpense(this, flow, value, description, date); Expenses.Add(expense); return(expense); }
public async Task LoadExpenseData() { if (Constants.isExpenseLoaded) { goto ReflectValue; } Constants.isExpenseLoaded = true; Expenses.Clear(); var expenses = await _expenseStore.GetExpensesByUserId(Constants.curUserId); foreach (var exp in expenses) { Expenses.Add(new ExpenseViewModel(exp)); } ReflectValue: if (Expenses.Count != 0) { MyExpenseValue = Expenses.Where(x => x.UserId == Constants.curUserId).Sum(x => x.Amount); } Constants.myTotalExpense = (MyExpenseValue != 0) ? MyExpenseValue : 0; if (Constants.myTotalFund != 0) { MyBalanceValue = MyFundValue - MyExpenseValue; } }
public async Task ExecuteLoadExpensesCommand() { if (IsBusy) { return; } IsBusy = true; if (!LoadedAlert) { await ExecuteLoadAlert(); } Expenses.Clear(); NeedsUpdate = false; try { var exps = await expenseService.GetExpenses(); foreach (var expense in exps) { Expenses.Add(expense); } } catch (Exception exception) { Debug.WriteLine("Unable to query and gather expenses"); } finally { IsBusy = false; } }
async Task GetExpensesAsync() { if (IsBusy) { return; } IsBusy = true; try { Expenses.Clear(); var expenses = await DependencyService.Get <IDataService>().GetExpensesAsync(); foreach (var expense in expenses) { Expenses.Add(expense); } } catch (Exception ex) { MessagingCenter.Send(this, "Error", ex.Message); } finally { IsBusy = false; } }
async Task ExecuteLoadExpensesCommand() { if (IsBusy) { return; } IsBusy = true; try { Expenses.Clear(); var items = await DraftBudget.GetMonthlyExpensesAsync(true); foreach (var item in items) { Expenses.Add(item); } if (Expenses.Count == 0) { Expenses.Add(new Expense { Id = Guid.NewGuid().ToString(), Title = "", Amount = 0 }); } } catch (Exception ex) { Debug.WriteLine(ex); } finally { IsBusy = false; } }
private async void LoadData() { IsBusy = true; IList <Expense> list = await GetData(itemsToLoad, pageNumber); if (list.Any()) { if (Expenses == null) { Expenses = new ObservableCollection <Expense>(list); } else { if (pageNumber == 0) { Expenses.Clear(); } foreach (var item in list) { Expenses.Add(item); } } pageNumber++; } RaisePropertyChanged(() => this.HasNoExpenses); IsBusy = false; }
async Task GetExpensesAsync() { if (IsBusy) { return; } IsBusy = true; try { Expenses.Clear(); Expenses.Add(new Expense { Company = "Walmart", Description = "Always low prices.", Amount = "$14.99", Date = DateTime.Now }); Expenses.Add(new Expense { Company = "Apple", Description = "New iPhone came out - irresistable.", Amount = "$999", Date = DateTime.Now.AddDays(-7) }); Expenses.Add(new Expense { Company = "Amazon", Description = "Case to protect my new iPhone.", Amount = "$50", Date = DateTime.Now.AddDays(-2) }); } catch (Exception ex) { MessagingCenter.Send(this, "Error", ex.Message); } finally { IsBusy = false; } }
async Task ExecuteLoadItemsCommand() { if (IsBusy) { return; } IsBusy = true; try { Expenses.Clear(); var etems = await DataStores.GetItemsAsynce(true); foreach (var etem in etems) { Expenses.Add(etem); } } catch (Exception ex) { Debug.WriteLine(ex); } finally { IsBusy = false; } }
public void Exec(int amount, string categoryName) { Expenses.Add(new Expense { Amount = amount, CategoryId = Categories.ByName(categoryName).Id }); }
private async void PopulateExpenses() { List <Expense> expenses = await App.Database.GetExpensesAsync(); foreach (Expense expense in expenses) { Expenses.Add(expense); } }
//adds new or replaces existing expense public void AddExpense(Expense expense) { if (Expenses.Select(x => x.Type == expense.Type).Count() != 0) { Expenses.RemoveAll(x => x.Type == expense.Type); } Expenses.Add(expense); }
/// <summary> /// Add an Expense to Expenses List /// </summary> /// <param name="value"></param> /// <param name="date"></param> /// <param name="account"></param> internal void AddExpense(double value, DateTime date, Account account, ItemCategory category) { var expense = new Expense(date, account, value, category); Expenses.Add(expense); expense.Move(value); SaveAccounts(); SaveExpenses(); }
public void GetExpenses() { Expenses.Clear(); foreach (var expense in Expense.GetExpenses()) { Expenses.Add(expense); } }
/// <summary> /// Registers a new expense transaction to be billed at the end of the year. /// </summary> /// <param name="type">The <see cref = "TurnoverType"/> of the transaction.</param> /// <param name="amount">The amount of money transacted.</param> void RegisterExpense(TurnoverType type, float amount) { this.Log($"Wealth registered expense of {type} and {amount}"); if (!Expenses.ContainsKey(type)) { Expenses.Add(type, 0f); } Expenses[type] += amount; }
private void GetExpenses() { var expenses = Expense.GetExpenses(); Expenses.Clear(); foreach (var expense in expenses) { Expenses.Add(expense); } }
public void GetExpenses() { var expenses = Expense.GetExpenses().ToList(); Expenses.Clear(); foreach (var expense in expenses) { Expenses.Add(expense); } }
public void ReadExpenses() { IsRefreshing = true; var expenses = Expense.ReadExpenses(); Expenses.Clear(); foreach (var expense in expenses) { Expenses.Add(expense); } IsRefreshing = false; }
public virtual void AddExpense(int templateId) { var template = Templates.Include(q => q.Category).First(t => t.Id == templateId); Expenses.Add(new Expense { Description = template.Name, Category = template.Category, Date = DateTime.Now, Sum = template.Sum }); SaveChanges(); }
private async Task UpdateExpensesInView() { Expenses.Clear(); var expenses = await GetExpenses(); var sortedExpenses = expenses.Cast <Expense>().OrderByDescending((x) => x.CreationDateTime).Select(x => x); foreach (var expense in sortedExpenses) { Expenses.Add(expense); } //Expenses = new ObservableCollection<Expense>(sortedExpenses); }
protected async void AddNewExpense() { if (string.IsNullOrEmpty(NewExpense.Name)) { return; } Expenses.Add(NewExpense); await ServerFacade.UpdateExpenses(Expenses); FilterExpenses(); NewExpense = new Expense(); IsFormOpen = false; base.StateHasChanged(); }
/// <summary> /// Метод добавления строки расходов. /// </summary> private void Add(object param) { CurrentExpenses = new IncomeExpenses(); var MaxId = Expenses.Count; CurrentExpenses.Title = "NewTitle" + (MaxId + 1); Expenses.Add(CurrentExpenses); Save(CURRENT_PATH_EXPENSES, Expenses); Refresh(); }
/// <summary> /// bespoke method to loop through expenses from db & assign to class member /// NB not possible to assign directly to ObservableCollection, hence must loop & push /// </summary> public void GetExpenses() // must be public so as to use from page's code-behind when Observable change-in-value has triggered an OnAppearing { // throw new NotImplementedException(); var expenses = Expense.GetExpenses(); // NB not possible to assign directly to ObservableCollection, hence must loop & push Expenses.Clear(); foreach (var expense in expenses) { Expenses.Add(expense); // add 1-by-1 } }
private async void GetExpenses() { IsRefreshing = true; Expenses.Clear(); var expenses = await Expense.GetExpensesAsync(); if (expenses != null) { foreach (var expense in expenses) { Expenses.Add(expense); } } IsRefreshing = false; }
public void AddExpenseForTrip(object o) { int result; var parameter = (object[])o; if ((parameter[0].ToString() != "" && parameter[1].ToString() != "") && int.TryParse(parameter[1].ToString(), out result)) { ExpenseModel temp = new ExpenseModel(); temp.Name = parameter[0].ToString(); temp.AmountMoney = result; Expenses.Add(temp); OnPropertyChanged(nameof(Expenses)); Trip.AddExpense(temp); } }
public void Map(RomanApp.Service.Entities.Event entity) { base.Map(entity); DateCreated = entity.DateCreated; Guests.Clear(); Expenses.Clear(); foreach (var o in entity.Guests) { Guests.Add(new GuestModel(o)); } foreach (var o in entity.Expenses) { Expenses.Add(new ExpenseModel(o)); } }
public static void ProcessExpensesRepaidClosed (BasicEvent newEvent) { Person expenser = Person.FromIdentity(newEvent.VictimPersonId); Person payer = Person.FromIdentity(newEvent.PerpetratorPersonId); // The ParameterText field is like a,b,c,d where a..d are expense IDs string[] idStrings = newEvent.ParameterText.Split(','); Expenses expenses = new Expenses(); decimal totalAmount = 0.0m; foreach (string idString in idStrings) { Expense newExpense = Expense.FromIdentity(Int32.Parse(idString)); totalAmount += newExpense.Amount; expenses.Add (newExpense); } string body = "The following expenses, totaling " + totalAmount.ToString ("#,##0.00") + ", have been repaid to your registered account, " + expenser.BankName + " " + expenser.BankAccount + ".\r\n\r\n"; body += FormatExpenseLine ("#", "Description", "Amount"); body += FormatExpenseLine ("===", "========================================", "========="); foreach (Expense expense in expenses) { body += FormatExpenseLine (expense.Identity.ToString(), expense.Description, expense.Amount.ToString ("#,##0.00")); } body += FormatExpenseLine ("---", "----------------------------------------", "---------"); body += FormatExpenseLine (string.Empty, "TOTAL", totalAmount.ToString ("#,##0.00")); body += "\r\nIf you see any problems with this, please contact the treasurer, " + payer.Name + ", at " + payer.PPMailAddress + ". Thank you for helping the pirate movement succeed.\r\n"; new PirateWeb.Utility.Mail.MailTransmitter("PirateWeb", "*****@*****.**", "Expenses Repaid: " + totalAmount.ToString("#,##0.00"), body, expenser, true).Send(); }