示例#1
0
        private string AddNameOftypes(ProducLIst itemVM, int id, int v)
        {
            if (v == 2)
            {
                TypeServise servise = new TypeServise();
                string      items   = "";
                if (itemVM.Items[id].Type == 0)
                {
                    items = "";
                }
                else
                {
                    var element = servise.GetByID(itemVM.Items[id].Type);
                    items = element.Name;
                }

                return(items);
            }
            else
            {
                BaseTypeServise servise = new BaseTypeServise();
                string          items   = "";

                if (itemVM.Items[id].Basetype == 0)
                {
                    items = "";
                }
                else
                {
                    var element = servise.GetByID(itemVM.Items[id].Basetype);
                    items = element.Name;
                }
                return(items);
            }
        }
示例#2
0
        public ActionResult ListProducts(int Curentpage)
        {
            ProducLIst itemVM = new ProducLIst();

            itemVM = PopulateIndex(itemVM, Curentpage);
            return(View(itemVM));
        }
示例#3
0
        public ActionResult Index(string search)
        {
            ProducLIst itemVM = new ProducLIst();

            if (search != null)
            {
                _search = search;
                string[]       keys = search.Split(' ');
                List <Product> list = new List <Product>();

                list          = _productServise.GetAll(x => x.Title.ToLower().Contains(keys[0].ToLower()));
                itemVM.Filter = new PruductFilter();
                if (keys.Length == 1)
                {
                    foreach (var item in list)
                    {
                        itemVM.Items.Add(item);
                    }
                }
                else
                {
                    itemVM = Check(keys, list, 1, itemVM);
                }

                return(View(itemVM));
            }

            return(View(itemVM));
        }
示例#4
0
 public ActionResult ListProduct(string Curentpage)
 {
     itemVM        = new ProducLIst();
     itemVM.Filter = new PruductFilter();
     itemVM        = GetElement(itemVM, int.Parse(Curentpage));
     return(View(itemVM));
 }
示例#5
0
        public ActionResult Orders()
        {
            Random rd = new Random();

            _orderNumber = rd.Next(0, 999999);
            ViewData["NumberOfOrder"] = _orderNumber;
            Session["OrderNumber"]    = _orderNumber.ToString();
            string     productsId = Session["OrderProduct"].ToString();
            string     quantities = Session["ProductQuantity"].ToString();
            ProducLIst itemVM     = new ProducLIst();

            if (productsId == null || productsId == "" &&
                quantities == null || quantities == "")
            {
                return(View(itemVM));
            }
            else
            {
                string[] keyProduct  = productsId.Split(',');
                string[] keyQuantity = quantities.Split(',');

                for (int i = 0; i < keyProduct.Length - 1; i++)
                {
                    Product entity   = _product.GetByID(int.Parse(keyProduct[i]));
                    int     quantity = entity.Quantity;
                    GenericSelectedList <Order> listUser = new GenericSelectedList <Order>();

                    itemVM.Qua = listUser.GetSelectedListIthemQuantity(quantity);
                    itemVM.Items.Add(_product.GetByID(int.Parse(keyProduct[i])));
                    itemVM.Items[i].Quantity = int.Parse(keyQuantity[i]);
                }

                return(View(itemVM));
            }
        }
 public ActionResult Index(int Curentpage)
 {
     itemVM        = new ProducLIst();
     itemVM.Filter = new PruductFilter();
     itemVM        = GetElement(itemVM, Curentpage);
     if (Request.Cookies["ViewProducr"] == null ||
         Request.Cookies["ViewProducr"] == "")
     {
         Response.Cookies.Append("ViewProducr", "2");
     }
     return(View(itemVM));
 }
示例#7
0
        public ActionResult ProductIndex(int Curentpage)
        {
            ProducLIst itemVM = new ProducLIst();

            itemVM = PopulateIndex(itemVM, Curentpage);
            string controllerNAme = GetControlerName();

            HttpCookie cookie      = HttpContext.Request.Cookies["ViewProduct"];
            string     cookieValue = cookie["ViewProduct"];

            ViewBag.Cookie = cookieValue;
            return(View(itemVM));
        }
示例#8
0
        public ActionResult Index(int Curentpage)
        {
            itemVM        = new ProducLIst();
            itemVM.Filter = new PruductFilter();
            itemVM        = GetElement(itemVM, Curentpage);
            HttpCookie cookie = HttpContext.Request.Cookies["ViewProduct"];

            if (cookie["ViewProduct"] == null ||
                cookie["ViewProduct"] == "")
            {
                cookie["ViewProduct"] = "2";
            }
            return(View(itemVM));
        }
