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); }
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); }
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)); }
internal TrackingSession(ITimeAccount account, DateTime start) { Start = start; Account = account; _accountID = account.ID; }
internal TrackingSession(ITimeAccount account) : this(account, DateTime.Now) { }