public static ProductEditModel Create(IRepository <Product> ProductRepository, IRepository <ProductCategory> ProductCategoryRepository, IRepository <ProductImage> ProductImageRepository, IRepository <Province> ProvinceRepository, IRepository <District> DistrictRepository, IRepository <State> StateRepository) { var productEdit = new ProductEditModel { Product = new Product(), ProductCategorys = ProductCategoryRepository.GetAll().OrderBy(r => r.Name).ToList(), Provinces = ProvinceRepository.GetAll().ToList(), Districts = DistrictRepository.GetAll().ToList(), States = StateRepository.GetAll().ToList() }; return(productEdit); }
public static ProductEditModel GetById(IRepository <Product> ProductRepository, IRepository <ProductCategory> ProductCategoryRepository, IRepository <ProductImage> ProductImageRepository, int id) { var product = ProductRepository.GetByID(id); var getproductImages = ProductImageRepository.GetAll().Where(x => x.ProductID == product.ID).ToList(); var getProductImagePath = ProductImageRepository.GetAll().Where(x => x.ProductID == product.ID).Select(x => x.ImagePath).ToList(); if (product != null) { var model = new ProductEditModel { Product = product, ProductCategorys = ProductCategoryRepository.GetAll().OrderBy(r => r.ID).ToList(), ProductImages = getproductImages, ProductImagePath = getProductImagePath }; var Productcate = ProductCategoryRepository.GetByID(product.categoryID).Name; model.SelectedProductCategory = Productcate; return(model); } return(null); }
public static ProductEditModel GetById(IRepository <Product> ProductRepository, IRepository <ProductCategory> ProductCategoryRepository, IRepository <ProductImage> ProductImageRepository, IRepository <Province> ProvinceRepository, IRepository <District> DistrictRepository, IRepository <State> StateRepository, int id) { var product = ProductRepository.GetByID(id); var productImages = ProductImageRepository.GetAll().Where(x => x.ProductID == product.ID).ToList(); if (product != null) { var model = new ProductEditModel { Product = product, ProductCategorys = ProductCategoryRepository.GetAll().OrderBy(r => r.ID).ToList(), ProductImages = productImages, Provinces = ProvinceRepository.GetAll().ToList(), Districts = DistrictRepository.GetAll().ToList(), States = StateRepository.GetAll().ToList() }; var Productcate = ProductCategoryRepository.GetByID(product.categoryID).Name; model.SelectedProductCategory = Productcate; return(model); } return(null); }