Ejemplo n.º 1
0
        public async Task <Response <UpdateCategoryDto> > Handle(UpdateCategoryCommand request, CancellationToken cancellationToken)
        {
            var command  = _mapper.Map <UpdateCategoryRequest>(request);
            var category = await _CategoryRepository.GetByIdAsync(command.Id);

            if (category == null)
            {
                throw new ApiException($"Category Not Found.");
            }
            else
            {
                category.Name        = command.Name;
                category.Description = command.Description;
                await _CategoryRepository.UpdateAsync(category);

                return(new Response <UpdateCategoryDto>(_mapper.Map <UpdateCategoryDto>(category), "Category Update Successufull"));
            }
        }