public async Task <List <CategoryViewDto> > GetCategory() { List <CategoryViewDto> categoryList = new List <CategoryViewDto>(); var cat = await _category.GetCategory(); if (cat.Count > 0) { foreach (var categories in cat) { CategoryViewDto newcategory = new CategoryViewDto { CategoryName = categories.CategoryName, Id = categories.Id }; categoryList.Add(newcategory); } } return(categoryList); }
public static CategoryViewDto ToDto(this DataAccess.Models.CategoryView item) { CategoryViewDto dto = null; if (item != null) { dto = new CategoryViewDto { Id = item.Id, Category = item.Category, SubCategory1 = item.SubCategory1, SubCategory2 = item.SubCategory2, SubCategory1Id = item.SubCategory1Id, SubCategory2Id = item.SubCategory2Id, ParentId = item.ParentId, SubCategory1ParentId = item.SubCategory1ParentId, SubCategory2ParentId = item.SubCategory2ParentId }; } return(dto); }