示例#9
0
        public ActionResult Index()
        {
            //LoginServise _login = new LoginServise();
            //if (!_login.CheckForAdmin())
            //{
            //    return Redirect("Login/Registration");
            //}

            ProducLIst itemVM = new ProducLIst();

            itemVM = PopulateIndex(itemVM);

            return(View(itemVM));
        }
示例#10
0
 public ProducLIst Check(string[] keys, List <Product> list, int i, ProducLIst itemVM)
 {
     try
     {
         List <Product> newResult = new List <Product>();
         newResult = list.Where(x => x.Title.ToLower().Contains(keys[i].ToLower())).ToList();
         if (i == keys.Length - 1)
         {
             foreach (var item in newResult)
             {
                 itemVM.Items.Add(item);
             }
             return(itemVM);
         }
         i++;
         Check(keys, newResult, i, itemVM);
     }
     catch (ArgumentOutOfRangeException ex)
     {
     }
     return(itemVM);
 }
示例#11
0
        protected virtual ProducLIst PopulateIndex(ProducLIst itemVM, int curentPage)
        {
            string controllerName = GetControlerName();
            string actionname     = GetActionName();

            itemVM.ControllerName = controllerName;
            itemVM.ActionName     = actionname;
            if (_code != null)
            {
                itemVM.AllItems = _product.GetAll(x => x.Code.Contains(_code));
            }
            else
            {
                itemVM.AllItems = _product.GetAll();
            }
            itemVM.Pages = itemVM.AllItems.Count / 12;
            double doublePages = itemVM.AllItems.Count / 12.0;

            if (doublePages > itemVM.Pages)
            {
                itemVM.Pages++;
            }
            itemVM.StartItem = 12 * curentPage;
            try
            {
                for (int i = itemVM.StartItem - 12; i < itemVM.StartItem; i++)
                {
                    itemVM.Items.Add(itemVM.AllItems[i]);
                    itemVM.BaseTypeName.Add(AddNameOftypes(itemVM, i, 1));
                    itemVM.TypeName.Add(AddNameOftypes(itemVM, i, 2));
                }
            }
            catch (ArgumentOutOfRangeException ex)
            {
            }

            return(itemVM);
        }
示例#12
0
        private ProducLIst GetElement(ProducLIst itemVM, int curentPage)
        {
            string controllerName = GetControlerName();
            string actionname     = GetActionName();

            itemVM.ControllerName = controllerName;
            itemVM.ActionName     = actionname;
            List <Product> list = new List <Product>();

            list = FilterProducts();


            if (_sort == 1)
            {
                if (list == null)
                {
                    itemVM.AllItems = _productServise.GetAll().OrderBy(x => x.Price).ToList();
                }
                else
                {
                    itemVM.AllItems = list.OrderBy(x => x.Price).ToList();
                }
            }
            else if (_sort == 2)
            {
                if (list == null)
                {
                    itemVM.AllItems = _productServise.GetAll().OrderByDescending(x => x.Price).ToList();
                }
                else
                {
                    itemVM.AllItems = list.OrderByDescending(x => x.Price).ToList();
                }
            }
            else
            {
                if (list == null)
                {
                    itemVM.AllItems = _productServise.GetAll().OrderBy(x => x.Date).ToList();
                }
                else
                {
                    itemVM.AllItems = list.OrderBy(x => x.Date).ToList();
                }
            }



            itemVM.Pages = itemVM.AllItems.Count / 12;
            double doublePages = itemVM.AllItems.Count / 12.0;

            if (doublePages > itemVM.Pages)
            {
                itemVM.Pages++;
            }
            itemVM.StartItem = 12 * curentPage;
            try
            {
                for (int i = itemVM.StartItem - 12; i < itemVM.StartItem; i++)
                {
                    itemVM.Items.Add(itemVM.AllItems[i]);
                }
            }
            catch (ArgumentOutOfRangeException ex)
            {
            }



            return(itemVM);
        }
示例#13
0
 private ProducLIst PopulateIndex(ProducLIst itemVM)
 {
     //itemVM.Items = _product.GetAll(x => x.Front == 1);
     return(itemVM);
 }