public JsonResult GetAllTasks(int limit, int offset, string sortfiled, string sortway, string search, string status)
        {
            var output = _taskAppService.GetTasks(new GetTasksInput());

            TaskState currentState;

            var result = output.Tasks.Where(t => t.Title.Contains(search));

            if (!string.IsNullOrEmpty(sortfiled))
            {
                result = result.OrderBy(string.Format("{0} {1}", sortfiled, sortway));
            }
            if (!string.IsNullOrEmpty(status))
            {
                if (Enum.TryParse <TaskState>(status, true, out currentState))
                {
                    result = result.Where(r => r.State == currentState);
                }
            }

            var taskDtos = result as TaskDto[] ?? result.ToArray();
            var total    = taskDtos.ToList().Count;

            var rows = taskDtos.Skip(offset).Take(limit).ToList();

            return(AbpJson(new { total = total, rows = rows }, wrapResult: false, camelCase: false, behavior: JsonRequestBehavior.AllowGet));
        }
Example #2
0
        public ActionResult Index(GetTasksInput input)
        {
            var output = _taskAppService.GetTasks(input);

            var model = new IndexViewModel(output.Tasks)
            {
                SelectedTaskState = input.State
            };

            return(View(model));
        }
Example #3
0
        public ActionResult List()
        {
            GetTasksInput getTasksInput = new GetTasksInput();

            getTasksInput.TaskId = 1;
            GetTasksOutput res = _appService.GetTasks(getTasksInput);

            return(View(res.Tasks));
        }
Example #4
0
        public void GetTasks_Test()
        {
            // Act
            var output = _taskAppService.GetTasks(new GetTasksInput {
                State = TaskState.Active
            });

            // Assert
            output.Tasks.Count.ShouldBeGreaterThan(0);
        }
Example #5
0
        public ActionResult Create(CreateTaskInput task)
        {
            //var id = _taskAppService.CreateTask(task);
            //.CreateTask(task);

            var input  = new GetTasksInput();
            var output = _taskAppService.GetTasks(input);

            return(PartialView("_List", output.Tasks));
        }
Example #6
0
        public void Should_Get_Tasks()
        {
            //Run SUT
            var output = _taskAppService.GetTasks(new GetTasksInput {
                State = TaskState.Completed
            });

            //Checking results
            output.Tasks.Count.ShouldBe(2);
            output.Tasks.All(t => t.State == (byte)TaskState.Completed).ShouldBe(true);
        }
Example #7
0
        public void Test()
        {
            var result = _taskAppService.GetTasks(new GetTasksInput());

            foreach (var task in result.Tasks)
            {
                Console.WriteLine(task.ToString());
            }

            Console.WriteLine();
            Console.WriteLine("{0} tasks listed.", result.Tasks.Count);
        }
        public void Should_Get_Filtered_Task()
        {
            //Arrange
            var filter = new GetTasksInput()
            {
                State = TaskState.Open
            };

            var openTasksCount = UsingDbContext(ctx => ctx.Tasks.Count(t => t.State == TaskState.Open));

            //Act
            var actualOpenTaskCount = _taskAppService.GetTasks(filter).Tasks.Count;

            //Assert
            actualOpenTaskCount.ShouldBe(openTasksCount);
        }
Example #9
0
        public GetTasksOutput GetTasks([FromBody] GetTaskInput input)
        {
            var output = _taskAppService.GetTasks(input);

            return(output);
        }
Example #10
0
        public void Should_Get_All_Tasks()
        {
            var output = _taskAppService.GetTasks(new GetTasksInput());

            output.Tasks.Count.ShouldBe(2);
        }