コード例 #1
0
        public ActionResult UrunDetay(Nullable <int> id)
        {
            if (id == null)
            {
                // id null ise bu hatayı ver.
                return(new HttpStatusCodeResult(System.Net.HttpStatusCode.BadRequest));
            }

            Products product = db.Products.Find(id);

            if (product == null)
            {
                // ürün bulunamazsa ise bu hatayı ver.
                return(new HttpStatusCodeResult(System.Net.HttpStatusCode.NotFound));
            }

            UrunDetayViewModel model = new UrunDetayViewModel();

            model.Product = product;

            if (cm.HasCache() == false)
            {
                cm.Set(db.Categories.ToList());
            }

            model.CategoryList = cm.Get();

            return(View(model));
        }
コード例 #2
0
ファイル: HomeController.cs プロジェクト: berfuu/OnlineSatis
        public ActionResult UrunDetay(int id)
        {
            UrunDetayViewModel urunDetay = new UrunDetayViewModel();

            urunDetay.Urun         = db.Urun.Where(x => x.UrunId == id).SingleOrDefault();
            urunDetay.UrunYorumlar = db.UrunYorum.Where(x => x.UrunId == id).ToList();
            var variantsFromDb = db.UrunVaryant.Where(u => u.UrunId == id).ToList();

            foreach (var item in variantsFromDb)
            {
                urunDetay.urunVaryantları.Add(item.Label, item.Value);
            }
            urunDetay.urunler = db.Urun.Take(4).ToList();
            return(View(urunDetay));
        }
コード例 #3
0
        public ActionResult UrunDetay(int?id, UrunDetayViewModel model)
        {
            if (id == null)
            {
                // id null ise bu hatayı ver.
                return(new HttpStatusCodeResult(System.Net.HttpStatusCode.BadRequest));
            }

            Products product = db.Products.Find(id);

            if (product == null)
            {
                // ürün bulunamazsa ise bu hatayı ver.
                return(new HttpStatusCodeResult(System.Net.HttpStatusCode.NotFound));
            }

            SiteUsers user = null;

            if (Session["kullanici"] != null)
            {
                user = Session["kullanici"] as SiteUsers;
            }

            if (Session["admin"] != null)
            {
                user = Session["admin"] as SiteUsers;
            }

            Comments comment = new Comments();

            comment.Products  = product;
            comment.Nickname  = user.Name + " " + user.Surname;
            comment.CreatedOn = DateTime.Now;
            comment.Text      = model.CommentOnText;
            comment.IsValid   = false;

            db.Comments.Add(comment);
            db.SaveChanges();

            return(RedirectToAction("UrunDetay"));
        }
コード例 #4
0
        private void btnSepeteEkle_Click(object sender, EventArgs e)
        {
            if (lstUrunler.SelectedItem == null)
            {
                MessageBox.Show("Öncelikle Sol Taraftan Ürün Seçiniz");
                return;
            }
            UrunDetayViewModel seciliUrun = lstUrunler.SelectedItem as UrunDetayViewModel;
            bool varMi = false;

            foreach (var item in sepetUrunler)
            {
                if (seciliUrun.UrunId == item.PF_UrunId)
                {
                    varMi = true;
                    break;
                }
            }
            if (varMi)
            {
                sepetUrunler.Where(x => x.PF_UrunId == seciliUrun.UrunId).FirstOrDefault().Adet += Convert.ToInt32(nAdet.Value);
                sepetDoldur();
            }
            else
            {
                sepetUrunler.Add(new SepetViewModel()
                {
                    UrunAdi     = seciliUrun.UrunAdi,
                    Adet        = Convert.ToInt32(nAdet.Value),
                    SepetFiyati = Convert.ToDecimal(seciliUrun.UrunFiyati),
                    PF_UrunId   = seciliUrun.UrunId,
                    KategoriId  = seciliUrun.KategoriId,
                });
                sepetDoldur();
            }

            cbRestoran.Enabled = false;
        }
コード例 #5
0
        public ActionResult UrunDetay(Guid urunId)
        {
            ProductManager productManager = new ProductManager();
            Product        product        = productManager.UrunGetir(urunId);

            UrunDetayViewModel urunDetayViewModel = new UrunDetayViewModel()
            {
                productId        = product.id,
                price            = product.Price,
                cost             = product.Cost,
                productImage     = product.ProductImage,
                longdescription  = product.LongDescription,
                productName      = product.ProductName,
                shortdescription = product.ShortDescription,
                productCategory  = product.ProductCategory.Select(x => x.Category.CategoryName).ToList(),
                productDetails   = product.ProductSize.Select(x => new ProductDetail()
                {
                    size         = x.Size,
                    productColor = x.ProductColor.Select(y => new productColor()
                    {
                        productImageGallery = y.ProdutImageGallery.Select(t => new productImageGallery()
                        {
                            imagePath   = t.ImagePath,
                            colorDetail = t.ProductColor.ProductColorDetail.Select(l => new colorDetail()
                            {
                                colorCode = l.Color.ColorCode,
                                colorName = l.Color.ColorName
                            }).ToList()
                        }).ToList()
                    }).ToList()
                }).ToList()
            };



            return(View(urunDetayViewModel));
        }