Beispiel #1
0
        public ActionResult Index(int? page,  string Pages, Products pro)
        {
            string submit = Request["submit"];
            Dictionary<int, string> searchData = new Dictionary<int, string>();

            if (!(string.IsNullOrEmpty(pro.Loc)))
            {
                searchData.Add(1, pro.Loc);
            }
            if (!(string.IsNullOrEmpty(pro.Type)))
            {
                searchData.Add(2, pro.Type);
            }
            if (!(string.IsNullOrEmpty(pro.Finish)))
            {
                searchData.Add(3, pro.Finish);
            }
            if (!(string.IsNullOrEmpty(pro.Gauge)))
            {
                searchData.Add(4, pro.Gauge);
            }
            if (!(string.IsNullOrEmpty(pro.Width)))
            {
                searchData.Add(5, pro.Width);
            }
            if (!(string.IsNullOrEmpty(pro.WTNET)))
            {
                searchData.Add(6, pro.WTNET);
            }
            if (!(string.IsNullOrEmpty(submit)))
            {
                SearchedData search = new SearchedData();
                search.Filerdata = new FilterData();
                search.Filerdata = search.Filerdata.GetData(User.Identity.GetUserId());
                search.Filerdata.IPAddress = Request.ServerVariables["REMOTE_ADDR"];
                search.Details = searchData;
                search.Filerdata.user_Id = User.Identity.GetUserId();
                search.insert(search);
            }

            pro.ProductList = pro.ProductsList().ToList();

            pro.ProductList = pro.ProductList.Where(a => a.Loc.ToUpper().Contains(string.IsNullOrEmpty(pro.Loc) ? a.Loc : pro.Loc.ToUpper())).
                Where(a => a.Type.ToUpper().Contains(string.IsNullOrEmpty(pro.Type) ? a.Type : pro.Type.ToUpper())).
                Where(a => a.Finish.ToUpper().Contains(string.IsNullOrEmpty(pro.Finish) ? a.Finish : pro.Finish.ToUpper())).
                Where(a => a.Gauge.ToUpper().Contains(string.IsNullOrEmpty(pro.Gauge) ? a.Gauge : pro.Gauge.ToUpper())).
                Where(a => a.Width.ToUpper().Contains(string.IsNullOrEmpty(pro.Width) ? a.Width : (pro.Width.ToUpper()))).
                Where(a => a.WTNET.ToUpper().Contains(string.IsNullOrEmpty(pro.WTNET) ? a.WTNET : (pro.WTNET.ToUpper()))).ToList();

            List<SelectListItem> listitems = new List<SelectListItem>();

            listitems.Add(new SelectListItem { Text = "10 items ", Value = "10" });
            listitems.Add(new SelectListItem { Text = "20 items ", Value = "20" });
            listitems.Add(new SelectListItem { Text = "30 items ", Value = "30" });
            listitems.Add(new SelectListItem { Text = "40 items ", Value = "40" });

            ViewBag.ListItems = listitems;

            if (string.IsNullOrEmpty(Pages))
            {

                pro.IPagedProductsList = pro.ProductList.ToPagedList(page ?? 1, 10);
                return View(pro);
            }
            else
            {
                pro.IPagedProductsList = pro.ProductList.ToPagedList(page ?? 1, Convert.ToInt32(Pages));
                return View(pro);
            }
        }
