public async Task <Result <JobTypesResponse> > Handle(GetJobTypeByIdQuery query, CancellationToken cancellationToken) { var item = await _repository.GetByIdAsync(query.Id); var mappedCategory = _mapper.Map <JobTypesResponse>(item); return(Result <JobTypesResponse> .Success(mappedCategory)); }
public async Task <Result <int> > Handle(DeleteJobTypeCommand command, CancellationToken cancellationToken) { var item = await _repository.GetByIdAsync(command.Id); await _repository.DeleteAsync(item); await _unitOfWork.Commit(cancellationToken); return(Result <int> .Success(item.Id)); }
public async Task <Result <int> > Handle(UpdateJobTypeCommand 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)); } }