public static Task AddTask(Task newTask) { int newId = Tasks.Max(t => t.TaskID) + 1; newTask.TaskID = newId; Tasks.Add(newTask); return newTask; }
public void UpdateTask(int agentId, int taskId, Task updatedTask) { Agent agent = Database.Agents.SingleOrDefault(a => a.AgentID == agentId); Task task = agent.Tasks.Where(t => t.TaskID == taskId).SingleOrDefault(); // Update the task from the database task.Description = updatedTask.Description; task.IsComplete = updatedTask.IsComplete; }
public Task AddTask(int agentId, Task newTask) { Agent agent = Database.Agents.SingleOrDefault(a => a.AgentID == agentId); // Create the task and attach it to the agent entity newTask = Database.AddTask(newTask); agent.Tasks.Add(newTask); return newTask; }