Beispiel #2
0
        public ActionResult Index(int? page, int? Id, string sortOrder, string Pages, Products pro)
        {
            string submit = Request["submit"];
            ViewBag.Pages = Pages;
            ViewBag.LocSortParm = String.IsNullOrEmpty(sortOrder) ? "Loc_desc" : "";
            ViewBag.TypeSortParm = sortOrder == "Type" ? "Type_desc" : "Type";
            ViewBag.FinishSortParm = sortOrder == "Finish" ? "Finish_desc" : "Finish";
            ViewBag.GaugeSortParm = sortOrder == "Gauge" ? "Gauge_desc" : "Gauge";
            ViewBag.WidthSortParm = sortOrder == "Width" ? "Width_desc" : "Width";
            ViewBag.WTNETSortParm = sortOrder == "WTNET" ? "WTNET_desc" : "WTNET";
            ViewBag.NOOFPCSSortParm = sortOrder == "NOOFPCS" ? "NOOFPCS_desc" : "NOOFPCS";

            pro.ProductList = pro.ProductsList().ToList();

            pro.ProductList = pro.ProductList.Where(a => a.Loc.ToUpper().Contains(string.IsNullOrEmpty(pro.Loc) ? a.Loc : pro.Loc.ToUpper())).
                Where(a => a.Type.ToUpper().Contains(string.IsNullOrEmpty(pro.Type) ? a.Type : pro.Type.ToUpper())).
                Where(a => a.Finish.ToUpper().Contains(string.IsNullOrEmpty(pro.Finish) ? a.Finish : pro.Finish.ToUpper())).
                Where(a => a.Gauge.ToUpper().Contains(string.IsNullOrEmpty(pro.Gauge) ? a.Gauge : pro.Gauge.ToUpper())).
                Where(a => a.Width.ToUpper().Contains(string.IsNullOrEmpty(pro.Width) ? a.Width : (pro.Width.ToUpper()))).
                Where(a => a.WTNET.ToUpper().Contains(string.IsNullOrEmpty(pro.WTNET) ? a.WTNET : (pro.WTNET.ToUpper()))).ToList();

            if (Id.HasValue)
            {
                RequestedQuote quote = new RequestedQuote();
                quote = quote.GetData(User.Identity.GetUserId());
                quote.User_Id = User.Identity.GetUserId();
                quote.product = new Products();
                quote.product = quote.product.productDetails(Id.Value);
                quote.insert(quote);

                var smtpClient = new SmtpClient();
                var message = new MailMessage("*****@*****.**", "*****@*****.**")
                {
                    Subject = "Requested Quote" + quote.product.Loc,
                    Body = "User Name " + User.Identity.GetUserName() + Environment.NewLine + "Phone Nubmer :" + quote.PhoneNumber + Environment.NewLine + "Ip Adderss:" + Request.ServerVariables["REMOTE_ADDR"]

                };
                smtpClient.Send(message);

            }

            switch (sortOrder)
            {
                case "Loc_desc":
                    pro.ProductList = pro.ProductList.OrderByDescending(s => s.Loc).ToList();
                    break;
                case "Finish":
                    pro.ProductList = pro.ProductList.OrderBy(s => s.Finish).ToList();
                    break;
                case "Finish_desc":
                    pro.ProductList = pro.ProductList.OrderByDescending(s => s.Finish).ToList();
                    break;
                case "Gauge":
                    pro.ProductList = pro.ProductList.OrderBy(s => s.Gauge).ToList();
                    break;
                case "Gauge_desc":
                    pro.ProductList = pro.ProductList.OrderByDescending(s => s.Gauge).ToList();
                    break;
                case "Type":
                    pro.ProductList = pro.ProductList.OrderBy(s => s.Type).ToList();
                    break;
                case "Type_desc":
                    pro.ProductList = pro.ProductList.OrderByDescending(s => s.Type).ToList();
                    break;
                case "Width":
                    pro.ProductList = pro.ProductList.OrderBy(s => s.Width).ToList();
                    break;
                case "Width_desc":
                    pro.ProductList = pro.ProductList.OrderByDescending(s => s.Width).ToList();
                    break;

                case "WTNET":
                    pro.ProductList = pro.ProductList.OrderBy(s => s.WTNET).ToList();
                    break;
                case "WTNET_desc":
                    pro.ProductList = pro.ProductList.OrderByDescending(s => s.WTNET).ToList();
                    break;

                case "NOOFPCS":
                    pro.ProductList = pro.ProductList.OrderBy(s => s.NOOFPCS).ToList();
                    break;
                case "NOOFPCS_desc":
                    pro.ProductList = pro.ProductList.OrderByDescending(s => s.NOOFPCS).ToList();
                    break;
                default:
                    pro.ProductList = pro.ProductList.OrderBy(s => s.Loc).ToList();
                    break;
            }

            List<SelectListItem> listitems = new List<SelectListItem>();

            listitems.Add(new SelectListItem { Text = "10 items ", Value = "10" });
            listitems.Add(new SelectListItem { Text = "20 items ", Value = "20" });
            listitems.Add(new SelectListItem { Text = "30 items ", Value = "30" });
            listitems.Add(new SelectListItem { Text = "40 items ", Value = "40" });
            ViewBag.ListItems = listitems;
            if (string.IsNullOrEmpty(Pages))
            {
                pro.IPagedProductsList = pro.ProductList.ToPagedList(page ?? 1, 10);
                return View(pro);
            }
            else
            {
                pro.IPagedProductsList = pro.ProductList.ToPagedList(page ?? 1, Convert.ToInt32(Pages));
                return View(pro);
            }
        }