Ejemplo n.º 1
0
            public async Task <Result <SalariesResponse> > Handle(GetSalaryByIdQuery query, CancellationToken cancellationToken)
            {
                var item = await _repository.GetByIdAsync(query.Id);

                var mappedCategory = _mapper.Map <SalariesResponse>(item);

                return(Result <SalariesResponse> .Success(mappedCategory));
            }
Ejemplo n.º 2
0
            public async Task <Result <int> > Handle(DeleteSalaryCommand command, CancellationToken cancellationToken)
            {
                var item = await _repository.GetByIdAsync(command.Id);

                await _repository.DeleteAsync(item);

                await _unitOfWork.Commit(cancellationToken);

                return(Result <int> .Success(item.Id));
            }
Ejemplo n.º 3
0
        public async Task <Result <int> > Handle(UpdateSalaryCommand command, CancellationToken cancellationToken)
        {
            var item = await _repository.GetByIdAsync(command.Id);

            if (item == null)
            {
                return(Result <int> .Fail($"JobAge Not Found."));
            }
            else
            {
                item.Name        = command.Name ?? item.Name;
                item.Code        = command.Code ?? item.Code;
                item.Description = command.Description ?? item.Description;
                await _repository.UpdateAsync(item);

                await _unitOfWork.Commit(cancellationToken);

                return(Result <int> .Success(item.Id));
            }
        }