Пример #1
0
        // GET: Shoes/Details/5
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Sho sho = db.Shoes.Find(id);

            if (sho == null)
            {
                return(HttpNotFound());
            }
            return(View(sho));
        }
Пример #2
0
 public ActionResult Edit([Bind(Include = "ShoesID,Name,PhotoID,Type,ColorID,SeasonID,OccasionID")] Sho sho)
 {
     if (ModelState.IsValid)
     {
         db.Entry(sho).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.ColorID    = new SelectList(db.Colors, "ColorID", "Color1", sho.ColorID);
     ViewBag.OccasionID = new SelectList(db.Occasions, "OccasionID", "Occasion1", sho.OccasionID);
     ViewBag.PhotoID    = new SelectList(db.Photos, "PhotoID", "Photo1", sho.PhotoID);
     ViewBag.SeasonID   = new SelectList(db.Seasons, "SeasonID", "Season1", sho.SeasonID);
     return(View(sho));
 }
Пример #3
0
        public ActionResult Create([Bind(Include = "ShoeID,ShoeName,ShoePhoto,ShoeType,ColorID,SeasonID,OccasionID")] Sho sho)
        {
            if (ModelState.IsValid)
            {
                db.Shoes.Add(sho);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.ColorID    = new SelectList(db.Colors, "ColorID", "ColorName", sho.ColorID);
            ViewBag.OccasionID = new SelectList(db.Occasions, "OccasionID", "OccasionName", sho.OccasionID);
            ViewBag.SeasonID   = new SelectList(db.Seasons, "SeasonID", "SeasonName", sho.SeasonID);
            return(View(sho));
        }
Пример #4
0
 public ActionResult Edit([Bind(Include = "ShoesID,ShoeName,ShoePhoto,ShoeTypeID,ShoeColorID,ShoeSeasonID,ShoeOccassionID")] Sho sho)
 {
     if (ModelState.IsValid)
     {
         db.Entry(sho).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.ShoeColorID     = new SelectList(db.ShoeColors, "ShoeColorID", "ShoeColorName", sho.ShoeColorID);
     ViewBag.ShoeOccassionID = new SelectList(db.ShoeOccasions, "ShoeOccasionID", "ShoeOccassionName", sho.ShoeOccassionID);
     ViewBag.ShoeSeasonID    = new SelectList(db.ShoeSeasons, "ShoeSeasonID", "ShoeSeasonName", sho.ShoeSeasonID);
     ViewBag.ShoeTypeID      = new SelectList(db.ShoeTypes, "ShoeTypeID", "ShoeTypeName", sho.ShoeTypeID);
     return(View(sho));
 }
Пример #5
0
        // GET: Shoes/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Sho sho = db.Shoes.Find(id);

            if (sho == null)
            {
                return(HttpNotFound());
            }
            ViewBag.ShoeTypeID = new SelectList(db.ShoeTypes, "ShoeTypeID", "TypeName", sho.ShoeTypeID);
            return(View(sho));
        }
Пример #6
0
        public ActionResult Create([Bind(Include = "ShoeId,ShoeName,ShoePhoto,ShoeTypeId,ShoeColorId,ShoeSeasonId,ShoeOccasionId,ShoeNotes")] Sho sho)
        {
            if (ModelState.IsValid)
            {
                db.Shoes.Add(sho);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.ShoeColorId    = new SelectList(db.ShoeColors, "ShoeColorId", "ShoeColorName", sho.ShoeColorId);
            ViewBag.ShoeOccasionId = new SelectList(db.ShoeOccasions, "ShoeOccasionId", "ShoeOccasion1", sho.ShoeOccasionId);
            ViewBag.ShoeSeasonId   = new SelectList(db.ShoeSeasons, "ShoeSeasonId", "ShoeSeason1", sho.ShoeSeasonId);
            ViewBag.ShoeTypeId     = new SelectList(db.ShoeTypes, "ShoeTypeId", "ShoeType1", sho.ShoeTypeId);
            return(View(sho));
        }
Пример #7
0
        public ActionResult Create([Bind(Include = "ShoesID,Name,ShoeSizeID,PhotoID,SeasonID,OccasionID")] Sho sho)
        {
            if (ModelState.IsValid)
            {
                db.Shoes.Add(sho);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.OccasionID = new SelectList(db.Occasions, "OccasionID", "Occasion1", sho.OccasionID);
            ViewBag.PhotoID    = new SelectList(db.Photos, "PhotoID", "Photo1", sho.PhotoID);
            ViewBag.SeasonID   = new SelectList(db.Seasons, "SeasonID", "Season1", sho.SeasonID);
            ViewBag.ShoeSizeID = new SelectList(db.ShoeSizes, "ShoeSizeID", "ShoeSizeID", sho.ShoeSizeID);
            return(View(sho));
        }
Пример #8
0
 //get sizes of specific shoe by id
 public static int[] GetSizesById(int id)
 {
     using (DB_shoesEntities5 db = new DB_shoesEntities5())
     {
         Sho   s         = db.Shoes.First(sh => sh.id_shoe == id);
         int   from_size = s.from_size.Value;
         int   to_size   = s.to_size.Value;
         int[] sizes     = new int[to_size - from_size + 1];
         for (int i = 0; i < sizes.Length; i++)
         {
             sizes[i] = from_size++;
         }
         return(sizes);
     }
 }
Пример #9
0
 public static int[] GetSizes()
 {
     using (DB_shoesEntities5 db = new DB_shoesEntities5())
     {
         Sho   sh       = new Sho();
         int   fromsize = 34;
         int   tosize   = 42;
         int[] size     = new int[tosize - fromsize + 1];
         for (int i = 0; i < size.Length; i++)
         {
             size[i] = fromsize++;
         }
         return(size);
     }
 }
Пример #10
0
        // GET: Shoes/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Sho sho = db.Shoes.Find(id);

            if (sho == null)
            {
                return(HttpNotFound());
            }
            ViewBag.BottomID = new SelectList(db.Bottoms, "BottomID", "BottomName", sho.BottomID);
            ViewBag.TopID    = new SelectList(db.Tops, "TopID", "TopName", sho.TopID);
            return(View(sho));
        }
Пример #11
0
        // GET: Shoes/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Sho sho = db.Shoes.Find(id);

            if (sho == null)
            {
                return(HttpNotFound());
            }
            ViewBag.OccasionID = new SelectList(db.Occasions, "OccasionID", "Occasion1", sho.OccasionID);
            ViewBag.SeasonID   = new SelectList(db.Seasons, "SeasonID", "Season1", sho.SeasonID);
            return(View(sho));
        }
Пример #12
0
        //get al the details of specific shoe by id
        public static shoeDetails GetDetailsById(int id)
        {
            using (DB_shoesEntities5 db = new DB_shoesEntities5())
            {
                try
                {
                    int         idBranch = 1;
                    Sho         s        = db.Shoes.First(sh => sh.id_shoe == id);
                    shoeDetails shoe     = new shoeDetails();
                    //set img
                    shoe.img = s.picture;
                    //set sizes
                    int   from_size = s.from_size.Value;
                    int   to_size   = s.to_size.Value;
                    int[] sizes     = new int[to_size - from_size + 1];
                    for (int i = 0; i < sizes.Length; i++)
                    {
                        sizes[i] = from_size++;
                    }
                    shoe.sizes = sizes;
                    //set coloers
                    shoe.colors = s.Colors.Select(sh => sh.color1).ToList().ToArray();
                    //set price
                    shoe.price = Int32.Parse(s.price.ToString());
                    //find sale
                    try
                    {
                        List <Sale> l       = db.Stocks.First(s1 => s1.id_shoe == id && s1.id_branch == idBranch).Sales.ToList();
                        Sale        minSale = l.OrderBy(s2 => s2.precent_sale).First(s3 => s3.start_date <= DateTime.Now && s3.end_date >= DateTime.Now);
                        shoe.salePrice = (double)(shoe.price * (1 - minSale.precent_sale));
                        shoe.saleName  = minSale.description_sale;
                    }
                    catch (Exception e)
                    {
                        shoe.salePrice = shoe.price;
                        shoe.saleName  = "no sale now";
                    }

                    return(shoe);
                }
                catch (Exception e)
                {
                    return(null);
                }
            }
        }
Пример #13
0
        // GET: Shoes/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Sho sho = db.Shoes.Find(id);

            if (sho == null)
            {
                return(HttpNotFound());
            }
            ViewBag.ShoeColorId    = new SelectList(db.ShoeColors, "ShoeColorId", "ShoeColorName", sho.ShoeColorId);
            ViewBag.ShoeOccasionId = new SelectList(db.ShoeOccasions, "ShoeOccasionId", "ShoeOccasion1", sho.ShoeOccasionId);
            ViewBag.ShoeSeasonId   = new SelectList(db.ShoeSeasons, "ShoeSeasonId", "ShoeSeason1", sho.ShoeSeasonId);
            ViewBag.ShoeTypeId     = new SelectList(db.ShoeTypes, "ShoeTypeId", "ShoeType1", sho.ShoeTypeId);
            return(View(sho));
        }
Пример #14
0
        public ActionResult Create([Bind(Include = "ShoeID,ShoeName,ShoeTypeID,ColorID,SeasonID,OccasionID,ShoeImage")] Sho sho)
        {
            //bypasses error if no input in image link input editor
            if (sho.ShoeImage == null)
            {
                sho.ShoeImage = "https://upload.wikimedia.org/wikipedia/commons/a/ac/No_image_available.svg";
            }

            if (ModelState.IsValid)
            {
                db.Shoes.Add(sho);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.ColorID    = new SelectList(db.Colors, "ColorID", "ColorName", sho.ColorID);
            ViewBag.OccasionID = new SelectList(db.Occasions, "OccasionID", "OccasionName", sho.OccasionID);
            ViewBag.SeasonID   = new SelectList(db.Seasons, "SeasonID", "SeasonName", sho.SeasonID);
            ViewBag.ShoeTypeID = new SelectList(db.ShoeTypes, "ShoeTypeID", "ShoeTypeName", sho.ShoeTypeID);
            return(View(sho));
        }
Пример #15
0
        public ActionResult Product(int id)
        {
            var ListShoes       = db.Shoes.ToList();
            var ListShoesDetail = db.ShoesDetails.ToList();
            Sho shose           = new Sho();
            int isFinded        = 0;

            foreach (Sho item in ListShoes)
            {
                if (item.idShoes == id)
                {
                    shose = item;
                    isFinded++;
                    break;
                }
            }
            if (isFinded == 0)
            {
                return(RedirectToRoute("AllProducts"));
            }
            ViewBag.Shose = shose;
            return(View());
        }
Пример #16
0
        // GET: Shoes/Details/5
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Sho sho = db.Shoes.Find(id);

            if (sho == null)
            {
                return(HttpNotFound());
            }

            if (sho.ShoesName == "Sneakers")
            {
                ViewBag.ShoePhoto = "/Content/Images/Sneakers.jpg";
            }

            if (sho.ShoesName == "Oxfords")
            {
                ViewBag.ShoePhoto = "/Content/Images/Oxfords.jpg";
            }

            if (sho.ShoesName == "Sandals")
            {
                ViewBag.ShoePhoto = "/Content/Images/Sandals.jpg";
            }

            if (sho.ShoesName == "Vibram Five Fingers")
            {
                ViewBag.ShoePhoto = "/Content/Images/VibramFiveFingers.jpg";
            }


            return(View(sho));
        }