/// <summary> /// Updates the created task with UID = <paramref name="id"/> in the current job. /// </summary> /// <param name="id"> /// Task's UID. /// </param> /// <param name="task"> /// Task's updated definition. /// </param> public void UpdateTask(Guid id, Dto.Task task) { if (currentJob.State == JobState.Creating || currentJob.State == JobState.Ready || currentJob.State == JobState.Completed || currentJob.State == JobState.Failed) { var updatedTask = task.FromContract(currentJob.Tasks); updatedTask.Id = id; lock (currentJob) { currentJob.Tasks.Remove(currentJob.Tasks.Where(t => t.Id == id).Single()); currentJob.Tasks.Add(updatedTask); } } else { throw new InvalidOperationException("currentJob is in wrong state."); } }
/// <summary> /// Creates a task in current job. /// </summary> /// <param name="task"> /// An instance of <see cref="DataModel.Task"/> which defines the task to create. /// </param> /// <returns> /// An unique identifier for created task. /// </returns> public Guid CreateTask(Dto.Task task) { var t = task.FromContract(currentJob.Tasks); t.Id = Guid.NewGuid(); t.Job = currentJob; currentJob.Tasks.Add(t); return t.Id; }