コード例 #1
0
        public async Task <IActionResult> GetTasks(int page = 1, int size = 10)
        {
            var filter = new GetTasksQuery(page, size);
            var result = await _mediator.Send(filter);

            return(Ok(result));
        }
コード例 #2
0
        public void TextInitialize()
        {
            var kernel = AssemblyConfiguration.Kernel;

            _createTaskCommand = kernel.Get <CreateTaskCommand>();
            _sut = kernel.Get <GetTasksQuery>();
        }
コード例 #3
0
            public async Task <TimesheetResponse <TaskDto> > Handle(GetTasksQuery request, CancellationToken cancellationToken)
            {
                var task = await _taskRepository.Get();

                var response = new TimesheetResponse <TaskDto>();

                response.Timesheet.AddRange(_mapper.Map <List <TaskDto> >(task));
                return(response);
            }
コード例 #4
0
        public void TestInitialize()
        {
            var commandFactory = AssemblyConfiguration.Kernel.Get <CommandFactory>();
            var queryFactory   = AssemblyConfiguration.Kernel.Get <QueryFactory>();

            _mapper            = AssemblyConfiguration.Kernel.Get <IMapper>();
            _createTaskCommand = commandFactory.GetInstance <CreateTaskCommand>();
            _getTaskQuery      = queryFactory.GetInstance <GetTasksQuery>();
            _sut = commandFactory.GetInstance <UpdateTaskCommand>();
        }
コード例 #5
0
        public async Task <List <TaskResponse> > Handle(GetTasksQuery request, CancellationToken cancellationToken)
        {
            var tasks = await _taskRepository.GetTasksAsync(request.Page, request.Size);

            if (tasks == null)
            {
                throw new ApplicationException($"no record found");
            }
            _logger.LogInformation($"Requested tasks count : {tasks?.Count}");
            return(_mapper.MapTaskDtosToTaskResponses(tasks));
        }
コード例 #6
0
        public void TestInitialize()
        {
            var commandFactory = AssemblyConfiguration.Kernel.Get <CommandFactory>();
            var queryFactory   = AssemblyConfiguration.Kernel.Get <QueryFactory>();

            _getCurrentScheduleQuery = queryFactory.GetInstance <GetCurrentScheduleQuery>();
            _getTaskQuery            = queryFactory.GetInstance <GetTasksQuery>();
            _createTaskCommand       = commandFactory.GetInstance <CreateTaskCommand>();
            _createScheduleCommand   = commandFactory.GetInstance <CreateScheduleCommand>();
            _sut = commandFactory.GetInstance <TrackWorkTimeCommand>();
        }
コード例 #7
0
        public async Task <IList <TaskViewModel> > Handle(GetTasksQuery request, CancellationToken cancellationToken)
        {
            var tasks = await this.repository.GetAll();

            return(tasks.Select(x => new TaskViewModel()
            {
                Id = x.Id,
                Description = x.Description,
                StatusId = (int)x.Status,
                Title = x.Title
            }).ToList());
        }
コード例 #8
0
        public IHttpActionResult Get()
        {
            try
            {
                var query = new GetTasksQuery();
                var tasks = _getTasksQueryHandler.Handle(query);

                return(Json <object>(tasks));
            }
            catch (Exception exception)
            {
                return(InternalServerError(exception));
            }
        }
コード例 #9
0
        public static void GetTasks(IQueryDispatcher queryDispatcher, Expression <Func <Task, bool> > predicate = null)
        {
            var getTasksQuery = new GetTasksQuery();

            getTasksQuery.Predicate = predicate;

            IQueryable <Task> tasks = queryDispatcher.Query <GetTasksQuery, IQueryable <Task> >(getTasksQuery);

            Console.WriteLine("Güncelleme sonrası Bitmiş tasklar getiriliyor.");

            foreach (var task in tasks.ToList())
            {
                Console.WriteLine(task);
            }
        }
コード例 #10
0
        static void Main(string[] args)
        {
            DataBaseInitializer <TaskContext> .InitializedDatabase();

            IContainer container = new SimpleIocContainer();

            BootStrapper.Configure(container);

            ICommandDispatcher commandDispatcher = container.Resolve <ICommandDispatcher>();

            IQueryDispatcher queryDispatcher = container.Resolve <IQueryDispatcher>();



            var createCommand = new CreateTaskCommand {
                Title = "CQRS Örneği", UserName = "******", IsCompleted = false, CreatedOn = DateTime.Now, UpdatedOn = DateTime.Now
            };

            commandDispatcher.Execute(createCommand);


            var getTasksQuery = new GetTasksQuery();

            getTasksQuery.Predicate = (t) => t.IsCompleted == false;

            IQueryable <Task> tasks = queryDispatcher.Query <GetTasksQuery, IQueryable <Task> >(getTasksQuery);


            Console.WriteLine("Bitmemiş tasklar getiriliyor.");

            foreach (var task in tasks.ToList())
            {
                Console.WriteLine(task);
            }

            var lastTask = tasks.ToList().LastOrDefault();


            var changeCommand = new ChangeTaskStatusCommand {
                TaskId = 24, IsCompleted = true, UpdatedOn = DateTime.Now.AddMinutes(5)
            };

            commandDispatcher.Execute(changeCommand);

            Console.ReadLine();
        }
コード例 #11
0
        public IEnumerable <TaskDTO> Handle(GetTasksQuery query)
        {
            var tasks = _repository.Get();

            return(tasks.Select(task => DomainTaskToDTOMapper.Transform(task)));
        }
コード例 #12
0
        public async Task <ActionResult <TasksVm> > Get([FromQuery] GetTasksQuery query)
        {
            var user = _sharedIdentityService.GetUserId;

            return(await Mediator.Send(query));
        }
コード例 #13
0
 public async Task <ActionResult <TasksVm> > Get([FromQuery] GetTasksQuery query)
 {
     return(await Mediator.Send(query));
 }