Exemplo n.º 1
0
        public async Task <IActionResult> Create([FromBody] CreateTaskDto dto)
        {
            //not sure if this is the best way but can't think of a better way.
            var usecase  = new TaskCreatedUseCase(_taskRepository, _lifetimeScope.Resolve <ILogger <TaskCreatedUseCase> >());
            var response = await usecase.Process(_mapper.Map <CreateTaskRequest>(dto));

            if (response.Success)
            {
                return(new OkResult());
            }

            return(ApiHelpers.GetErrorResult(response.Errors, _mapper));
        }
Exemplo n.º 2
0
        public IActionResult Update(UpdateExampleDto dto)
        {
            //We are updating something so the use case manage the business and application logic.
            //The controller method handles transforming the response.
            var usecase   = new UpdateExampleUseCase(_exampleRepository);
            var ressponse = usecase.Process(new UpdateExampleRequest(dto.Id, dto.Property1));

            if (ressponse.Success)
            {
                return(new OkResult());
            }

            return(ApiHelpers.GetErrorResult(ressponse.Errors, _mapper));
        }
Exemplo n.º 3
0
        public async Task <IActionResult> Update([FromBody] UpdateToDoDto dto)
        {
            //We are updating something so the use case manages the business and application logic.
            //The controller method handles transforming the response.
            var usecase  = new UpdateTaskUseCase(_taskRepository, _userRepository); //not sure this is good.
            var response = await usecase.Process(_mapper.Map <UpdateTaskRequest>(dto));

            if (response.Success)
            {
                return(new OkResult());
            }

            return(ApiHelpers.GetErrorResult(response.Errors, _mapper));
        }