コード例 #1
0
        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);
        }
コード例 #2
0
        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);
        }
コード例 #3
0
        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);
        }
コード例 #4
0
 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());
 }
コード例 #5
0
        public CategoryProductsDTO GetCategoryProducts(string CategoryName)
        {
            bool exists = productDatabaseContext.CategoryExists(CategoryName);

            if (!exists)
            {
                throw new CategoryDoesNotExistsException();
            }
            CategoryProductsDTO newCategoryProductsDTO = productDatabaseContext.GetCategoryProducts(CategoryName);

            return(newCategoryProductsDTO);
        }
コード例 #6
0
 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 }));
     }
 }
コード例 #7
0
        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));
        }
コード例 #8
0
        public CategoryProductsDTO GetCategoryProducts(string categoryName)
        {
            CategoryProductsDTO categoryProductsDTO = categoryDatabaseContext.GetCategoryProducts(categoryName);

            return(categoryProductsDTO);
        }