public bool Delete(Task task) { if (task.AccountInfo.Provider == AccountProvider.Google) { GoogleTaskManager googleTaskManager = new GoogleTaskManager(); bool deleteSucess = googleTaskManager.Delete(task); if (!deleteSucess) { Errors.Add(googleTaskManager.ErrorMessage, task.AccountInfo); } return deleteSucess; } return false; }
public bool Insert(string accountTitle, Task task) { IAccountInfo accountInfo = Accounts.Find(acc => (acc.Title == accountTitle && acc.Provider == AccountProvider.Google)); if (accountInfo != null) { GoogleTaskManager googleTaskManager = new GoogleTaskManager(); task.AccountInfo = accountInfo; bool insertSucess = googleTaskManager.Insert(task); ClearErrors(); if (!insertSucess) { Errors.Add(googleTaskManager.ErrorMessage, accountInfo); } return insertSucess; } return false; }
private void FetchGoogleAccounts() { List<IAccountInfo> googleAccounts = Accounts.FindAll(acc => acc.Provider == AccountProvider.Google); foreach (IAccountInfo account in googleAccounts) { GoogleTaskManager taskManager = new GoogleTaskManager(); List<Task> query = taskManager.Query(account); if (taskManager.ErrorMessage != String.Empty) { Errors.Add(taskManager.ErrorMessage, account); Accounts.Remove(account); } else { TaskList.AddRange(query); } } }