Exemplo n.º 1
0
 public ActionResult Search()
 {
     //SelectList categories = new SelectList(db.Catgories, "id_catgory", "catgory");
     //SelectListItem selected = categories.Where(x => x.Value == "4").First();
     //selected.Selected = true;
     //SelectListItem g= categories.Where(p => p.Selected == true).First();
     //ViewBag.id_catgory = categories;
     if (Session["searchDetails"] != null)
     {
         SearchDetails details = (Session["searchDetails"] as SearchDetails);
         ViewBag.id_catgory  = new SelectList(db.Catgories, "id_catgory", "catgory", details.id_catgory);
         ViewBag.id_season   = new SelectList(db.Seasons, "id_season", "season", details.id_season);
         ViewBag.color       = new SelectList(db.Colors, "id_color", "color", details.color);
         ViewBag.stringSizes = details.stringSizes.Split(' ').ToArray();
         ViewBag.price       = details.price;
         //MainSearch(details.id_catgory, details.id_season, details.price, details.stringSizes, details.is_long, details.is_light, details.color);
     }
     else
     {
         ViewBag.id_catgory = new SelectList(db.Catgories, "id_catgory", "catgory");
         ViewBag.id_renter  = new SelectList(db.Renters, "id_renter", "fname");
         ViewBag.id_season  = new SelectList(db.Seasons, "id_season", "season");
         ViewBag.id_season  = new SelectList(db.Seasons, "id_season", "season");
         ViewBag.id_set     = new SelectList(db.Sets, "id_set", "id_set");
         ViewBag.color      = new SelectList(db.Colors, "id_color", "color");
         ViewBag.price      = 250;
         ViewBag.is_light   = false;
         ViewBag.is_dark    = false;
         ViewBag.is_long    = false;
         ViewBag.is_short   = false;
     }
     return(View());
 }
Exemplo n.º 2
0
        public ActionResult MainSearch(int?id_catgory, int?id_season, int?price, string stringSizes, string is_long, string is_light, int?color)
        {
            SearchDetails searchDetails = new SearchDetails()
            {
                color = color, id_catgory = id_catgory, id_season = id_season, is_light = is_light, is_long = is_long, price = price, stringSizes = stringSizes
            };

            if (Session["searchDetails"] == null)
            {
                Session["searchDetails"] = new SearchDetails();
                Session["searchDetails"] = searchDetails;
            }
            else
            {
                Session["searchDetails"] = searchDetails;
            }

            List <Gowns> listAfterCheckLight = new List <Gowns>();
            List <Gowns> listAfterCheckLong  = new List <Gowns>();
            List <Gowns> listAfterCheckColor = new List <Gowns>();
            List <Gowns> MainSearchResult    = db.Gowns.Where(p => p.id_catgory == id_catgory && p.id_season == id_season && p.price <price + 50 && p.price> price - 50 && p.is_available == true).ToList();
            List <Gowns> myList = new List <Gowns>();

            //filter by sizes
            if (stringSizes != "")
            {
                string[] arraysizes = stringSizes.Split(' ').ToArray();
                foreach (string size in arraysizes)
                {
                    if (size != "")
                    {
                        foreach (Gowns gown in MainSearchResult)
                        {
                            if (gown.size == int.Parse(size))
                            {
                                myList.Add(gown);
                            }
                        }
                    }
                }
            }
            else
            {
                myList = MainSearchResult;
            }
            if (is_long != "")
            {
                foreach (Gowns gown in myList)
                {
                    if (gown.is_long == true && is_long == "ארוך" || gown.is_long == false && is_long == "קצר")
                    {
                        listAfterCheckLong.Add(gown);
                    }
                }
                myList = listAfterCheckLong;
            }
            if (is_light != "")
            {
                foreach (Gowns gown in myList)
                {
                    if (gown.is_light == true && is_light == "בהיר" || gown.is_light == false && is_light == "כהה")
                    {
                        listAfterCheckLight.Add(gown);
                    }
                }
                myList = listAfterCheckLight;
            }
            if (color != 1)
            {
                foreach (Gowns gown in myList)
                {
                    if (gown.color == color)
                    {
                        listAfterCheckColor.Add(gown);
                    }
                }
                myList = listAfterCheckColor;
            }
            return(PartialView(myList));
        }
Exemplo n.º 3
0
        public ActionResult MainSearch(double?lat, double?lng, DateTime date, int?id_catgory, int?id_season, int?price, string stringSizes, string is_long, string is_light, int?color)
        {
            Session["lat"] = lat;
            Session["lng"] = lng;
            SearchDetails searchDetails = new SearchDetails()
            {
                color = color, id_catgory = id_catgory, id_season = id_season, is_light = is_light, is_long = is_long, price = price, stringSizes = stringSizes, date = date
            };

            if (Session["searchDetails"] == null)
            {
                Session["searchDetails"] = new SearchDetails();
                Session["searchDetails"] = searchDetails;
            }
            else
            {
                Session["searchDetails"] = searchDetails;
            }

            List <Gowns> listAfterCheckLight = new List <Gowns>();
            List <Gowns> listAfterCheckLong  = new List <Gowns>();
            List <Gowns> listAfterCheckColor = new List <Gowns>();
            List <Gowns> listAfterCheckDate  = new List <Gowns>();
            List <Gowns> MainSearchResult    = db.Gowns.Where(p => p.id_catgory == id_catgory && p.id_season == id_season && p.price <price + 50 && p.price> price - 50 && p.is_available == true).ToList();
            List <Gowns> myList = new List <Gowns>();

            //filter by sizes
            if (stringSizes != "")
            {
                string[] arraysizes = stringSizes.Split(' ').ToArray();
                foreach (string size in arraysizes)
                {
                    if (size != "")
                    {
                        foreach (Gowns gown in MainSearchResult)
                        {
                            if (gown.size == int.Parse(size))
                            {
                                myList.Add(gown);
                            }
                        }
                    }
                }
            }
            else
            {
                myList = MainSearchResult;
            }
            if (is_long != "")
            {
                foreach (Gowns gown in myList)
                {
                    if (gown.is_long == true && is_long == "ארוך" || gown.is_long == false && is_long == "קצר")
                    {
                        listAfterCheckLong.Add(gown);
                    }
                }
                myList = listAfterCheckLong;
            }
            if (is_light != "")
            {
                foreach (Gowns gown in myList)
                {
                    if (gown.is_light == true && is_light == "בהיר" || gown.is_light == false && is_light == "כהה")
                    {
                        listAfterCheckLight.Add(gown);
                    }
                }
                myList = listAfterCheckLight;
            }
            if (color != 1)
            {
                foreach (Gowns gown in myList)
                {
                    if (gown.color == color)
                    {
                        listAfterCheckColor.Add(gown);
                    }
                }
                myList = listAfterCheckColor;
            }

            foreach (Gowns gown in myList)
            {
                bool isAvailable = true;
                foreach (Rents rent in db.Rents)
                {
                    TimeSpan t1 = rent.date.Subtract(date);
                    TimeSpan t2 = date.Subtract(rent.date);
                    if (gown.id_gown == rent.id_gown && (t1.TotalDays < 10 && t1.TotalDays >= 0 || t2.TotalDays < 10 && t2.TotalDays >= 0))
                    {
                        isAvailable = false;
                    }
                }
                if (isAvailable == true)
                {
                    listAfterCheckDate.Add(gown);
                }
            }
            return(PartialView(listAfterCheckDate));
        }