public void CreateTaskTest() { var taskController = new TaskController() { Request = new HttpRequestMessage { Method = HttpMethod.Post, RequestUri = new Uri(serviceBaseURL + "Create") } }; taskController.Request.Properties.Add(HttpPropertyKeys.HttpConfigurationKey, new HttpConfiguration()); var newTask = new TaskEntity() { Task_ID = 1, Parent_ID = 1, TaskName = "Task-1", Parent_Task = "ParentTask-1", Start_Date = Convert.ToDateTime("2018-01-20"), End_Date = Convert.ToDateTime("2018-01-30"), Priority = 5 }; int parentTask = _parentTaskService.CreateTask(new ParentTaskEntity() { Parent_Task = newTask.Parent_Task }); taskController.Post(newTask); _response = taskController.Get(); var responseResultSearch = JsonConvert.DeserializeObject <List <VIEW_TASKManger> >(_response.Content.ReadAsStringAsync().Result); var taskList = responseResultSearch.Select( taskEntity => new Task { Task_ID = taskEntity.Task_ID, Parent_ID = taskEntity.Parent_ID, TaskName = taskEntity.TaskName, Start_Date = taskEntity.Start_Date, End_Date = taskEntity.End_Date, Priority = taskEntity.Priority }).ToList(); var addedtask = new Task() { Task_ID = newTask.Task_ID, Parent_ID = newTask.Parent_ID, TaskName = newTask.TaskName, Start_Date = newTask.Start_Date, End_Date = newTask.End_Date, Priority = newTask.Priority }; AssertObjects.PropertyValuesAreEquals(addedtask, taskList.Last()); }
public int CreateTask(TaskEntity taskEntity) { using (var scope = new TransactionScope()) { var task = new TaskMan.DAL.Task { TaskName = taskEntity.TaskName, Parent_ID = taskEntity.Parent_ID, Start_Date = taskEntity.Start_Date, End_Date = taskEntity.End_Date, Priority = taskEntity.Priority, }; _unitOfWork.TaskRepository.Insert(task); _unitOfWork.Save(); scope.Complete(); return(task.Task_ID); } }