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)); }
public void TextInitialize() { var kernel = AssemblyConfiguration.Kernel; _createTaskCommand = kernel.Get <CreateTaskCommand>(); _sut = kernel.Get <GetTasksQuery>(); }
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); }
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>(); }
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)); }
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>(); }
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()); }
public IHttpActionResult Get() { try { var query = new GetTasksQuery(); var tasks = _getTasksQueryHandler.Handle(query); return(Json <object>(tasks)); } catch (Exception exception) { return(InternalServerError(exception)); } }
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); } }
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(); }
public IEnumerable <TaskDTO> Handle(GetTasksQuery query) { var tasks = _repository.Get(); return(tasks.Select(task => DomainTaskToDTOMapper.Transform(task))); }
public async Task <ActionResult <TasksVm> > Get([FromQuery] GetTasksQuery query) { var user = _sharedIdentityService.GetUserId; return(await Mediator.Send(query)); }
public async Task <ActionResult <TasksVm> > Get([FromQuery] GetTasksQuery query) { return(await Mediator.Send(query)); }