public async Task <Result <QuocGiasResponse> > Handle(GetQuocGiaByIdQuery query, CancellationToken cancellationToken) { var item = await _repository.GetByIdAsync(query.Id); var mappedCategory = _mapper.Map <QuocGiasResponse>(item); return(Result <QuocGiasResponse> .Success(mappedCategory)); }
public async Task <Result <int> > Handle(DeleteQuocGiaCommand 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(UpdateQuocGiaCommand 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.Icon = command.Icon ?? item.Icon; item.Description = command.Description ?? item.Description; await _repository.UpdateAsync(item); await _unitOfWork.Commit(cancellationToken); return(Result <int> .Success(item.Id)); } }