示例#1
0
        public ITimeAccount AddAccount(string name)
        {
            ITimeAccount result = null;
            // account name could be already existing
            var account = _accounts.FirstOrDefault(a => a.Name.Equals(name, StringComparison.CurrentCultureIgnoreCase));

            if (account != null)
            {
                // yes account already exists
                if (account.Archived.HasValue)
                {
                    // reactivate
                    account.Archived = null;
                    result           = account;
                }
            }
            else
            {
                // create new one
                result = new TimeAccount(name);
                _accounts.Add(result);
            }

            if (result != null)
            {
                _accountStore.Write(_accounts);
            }

            return(result);
        }
示例#2
0
        public void TimeTracking_Switch()
        {
            const string TestAccountName = "Test1";
            var          tt         = new TimeTracking();
            ITimeAccount newAccount = tt.AddAccount(TestAccountName);

            tt.Switch(newAccount);

            Assert.AreSame(tt.CurrentSession.Account, newAccount);
        }
示例#3
0
        private void TimeAccountAcctivate(object sender, EventArgs e)
        {
            var button = sender as CheckBox;

            if (!button.Checked)
            {
                button.Checked = true;
                return; // prevent unchecking
            }

            ITimeAccount account = button.Tag as ITimeAccount;

            if (_timeTracking.Switch(account))
            {
                _activeButton.Checked = false;
                _activeButton         = button;
            }
            ShowCommenting(!(_activeButton.Tag is BreakAccount));
        }
示例#4
0
 internal TrackingSession(ITimeAccount account, DateTime start)
 {
     Start      = start;
     Account    = account;
     _accountID = account.ID;
 }
示例#5
0
 internal TrackingSession(ITimeAccount account) : this(account, DateTime.Now)
 {
 }