public async Task <IEnumerable <Brand> > Handle(GetAllBrandsQuery request, CancellationToken cancellationToken)
    {
        var brands = await _context.Brands.OrderBy(x => x.Id).ToListAsync(cancellationToken: cancellationToken);

        if (brands == null)
        {
            throw new Exception("Brands Not Found!");
        }
        return(brands);
    }
Esempio n. 2
0
        public async Task <IActionResult> Get(string search)
        {
            var command = new GetAllBrandsQuery()
            {
                Search = search ?? string.Empty
            };

            var brands = await _mediator.Send(command);

            return(Ok(brands));
        }
Esempio n. 3
0
        public async override Task <List <BrandReadModel> > Execute(GetAllBrandsQuery input, User?user)
        {
            var brands = await reader.ReadAll();

            return(brands);
        }
Esempio n. 4
0
        public async Task <IEnumerable <BrandDto> > Handle(GetAllBrandsQuery request, CancellationToken cancellationToken)
        {
            var brands = await _brandRepository.GetByFilter(x => x.Name.Contains(request.Search));

            return(_mapper.Map <IEnumerable <BrandDto> >(brands));
        }
Esempio n. 5
0
            public async Task <IEnumerable <Brand> > Handle(GetAllBrandsQuery query, CancellationToken cancellationToken)
            {
                var entityList = await _context.Brands.ToListAsync(cancellationToken);

                return(entityList?.AsReadOnly());
            }