/// <summary> /// Builds an instance of GetBasicProductCategoryModelView from an instance of ProductCategory. /// </summary> /// <param name="productcategory">Instance of ProductCategory from which the ModelView will be built.</param> /// <returns>An instance of GetBasicProductCategoryModelView.</returns> public static GetBasicProductCategoryModelView fromEntityAsBasic(ProductCategory productCategory) { GetBasicProductCategoryModelView basicProductCategoryModelView = new GetBasicProductCategoryModelView(); basicProductCategoryModelView.id = productCategory.Id; basicProductCategoryModelView.name = productCategory.name; return(basicProductCategoryModelView); }
/// <summary> /// Builds a List of GetBasicProductCategoryModelView from an IEnumerable of ProductCategory. /// </summary> /// <param name="productCategories">IEnumerable of instances of ProductCategory from which the ModelView List will be built.</param> /// <returns>A List of GetBasicProductCategoryModelView.</returns> public static GetAllProductCategoriesModelView fromCollection(IEnumerable <ProductCategory> productCategories) { GetAllProductCategoriesModelView result = new GetAllProductCategoriesModelView(); foreach (ProductCategory productCategory in productCategories) { GetBasicProductCategoryModelView basicInfoModelView = new GetBasicProductCategoryModelView(); basicInfoModelView.id = productCategory.Id; basicInfoModelView.name = productCategory.name; basicInfoModelView.parentId = productCategory.parentId; basicInfoModelView.parentName = productCategory.parent != null ? productCategory.parent.name : null; result.Add(basicInfoModelView); } return(result); }