public async Task <List <Task> > GetUnsynced(DateTime lastSyncDate) { try { var response = await _serviceStackClient.PostAsync(new TasksRequest { LastSyncDate = lastSyncDate }); var returnList = new List <Task>(); foreach (var task in response.Tasks) { var project = _projectRepository.GetById(task.ProjectId); if (project != null) { var timeRegistrationTypeEnum = (TimeRegistrationTypeEnum)(int)task.TimeRegistrationType; //now thats casting! var item = Task.Create(task.Guid, task.Id, task.Name, task.Description, project, task.CreateDate, true, string.Empty, task.Inactive, timeRegistrationTypeEnum); returnList.Add(item); } else { throw new MissingHieracleDataException(string.Format("Could not find projectId {0} for task '{1} ({2})'", task.ProjectId, task.Name, task.Id)); } } return(returnList); } catch (MissingHieracleDataException) { throw; } catch (Exception ex) { throw new ServiceAccessException("Error contacting service", ex); } }
public void SaveTask(Task task) { lock (LockObj) { AddOrUpdate(task); } }
private void AddOrUpdate(Task task) { if (DataSet.Tasks.All(x => x.Guid != task.Guid)) { var newTask = DataSet.Tasks.NewTasksRow(); newTask.Name = task.Name; newTask.Id = task.Id; newTask.Guid = task.Guid; newTask.ProjectId = task.Project.Id; newTask.CreateDate = task.CreateDate; newTask.Description = task.Description; newTask.Synced = task.IsSynced; newTask.SyncInfo = task.SyncResponse; newTask.TimeRegistionTypeId = (int)task.TimeRegistrationType; DataSet.Tasks.AddTasksRow(newTask); } else { var existingTask = DataSet.Tasks.First(t => t.Guid == task.Guid); existingTask.Name = task.Name; existingTask.Id = task.Id; existingTask.Guid = task.Guid; existingTask.ProjectId = task.Project.Id; existingTask.CreateDate = task.CreateDate; existingTask.Description = task.Description; existingTask.Synced = task.IsSynced; existingTask.SyncInfo = task.SyncResponse; existingTask.TimeRegistionTypeId = (int)task.TimeRegistrationType; } }
private void TaskSelectCompleted(Task task) { if (_isSelectingNewTask && task != null) { Rows.Add(_taskItemViewmodelFactory.CreateEmptyTaskItemViewmodel(task, StartDate)); UpdateBottom(); } _isSelectingNewTask = false; }