public CategoryProductsDTO GetCategoryProducts(string categoryName) { Category category = futureKartContext.Categories.Where(c => c.Name == categoryName).FirstOrDefault(); Debug.WriteLine(futureKartContext.Categories.Where(c => c.Name == categoryName).FirstOrDefault()); CategoryProductsDTO categoryDTO = CategoryMapper.Map <Category, CategoryProductsDTO>(category); return(categoryDTO); }
public CategoryProductsDTO GetCategoryProducts(string CategoryName) { Category category = dbContext.Category.Include(c => c.Product).Where(c => c.Name == CategoryName).FirstOrDefault(); IEnumerable <Product> products = category.Product; CategoryProductsDTO newcategoryProductsDTO = new CategoryProductsDTO(); newcategoryProductsDTO.Products = _CategoryProductMapper.Map <IEnumerable <Product>, IEnumerable <ProductDTO> >(products); newcategoryProductsDTO.Name = category.Name; return(newcategoryProductsDTO); }
public CategoryProductsDTO GetCategoryProducts(string categoryName) { Category category = futureKartEntities.Categories.Include(c => c.Products).Where(c => c.Name == categoryName).FirstOrDefault(); Debug.WriteLine(futureKartEntities.Categories.Include(c => c.Products).Where(c => c.Name == categoryName).FirstOrDefault()); CategoryProductsDTO categoryProductsDTO = new CategoryProductsDTO(); categoryProductsDTO = ProductInfoMapper.Map <Category, CategoryProductsDTO>(category); return(categoryProductsDTO); }
public IActionResult GetProducts(Guid id) { if (id != null) { Category cat = _repo.GetProducts(id); CategoryProductsDTO catproducts = _mapper.Map <CategoryProductsDTO>(cat); return(Ok(catproducts.products)); } return(NotFound()); }
public CategoryProductsDTO GetCategoryProducts(string CategoryName) { bool exists = productDatabaseContext.CategoryExists(CategoryName); if (!exists) { throw new CategoryDoesNotExistsException(); } CategoryProductsDTO newCategoryProductsDTO = productDatabaseContext.GetCategoryProducts(CategoryName); return(newCategoryProductsDTO); }
public ActionResult GetCategoryProducts(string CategoryName) { try { CategoryProductsDTO categoryProductsDTO = categoryBusinessContext.GetCategoryProducts(CategoryName); CategoryProductViewModel categoryViewModel; categoryViewModel = CategoryMapper.Map <CategoryProductsDTO, CategoryProductViewModel>(categoryProductsDTO); return(View(categoryViewModel)); } catch (CategoryDoesNotExistsException ex) { return(RedirectToAction("ExceptionCatch", "Static", new { exception = ex })); } }
public ActionResult CategoryProducts(string CategoryName) { CategoryProductsViewModel viewModel = new CategoryProductsViewModel(); CategoryProductsDTO categoryProductsDTO = new CategoryProductsDTO(); try { categoryProductsDTO = productBusinessContext.GetCategoryProducts(CategoryName); } catch (CategoryDoesNotExistsException ex) { return(View("Error")); } catch (Exception ex) { return(View("Internal Error")); } viewModel = _CategoryProductVMMapper.Map <CategoryProductsDTO, CategoryProductsViewModel>(categoryProductsDTO); if (Session["UserID"] != null) { viewModel.IsLoggedIn = true; } return(View(viewModel)); }
public CategoryProductsDTO GetCategoryProducts(string categoryName) { CategoryProductsDTO categoryProductsDTO = categoryDatabaseContext.GetCategoryProducts(categoryName); return(categoryProductsDTO); }