public ActionResult Insert(Product item, Guid id)
        {
            ViewBag.CategoryID      = new SelectList(cats.GetActive(), "ID", "CategoryName", item.CategoryID);
            ViewBag.SubCategoryID   = new SelectList(scats.GetDefault(m => m.CategoryID == item.CategoryID), "ID", "SubCategoryName", item.SubCategoryID);
            ViewBag.ThirdCategoryID = new SelectList(tcats.GetDefault(m => m.SubCategoryID == item.SubCategoryID), "ID", "ThirdCategoryName", item.ThirdCategoryID);
            ViewBag.BrandID         = new SelectList(brs.GetActive(), "ID", "Name", item.BrandID);
            item.AppUserID          = id;
            ViewData["ProductID"]   = item.ID;
            bool result = ps.Add(item);

            if (result)
            {
                return(RedirectToAction("Insert", "ProductDetail", new { id = item.ID }));
            }
            ViewBag.Message = "Ekleme İşlemi Başarısız";
            return(View());
        }
Exemple #2
0
        public ActionResult Index(Guid?id, string arama, string sirala, string filtre)
        {
            if (Session["oturum"] != null)
            {
                gelen             = (AppUser)Session["oturum"];
                ViewBag.AppUserID = gelen.ID;
            }
            else if (Session["admin"] != null)
            {
                gelen             = (AppUser)Session["admin"];
                ViewBag.AppUserID = gelen.ID;
            }
            ViewData["category"]      = cs.GetDefault(m => m.Status != Core.Entity.Enum.Status.Deleted);
            ViewData["subcategory"]   = ss.GetDefault(m => m.Status != Core.Entity.Enum.Status.Deleted);
            ViewData["thirdcategory"] = ts.GetDefault(m => m.Status != Core.Entity.Enum.Status.Deleted);
            ViewBag.ProductImage      = imgs.GetDefault(m => m.Status != Core.Entity.Enum.Status.Deleted);
            if (sirala == "İsim")
            {
                List <Product> sirList = ps.GetDefault(m => m.Status != Core.Entity.Enum.Status.Deleted);

                return(View(sirList.OrderBy(m => m.ProductName).ToList()));
            }
            else if (sirala == "Fiyat")
            {
                List <Product> sirList = ps.GetDefault(m => m.Status != Core.Entity.Enum.Status.Deleted);

                return(View(sirList.OrderBy(m => m.UnitPrice).ToList()));
            }
            if (filtre != null)
            {
                List <Product> filtlist = new List <Product>();
                switch (filtre)
                {
                case "Yeşil":
                    foreach (ProductDetail item in pds.GetDefault(m => m.Colour.ProductColour == "Yeşil" && m.Status != Core.Entity.Enum.Status.Deleted))
                    {
                        Product gelenurun = ps.GetByID(item.ProductID);
                        filtlist.Add(gelenurun);
                    }
                    if (filtlist.Count > 0)
                    {
                        return(View(filtlist.ToList()));
                    }
                    else
                    {
                        break;
                    }

                case "Beyaz":
                    foreach (ProductDetail item in pds.GetDefault(m => m.Colour.ProductColour == "Beyaz" && m.Status != Core.Entity.Enum.Status.Deleted))
                    {
                        Product gelenurun = ps.GetByID(item.ProductID);
                        filtlist.Add(gelenurun);
                    }
                    if (filtlist.Count > 0)
                    {
                        return(View(filtlist.ToList()));
                    }
                    else
                    {
                        break;
                    }

                case "Gri":
                    foreach (ProductDetail item in pds.GetDefault(m => m.Colour.ProductColour == "Gri" && m.Status != Core.Entity.Enum.Status.Deleted))
                    {
                        Product gelenurun = ps.GetByID(item.ProductID);
                        filtlist.Add(gelenurun);
                    }
                    if (filtlist.Count > 0)
                    {
                        return(View(filtlist.ToList()));
                    }
                    else
                    {
                        break;
                    }

                case "Mavi":
                    foreach (ProductDetail item in pds.GetDefault(m => m.Colour.ProductColour == "Mavi" && m.Status != Core.Entity.Enum.Status.Deleted))
                    {
                        Product gelenurun = ps.GetByID(item.ProductID);
                        filtlist.Add(gelenurun);
                    }
                    if (filtlist.Count > 0)
                    {
                        return(View(filtlist.ToList()));
                    }
                    else
                    {
                        break;
                    }

                case "Siyah":
                    foreach (ProductDetail item in pds.GetDefault(m => m.Colour.ProductColour == "Siyah" && m.Status != Core.Entity.Enum.Status.Deleted))
                    {
                        Product gelenurun = ps.GetByID(item.ProductID);
                        filtlist.Add(gelenurun);
                    }
                    if (filtlist.Count > 0)
                    {
                        return(View(filtlist.ToList()));
                    }
                    else
                    {
                        break;
                    }

                case "Small":
                    foreach (ProductDetail item in pds.GetDefault(m => m.SizeTo.ProductSize == "Small" || m.SizeTo.ProductSize == "S" && m.Status != Core.Entity.Enum.Status.Deleted))
                    {
                        Product gelenurun = ps.GetByID(item.ProductID);
                        filtlist.Add(gelenurun);
                    }
                    if (filtlist.Count > 0)
                    {
                        return(View(filtlist.ToList()));
                    }
                    else
                    {
                        break;
                    }

                case "Medium":
                    foreach (ProductDetail item in pds.GetDefault(m => m.SizeTo.ProductSize == "Medium" || m.SizeTo.ProductSize == "M" && m.Status != Core.Entity.Enum.Status.Deleted))
                    {
                        Product gelenurun = ps.GetByID(item.ProductID);
                        filtlist.Add(gelenurun);
                    }
                    if (filtlist.Count > 0)
                    {
                        return(View(filtlist.ToList()));
                    }
                    else
                    {
                        break;
                    }

                case "Large":
                    foreach (ProductDetail item in pds.GetDefault(m => m.SizeTo.ProductSize == "Large" || m.SizeTo.ProductSize == "L" && m.Status != Core.Entity.Enum.Status.Deleted))
                    {
                        Product gelenurun = ps.GetByID(item.ProductID);
                        filtlist.Add(gelenurun);
                    }
                    if (filtlist.Count > 0)
                    {
                        return(View(filtlist.ToList()));
                    }
                    else
                    {
                        break;
                    }

                case "0-100":

                    foreach (Product item in ps.GetDefault(m => m.UnitPrice > 0 && m.UnitPrice < 100 && m.Status != Core.Entity.Enum.Status.Deleted))
                    {
                        filtlist.Add(item);
                    }
                    if (filtlist.Count > 0)
                    {
                        return(View(filtlist.ToList()));
                    }
                    else
                    {
                        break;
                    }

                case "100+":
                    foreach (Product item in ps.GetDefault(m => m.UnitPrice > 100 && m.Status != Core.Entity.Enum.Status.Deleted))
                    {
                        filtlist.Add(item);
                    }
                    if (filtlist.Count > 0)
                    {
                        return(View(filtlist.ToList()));
                    }
                    else
                    {
                        break;
                    }
                }
            }
            if (arama != null)
            {
                if (ps.GetDefault(m => m.ProductName.Contains(arama)).Count > 0)
                {
                    ViewBag.AramaSonucSayisi = ps.GetDefault(m => m.ProductName.Contains(arama)).Count;
                    return(View(ps.GetDefault(m => m.ProductName.Contains(arama) && m.Status != Core.Entity.Enum.Status.Deleted)));
                }

                ViewBag.UrunBulunamadi = "Üzgünüz aradığınız ürün sitemizde mevcut değildir";
                return(View(ps.GetDefault(m => m.ProductName.Contains(arama) && m.Status != Core.Entity.Enum.Status.Deleted)));
            }
            if (id != null)
            {
                if (ps.GetDefault(m => m.CategoryID == id).Count > 0)
                {
                    return(View(ps.GetDefault(m => m.CategoryID == id && m.Status != Core.Entity.Enum.Status.Deleted)));
                }
                else if (ps.GetDefault(m => m.SubCategoryID == id && m.Status != Core.Entity.Enum.Status.Deleted).Count > 0)
                {
                    return(View(ps.GetDefault(m => m.SubCategoryID == id && m.Status != Core.Entity.Enum.Status.Deleted)));
                }
                else if (ps.GetDefault(m => m.ThirdCategoryID == id && m.Status != Core.Entity.Enum.Status.Deleted).Count > 0)
                {
                    return(View(ps.GetDefault(m => m.ThirdCategoryID == id && m.Status != Core.Entity.Enum.Status.Deleted)));
                }
                else
                {
                    ViewBag.UrunBulunamadi = "Üzgünüz aradığınız kategoride sitemizde ürün mevcut değildir";
                }
            }


            return(View(ps.GetDefault(m => m.Status != Core.Entity.Enum.Status.Deleted)));
        }
 public ActionResult Index(Guid id)
 {
     return(View(ts.GetDefault(m => m.SubCategoryID == id)));
 }