Beispiel #1
0
 public static int AddOrUpdate(Category category)
 {
     if (category.Id == 0) {
         return DB.Insert (category);
     } else {
         return DB.Update (category);
     }
 }
Beispiel #2
0
        public void UpdateCell(Category category)
        {
            if (category == null) {
                return;
            }

            var balance = FinancerModel.GetBalance (category);

            this.CategoryNameLabel.Text = category.Name;
            this.AmountLabel.Text = balance.ToString ("0.00") + " лв.";
            this.AmountLabel.TextColor = GetAmountColor (balance);
        }
Beispiel #3
0
        public static int Delete(Category category)
        {
            var result = 0;
            if (category != null) {
                DB.BeginTransaction ();
                var transactionsToDelete = GetTransactions ().Where (t => t.CategoryId == category.Id).ToArray ();
                foreach (var transaction in transactionsToDelete) {
                    result += DB.Delete (transaction);
                }

                result += DB.Delete (category);
                DB.Commit ();
            }

            return result;
        }
Beispiel #4
0
 public static double GetBalance(Category category)
 {
     return GetTransactions ().Where (trans => trans.CategoryId == category.Id).Sum (trans => (trans.IsInbound ? 1 : -1) * trans.Amount);
 }
        private void SetupTableViews()
        {
            this.currentCategory = this.Transaction == null ? FinancerModel.GetCategories ().FirstOrDefault () : this.Transaction.Category;
            this.categorySource = new CategoriesSource (new[] { this.currentCategory }.GetCategoriesDictionary ());
            this.categorySource.HeaderText = "Category";
            this.categorySource.Callback = (c) => {
                this.PerformSegue(this.IsEditing ? SelectCategorySegue : ReviewCategorySegue, this);
            };
            this.CategoryTableView.Source = this.categorySource;
            this.CategoryTableView.AlwaysBounceVertical = false;

            this.currentPerson = this.Transaction == null ? FinancerModel.GetOtherPeople ().FirstOrDefault () : this.Transaction.Contact;
            this.peopleSource = new PeopleSource (new[] { this.currentPerson }.GetPeopleDictionary());
            this.peopleSource.Callback = (p) => {
                this.PerformSegue(this.IsEditing ? SelectPersonSegue : ReviewPersonSegue, this);
            };
            this.peopleSource.HeaderText = "Contact";
            this.PersonTableView.Source = this.peopleSource;
            this.PersonTableView.AlwaysBounceVertical = false;
        }