示例#1
0
        public void GetAllParentTaskTest()
        {
            var prntTasks    = _parentTaskService.GetAllParentTasks();
            var prntTaskList =
                prntTasks.Select(
                    parentTaskEntity =>
                    new ParentTask
            {
                Parent_ID   = parentTaskEntity.Parent_ID,
                Parent_Task = parentTaskEntity.Parent_Task
            }).ToList();
            var comparer = new ParentTaskComparer();

            CollectionAssert.AreEqual(
                prntTaskList.OrderBy(prntTask => prntTask, comparer),
                _parentTask.OrderBy(prntTask => prntTask, comparer), comparer);
        }
示例#2
0
        // GET: api/ParentTask
        public HttpResponseMessage Get()
        {
            try
            {
                _loggerServices.LogInfo("InfoCode: API Info | Message :" + "File Name : TaskController | Method Name : GetAllTasks | Description : Method Begin", LoggerConstants.Informations.WebAPIInfo);

                var tasks = _taskServices.GetAllParentTasks();
                if (tasks != null)
                {
                    var taskEntities = tasks as List <ParentTaskEntity> ?? tasks.ToList();
                    if (taskEntities.Any())
                    {
                        return(Request.CreateResponse(HttpStatusCode.OK, taskEntities));
                    }
                }
            }
            catch (Exception exception)
            {
                _loggerServices.LogException(exception, LoggerConstants.Informations.WebAPIInfo);
            }
            return(Request.CreateErrorResponse(HttpStatusCode.NotFound, "Tasks not found"));
        }