/// <summary> /// Deletes a task from the database for a given id /// </summary> /// <param name="id">The id of the task to delete.</param> public void DelTask(int id) { ToDoTask toDoTask = new ToDoTask(this.resporitoryToDoTasks); ToDoTasksDataLayer.Entities.ToDoTasks entityTask = toDoTask.GetTasks(id); toDoTask.Del(entityTask); }
/// <summary> /// Get the individual task for a given taskid /// </summary> /// <param name="taskId">The task id</param> /// <returns>Returns a task object for use by the UI.</returns> public UIToDoTask GetTask(int taskId) { ToDoTasksDataLayer.Entities.ToDoTasks task = new ToDoTasksDataLayer.Entities.ToDoTasks(); ToDoTask toDoTask = new ToDoTask(this.resporitoryToDoTasks); ToDoTasksDataLayer.Entities.ToDoTasks entityTask = toDoTask.GetTasks(taskId); Models.UIToDoTask uiToDoTask = new Models.UIToDoTask { ToDoTaskId = entityTask.ToDoTaskId, CheckedDone = entityTask.CheckedDone, LastUpdated = entityTask.LastUpdated, TaskDescription = entityTask.TaskDescription, TaskUserId = entityTask.TaskUserId }; return(uiToDoTask); }
public void GetTasks_InCorrectParameters_ReturnsCorrectObject() { IRepository <ToDoTasks, int> iRepository = Substitute.For <IRepository <ToDoTasks, int> >(); ToDoTasks toDoTaskExpected = new ToDoTasks { CheckedDone = false, LastUpdated = System.DateTime.Now, TaskDescription = "someDescription", TaskUserId = 1, ToDoTaskId = 1 }; iRepository.FindBy(1).Returns(toDoTaskExpected); ToDoTask toDoTasks = new ToDoTask(iRepository); ToDoTasks taskUserActual = toDoTasks.GetTasks(2); Assert.Null(taskUserActual); }