Exemple #1
0
        // GET: Admin/SubCategory
        public ActionResult Index()
        {
            var res       = _subCategoryService.GetSubCategoryList().ToList();
            var viewModel = AutoMapper.Mapper.Map <List <SubCategoryMaster>, List <SubCategoryViewModel> >(res);

            //ViewBag.CategoryList = _categoryMasterService.GetCategoryList();

            return(View(viewModel));
        }
        public ActionResult ProductsById(string ProductId)
        {
            ProductViewModel viewModel;

            if (!string.IsNullOrEmpty(ProductId))
            {
                var res = _productService.GetProduct(Convert.ToDecimal(UrlSecurityManager.Decrypt(ProductId, System.Configuration.ConfigurationManager.AppSettings["SecurityKey"])));
                if (res != null)
                {
                    viewModel = AutoMapper.Mapper.Map <ProductEntity, ProductViewModel>(res);
                    if (viewModel.ProductUserGuide == null)
                    {
                        viewModel.ProductUserGuide = new ProductUserGuideViewModel();
                    }
                    if (viewModel.ProductFAQs != null)
                    {
                        foreach (var item in viewModel.ProductFAQs)
                        {
                            var productFaq   = _productService.GetProductFAQ(item.Id);
                            var viewModelFAQ = AutoMapper.Mapper.Map <ProductFAQs, ProductFaqViewModel>(productFaq);
                            if (viewModelFAQ.ProductFAQVideoList == null)
                            {
                                viewModelFAQ.ProductFAQVideoList = new List <ProductFAQVideoViewModel>();
                            }
                            else
                            {
                                var videos = AutoMapper.Mapper.Map <List <ProductFAQVideos>, List <ProductFAQVideoViewModel> >(productFaq.ProductFAQVideos.ToList());
                                viewModelFAQ.ProductFAQVideoList = videos.Where(y => y.IsDeleted != true).ToList();
                            }
                            item.ProductFAQVideoList = viewModelFAQ.ProductFAQVideoList;
                        }
                    }
                }
                else
                {
                    viewModel = new ProductViewModel();
                    return(Redirect("/Home/Index"));
                }
            }
            else
            {
                viewModel = new ProductViewModel();
                return(Redirect("/Home/Index"));
            }

            ViewBag.SubCategoryList = _subCategoryService.GetSubCategoryList();
            //_homeService.AddProductToRecentViewed(new RecentVisitedProduct() { ProductId = ProductId, UserId = Guid.Parse("6A68CDB1-167F-4323-9D90-34602D20E06D") });
            _homeService.AddProductToRecentViewed(new RecentVisitedProduct()
            {
                ProductId = Convert.ToDecimal(UrlSecurityManager.Decrypt(ProductId, "iPsUniversity2020")), UserId = Convert.ToInt32(Session["UserLoginID"])
            });

            return(View(viewModel));
        }
        public ActionResult AddEditProduct(string ProductId)
        {
            ProductViewModel viewModel;

            if (!string.IsNullOrEmpty(ProductId))
            {
                var res = _productService.GetProduct(Convert.ToDecimal(ProductId));
                viewModel = AutoMapper.Mapper.Map <ProductEntity, ProductViewModel>(res);
                if (viewModel.ProductUserGuide == null)
                {
                    viewModel.ProductUserGuide = new ProductUserGuideViewModel();
                }
            }
            else
            {
                viewModel = new ProductViewModel();
            }
            var subcategorys = _subCategoryService.GetSubCategoryList().ToList();

            //subcategorys = subcategorys.Where(t => t.AssocitedID == Convert.ToInt32(Session["UserSessionIDs"])).ToList();
            ViewBag.SubCategoryList = subcategorys;
            return(View(viewModel));
        }