Пример #1
0
        public async Task <Result <List <GetAllBrandsResponse> > > Handle(GetAllBrandsQuery request, CancellationToken cancellationToken)
        {
            var brandList = await _unitOfWork.Repository <Brand>().GetAllAsync();

            var mappedBrands = _mapper.Map <List <GetAllBrandsResponse> >(brandList);

            return(Result <List <GetAllBrandsResponse> > .Success(mappedBrands));
        }
Пример #2
0
        public async Task <Result <List <GetAllBrandsResponse> > > Handle(GetAllBrandsQuery request, CancellationToken cancellationToken)
        {
            Func <Task <List <Brand> > > getAllBrands = () => _unitOfWork.Repository <Brand>().GetAllAsync();
            var brandList = await _cache.GetOrAddAsync(ApplicationConstants.Cache.GetAllBrandsCacheKey, getAllBrands);

            var mappedBrands = _mapper.Map <List <GetAllBrandsResponse> >(brandList);

            return(await Result <List <GetAllBrandsResponse> > .SuccessAsync(mappedBrands));
        }