public async Task <CategoryListItemDTO> GetCategoryAsync(Guid id)
        {
            var category = await this.categoryRepository.GetCategoryAsync(id);

            var dto = new CategoryListItemDTO
            {
                Id         = category.Id,
                Name       = category.Name,
                ExternalId = category.ExternalId
            };

            return(dto);
        }
        public async Task <CategoryListItemDTO> SearchCategoryAsync(string _CategorySearchName)
        {
            CategoryListItemDTO dto = new CategoryListItemDTO();

            dto.CategorySearchName = _CategorySearchName;
            if (!string.IsNullOrEmpty(dto.CategorySearchName))
            {
                dto.categories = await _categoryRepository.TableNoTracking.Where(p => p.Name.Contains(dto.CategorySearchName)).OrderByDescending(o => o.ID).ToListAsync();
            }
            else
            {
                dto.categories = await _categoryRepository.TableNoTracking.OrderByDescending(o => o.ID).ToListAsync();
            }
            foreach (var i in dto.categories.ToList())
            {
                if (i.Description == null)
                {
                    i.Description = "";
                }
            }
            return(dto);
        }
 public async Task <IActionResult> List(CategoryListItemDTO dTO)
 {
     return(View(await _categoryService.SearchCategoryAsync(dTO.CategorySearchName)));
 }
Ejemplo n.º 4
0
        public IViewComponentResult Invoke()
        {
            CategoryListItemDTO dTO = new CategoryListItemDTO();

            return(View(dTO));
        }