Example #1
0
        public async Task <IActionResult> ListSizesAsync()
        {
            var sizes = await _sizeService.ListAsync();

            var data         = _mapper.Map <List <SizeDTO> >(sizes);
            var listResponse = new ListResponseDTO
            {
                Data = data,
            };

            return(Ok(listResponse));
        }
Example #2
0
        public ListResponseDTO List_File()
        {
            ListResponseDTO dto = null;

            try
            {
                dto = List_File(OSSFileCode.File);
            }
            catch (Exception ex)
            {
                LogHelper.WriteException(ex);
                dto = new ListResponseDTO();
            }
            return(dto);
        }
        public async Task <IActionResult> ListCategoriesAsync([FromQuery] Pagination pagination, [FromQuery] SearchCategory search)
        {
            var categories = await _categoryService.ListAsync(pagination, search);

            // Mapping before to return
            var data            = _mapper.Map <List <CategoryDTO> >(categories);
            var ListResponseDTO = new ListResponseDTO
            {
                Data        = data,
                CurrentPage = categories.CurrentPage,
                PageSize    = categories.PageSize,
                Count       = categories.Count,
                TotalCount  = categories.TotalCount,
                TotalPage   = categories.TotalPages
            };

            return(Ok(ListResponseDTO));
        }
Example #4
0
        public async Task <IActionResult> GetProductsAsync([FromQuery] Pagination pagination, [FromQuery] SearchProduct search)
        {
            var products = await _productService.ListAsync(pagination, search);

            var data = _mapper.Map <List <ProductDTO> >(products);

            var listResponseDTO = new ListResponseDTO
            {
                Data        = data,
                CurrentPage = products.CurrentPage,
                PageSize    = products.PageSize,
                Count       = products.Count,
                TotalCount  = products.TotalCount,
                TotalPage   = products.TotalPages
            };

            return(Ok(listResponseDTO));
        }
Example #5
0
        public async Task <ActionResult> GetOrders([FromQuery] SearchOrder search, [FromQuery] Pagination pagination)
        {
            var currentRequestId = User.Claims.First(claim => claim.Type == "sub").Value;

            if (User.IsInRole(Roles.Shipper))
            {
                search.ShipperId = currentRequestId;
            }

            var orders = await _orderService.ListAsync(search, pagination);

            var data = _mapper.Map <List <OrderDTO> >(orders);
            var list = new ListResponseDTO
            {
                Data        = data,
                Count       = orders.Count,
                CurrentPage = orders.CurrentPage,
                PageSize    = orders.PageSize,
                TotalCount  = orders.TotalCount,
                TotalPage   = orders.TotalPages
            };

            return(Ok(list));
        }