public async Task <CategoryModel> HandleAsync(ByIdQuery query) { var specification = new ByIdSpecification(query.Id); var category = await this._repository.FindOneAsync(specification).ConfigureAwait(false); return(Mapper.Map <CategoryModel>(category)); }
public async Task <CategoryModel> HandleAsync(ByIdKeywordsQuery query) { var specification = new ByIdSpecification(query.Id); var category = await _repository.FindOneAsync(specification).ConfigureAwait(false); if (!string.IsNullOrWhiteSpace(category.Keywords)) { return(Mapper.Map <CategoryModel>(category)); } var categoryWithKeywords = await _repository.GetCategoryWithKeywords(query.Id).ConfigureAwait(false); category.Keywords = categoryWithKeywords.Keywords; return(Mapper.Map <CategoryModel>(category)); }
public T GetById(Guid guid) { var spec = new ByIdSpecification(guid); return(_repo.Where(x => spec.SatisfiedBy(x)).First()); }