Exemplo n.º 1
0
        public ActionResult SearchAllProduct()
        {
            TrSearchViewModel vm = new TrSearchViewModel();

            if (Session["Language"] == null)
            {
                Session["Language"] = ConfigurationManager.AppSettings["Language"];
            }
            string language = Session["Language"].ToString();

            vm.Products = ProductBL.FindAllProduct(language);
            return(PartialView("_PartialTransactionSearch", vm));
        }
Exemplo n.º 2
0
        private ActionResult ProductByCat(string argument, TrSearchViewModel vmodel, string language)
        {
            //search if cat have child cat
            var children = SearchBL.FindCatsChildList(argument, language);

            if (children.Count() == 0)
            {
                vmodel.Products = SearchBL.FindProductListByIdCat(argument, language);
            }
            else
            {
                vmodel.CatsChild = children;
            }
            return(PartialView("_PartialTransactionSearch", vmodel));
        }
Exemplo n.º 3
0
        public ActionResult SearchProduct(string product)
        {
            TrSearchViewModel vm = new TrSearchViewModel();

            try
            {
                if (ModelState.IsValid)
                {
                    if (Session["Language"] == null)
                    {
                        Session["Language"] = ConfigurationManager.AppSettings["Language"];
                    }
                    string language = Session["Language"].ToString();
                    if (int.TryParse(product, out int codeP))
                    {
                        vm.Products = ProductBL.FindAllProductByCode(product, language);
                    }
                    else
                    {
                        vm.Products = ProductBL.FindAllProductByName(product, language);
                    }
                }
                return(PartialView("_PartialTransactionSearch", vm));
            }
            catch (InvalidOperationException ex)
            {
                //to do insert to log file
                var e1 = ex.GetBaseException(); // --> log
                var e4 = ex.Message;            // --> log
                var e5 = ex.Source;             // --> log
                var e8 = ex.GetType();          // --> log
                var e9 = ex.GetType().Name;     // --> log

                ViewBag.ErrorSearch = "N° de produit invalide";
                return(PartialView("_PartialTransactionSearch", vm));
            }
            catch (Exception ex)
            {
                //to do insert to log file
                var e1 = ex.GetBaseException(); // --> log
                var e4 = ex.Message;            // --> log
                var e5 = ex.Source;             // --> log
                var e8 = ex.GetType();          // --> log
                var e9 = ex.GetType().Name;     // --> log

                return(View("Error"));
            }
        }
Exemplo n.º 4
0
        public ActionResult SearchProduct(string product)
        {
            TrSearchViewModel vm = new TrSearchViewModel();

            try
            {
                if (ModelState.IsValid)
                {
                    if (int.TryParse(product, out int codeP))
                    {
                        vm.Products = ProductBL.FindAllProductByCode(product);
                    }
                    else
                    {
                        //to do
                        //vm.Products = TransactionBL.FindAllProductByName(product);
                    }
                }
                return(PartialView("_PartialTransactionSearch", vm));
            }
            catch (InvalidOperationException ex)
            {
                //to do insert to log file
                var e1 = ex.GetBaseException(); // --> log
                var e4 = ex.Message;            // --> log
                var e5 = ex.Source;             // --> log
                var e8 = ex.GetType();          // --> log
                var e9 = ex.GetType().Name;     // --> log

                ViewBag.ErrorSearch = "N° de produit invalide";
                return(PartialView("_PartialTransactionSearch", vm));
            }
            catch (Exception ex)
            {
                //to do insert to log file
                var e1 = ex.GetBaseException(); // --> log
                var e4 = ex.Message;            // --> log
                var e5 = ex.Source;             // --> log
                var e8 = ex.GetType();          // --> log
                var e9 = ex.GetType().Name;     // --> log

                return(View("Error"));
            }
        }
Exemplo n.º 5
0
        public ActionResult SearchBy(string method)
        {
            try
            {
                TrSearchViewModel vm = new TrSearchViewModel();
                if (Session["Language"] == null)
                {
                    Session["Language"] = ConfigurationManager.AppSettings["Language"];
                }
                string language = Session["Language"].ToString();
                string meth     = method.ToLower();
                switch (meth)
                {
                case "brand":
                    return(SearchByBrand(vm));

                case "hero":
                    return(SearchByHero(vm));

                case "age":
                    return(SearchByAge(vm));

                case "cat":
                    return(SearchByCat(vm, language));

                default:
                    ViewBag.ticket = false;
                    return(PartialView("_PartialTransactionSearch", vm));
                }
            }
            catch (Exception ex)
            {
                //to do insert to log file
                var e1 = ex.GetBaseException(); // --> log
                var e4 = ex.Message;            // --> log
                var e5 = ex.Source;             // --> log
                var e8 = ex.GetType();          // --> log
                var e9 = ex.GetType().Name;     // --> log

                return(View("Error"));
            }
        }
Exemplo n.º 6
0
        public ActionResult ProductBy(string method, string argument, TrSearchViewModel vmodel)
        {
            try
            {
                string meth = method.ToLower();
                switch (meth)
                {
                case "brand":
                    return(ProductByBrand(argument, vmodel));

                case "hero":
                    return(ProductByHero(argument, vmodel));

                case "age":
                    return(ProductByAge(argument, vmodel));

                case "cat":
                    return(ProductByCat(argument, vmodel));

                default:
                    ViewBag.ticket = false;
                    return(PartialView("_PartialTransactionSearch", vmodel));
                }
            }
            catch (Exception ex)
            {
                //to do insert to log file
                var e1 = ex.GetBaseException(); // --> log
                var e4 = ex.Message;            // --> log
                var e5 = ex.Source;             // --> log
                var e8 = ex.GetType();          // --> log
                var e9 = ex.GetType().Name;     // --> log

                return(View("Error"));
            }
        }
Exemplo n.º 7
0
 private ActionResult ProductByAge(string argument, TrSearchViewModel vmodel, string language)
 {
     vmodel.Products = SearchBL.FindProductListByIdAge(argument, language);
     return(PartialView("_PartialTransactionSearch", vmodel));
 }
Exemplo n.º 8
0
 private ActionResult SearchByBrand(TrSearchViewModel vm)
 {
     vm.Brands = SearchBL.FindBrandsList();
     return(PartialView("_PartialTransactionSearch", vm));
 }
Exemplo n.º 9
0
 private ActionResult SearchByHero(TrSearchViewModel vm)
 {
     vm.Heros = SearchBL.FindHerosList();
     return(PartialView("_PartialTransactionSearch", vm));
 }
Exemplo n.º 10
0
 private ActionResult SearchByAge(TrSearchViewModel vm)
 {
     vm.Ages = SearchBL.FindAgesList();
     return(PartialView("_PartialTransactionSearch", vm));
 }
Exemplo n.º 11
0
 private ActionResult SearchByCat(TrSearchViewModel vm, string language)
 {
     vm.Cats = SearchBL.FindCatsParentList(language);
     return(PartialView("_PartialTransactionSearch", vm));
 }
Exemplo n.º 12
0
 private ActionResult ProductByCat(string argument, TrSearchViewModel vmodel)
 {
     vmodel.Products = SearchBL.FindProductListByIdCat(argument);
     return(PartialView("_PartialTransactionSearch", vmodel));
 }