Esempio n. 1
0
        private static void getAllCategories()
        {
            IEcommerceManagerFacade categoryManagerFacade = (IEcommerceManagerFacade)FacadeFactory.Instance.Create(FacadeType.EcommerceManager, null);
            IList <OperationResult <ICategoriesDTO> > listOperationResult = categoryManagerFacade.GetAllCategories();

            foreach (var category in listOperationResult)
            {
                if (category.IsValid())
                {
                    System.Console.WriteLine(category.Data.CategotyId + "  " + category.Data.CategoryName);
                }

                else if (category.HasValidationFailed() && category.ValidationResult != null)
                {
                    foreach (EmployeePortalValidationFailure error in category.ValidationResult.Errors)
                    {
                        System.Console.WriteLine(error.PropertyName + "  " + error.ErrorMessage);
                    }
                }
                else if (category.Message != String.Empty && category.StackTrace != String.Empty)
                {
                    System.Console.WriteLine(category.Message + "  " + category.StackTrace);
                }
            }
        }
        public ActionResult EditItem(int id)
        {
            updateItemId = id;
            IEcommerceManagerFacade    employeeFacade = (IEcommerceManagerFacade)FacadeFactory.Instance.Create(FacadeType.EcommerceManager);
            OperationResult <IItemDTO> itemDTO        = employeeFacade.getItem(id);

            itemDTO.IsValid();
            OperationResult <ISubCategoriesDTO> subCategoryDTO = employeeFacade.getSubCategory(itemDTO.Data.SubCategotyId);

            subCategoryDTO.IsValid();

            Item item = new Item();

            item.SubCategotyId = itemDTO.Data.SubCategotyId;
            item.ItemName      = itemDTO.Data.ItemName;
            item.ItemId        = itemDTO.Data.ItemId;
            List <SelectListItem> tempList = new List <SelectListItem>();

            tempList.Add(new SelectListItem {
                Text = subCategoryDTO.Data.SubCategoryName, Value = subCategoryDTO.Data.SubCategotyId + "", Selected = true
            });
            ViewBag.subcategory = (IEnumerable <SelectListItem>)(tempList);
            IList <OperationResult <ICategoriesDTO> > CATEGORIES = employeeFacade.GetAllCategories();
            List <SelectListItem> listCategories = new List <SelectListItem>();

            foreach (OperationResult <ICategoriesDTO> emp in CATEGORIES)
            {
                if (emp.IsValid())
                {
                    if (subCategoryDTO.Data.CategotyId == emp.Data.CategotyId)
                    {
                        listCategories.Add(new SelectListItem {
                            Text = emp.Data.CategoryName, Value = emp.Data.CategotyId + "", Selected = true
                        });
                    }
                    else
                    {
                        listCategories.Add(new SelectListItem {
                            Text = emp.Data.CategoryName, Value = emp.Data.CategotyId + ""
                        });
                    }
                }
            }

            ViewBag.Categories = (IEnumerable <SelectListItem>)listCategories;
            return(View(item));
        }
        public ActionResult EditSubCategory(int id)
        {
            updateSubCategoryId = id;
            IEcommerceManagerFacade             employeeFacade = (IEcommerceManagerFacade)FacadeFactory.Instance.Create(FacadeType.EcommerceManager);
            OperationResult <ISubCategoriesDTO> subCategory    = employeeFacade.getSubCategory(id);

            subCategory.IsValid();

            SubCategory cat = new SubCategory();

            cat.CategotyId      = subCategory.Data.CategotyId;
            cat.SubCategoryName = subCategory.Data.SubCategoryName;
            cat.SubCategotyId   = subCategory.Data.SubCategotyId;
            IList <OperationResult <ICategoriesDTO> > CATEGORIES = employeeFacade.GetAllCategories();
            List <SelectListItem> listCategories = new List <SelectListItem>();

            foreach (OperationResult <ICategoriesDTO> emp in CATEGORIES)
            {
                if (emp.IsValid())
                {
                    if (subCategory.Data.CategotyId == emp.Data.CategotyId)
                    {
                        listCategories.Add(new SelectListItem {
                            Text = emp.Data.CategoryName, Value = emp.Data.CategotyId + "", Selected = true
                        });
                    }
                    else
                    {
                        listCategories.Add(new SelectListItem {
                            Text = emp.Data.CategoryName, Value = emp.Data.CategotyId + ""
                        });
                    }
                }
            }

            ViewBag.Categories = (IEnumerable <SelectListItem>)listCategories;
            return(View(cat));
        }
        //
        // GET: /Ecommerce/

        public ActionResult Index()
        {
            IList <Category>        retVal                   = new List <Category>();
            IEcommerceManagerFacade employeeFacade           = (IEcommerceManagerFacade)FacadeFactory.Instance.Create(FacadeType.EcommerceManager);
            IList <OperationResult <ICategoriesDTO> > result = employeeFacade.GetAllCategories();

            if (result.Count() > 0)
            {
                foreach (OperationResult <ICategoriesDTO> emp in result)
                {
                    if (emp.IsValid())
                    {
                        Category tempEmp = new Category();
                        tempEmp.CategoryName = emp.Data.CategoryName;
                        tempEmp.CategotyId   = emp.Data.CategotyId;
                        retVal.Add(tempEmp);
                    }
                }
            }


            return(View(retVal));
        }