示例#1
0
        protected virtual void Save()
        {
            var transaction = new Transaction
            {
                Comment = Comment,
                Date    = DateTime,
                Name    = Name,
                Value   = Amount
            };
            var success = DebtsManager.AddDebt(new Debt
            {
                Name         = Name,
                ToMe         = InterfaceUpdateManager.IsTabToMe,
                Transactions = new List <Transaction> {
                    transaction
                }
            });

            if (!success)
            {
                ShowAlert();
                return;
            }
            NavigationService.GoBack();
        }
示例#2
0
        void Merge()
        {
            var transaction = new Transaction
            {
                Comment = Comment,
                Date    = DateTime,
                Value   = Amount,
                Name    = Name
            };
            var success = DebtsManager.MergeDebt(new Debt
            {
                Name         = Name,
                ToMe         = InterfaceUpdateManager.IsTabToMe,
                Transactions = new List <Transaction> {
                    transaction
                }
            });

            if (!success)
            {
                ShowMergeFailedAlert();
                return;
            }
            NavigationService.GoBack();
        }
示例#3
0
        public void UpdateInfo(string name)
        {
            var newDebt = DebtsManager.GetDebt(name);

            if (newDebt != null)
            {
                Debt      = newDebt;
                TotalText = GetTotalText(Debt);
            }
        }
        protected override void Save()
        {
            var transaction = new Transaction
            {
                Comment = Comment,
                Date    = DateTime,
                Name    = Name,
                Value   = Positive ? Amount : -Amount
            };
            var success = DebtsManager.AddTransaction(transaction);

            if (!success)
            {
                ShowAlert();
                return;
            }
            NavigationService.GoBack();
            InterfaceUpdateManager.InvokeUpdateMainScreen();
        }
示例#5
0
        internal bool ChangeName(string text)
        {
            if (Debt.Name == text)
            {
                return(true);
            }

            //check if the name already exists
            if (DebtsManager.GetDebt(text) != null)
            {
                return(false);
            }

            //rename
            var oldName = Debt.Name;

            Debt.Name = text;

            //save changes
            DebtsManager.RenameDebt(oldName, Debt.Name);
            InterfaceUpdateManager.InvokeUpdateMainScreen();
            return(true);
        }
示例#6
0
 public void Dispose()
 {
     DebtsManager.RemoveTransaction(this);
     InterfaceUpdateManager.InvokeItemRemoved();
 }
示例#7
0
 public List <Debt> GetItems(bool myDebts)
 {
     _debts = DebtsManager.ReadDebts().Select(item => item.Value).ToList();
     return(_debts.Where(item => item.ToMe == !myDebts).ToList());
 }