Exemple #1
0
        public ActionResult SepeteEkle(int id)
        {
            ViewBag.CurrentUser = Session["UserName"];
            ////ViewBag.credits
            //return View();

            Cart mc = Session["sepet"] == null ? new Cart() : Session["sepet"] as Cart;

            var eklenecek = db.Products.Find(id);

            CartItem ct = new CartItem();

            ct.Id           = eklenecek.ProductID;
            ct.ProductName  = eklenecek.ProductName;
            ct.UnitPrice    = Convert.ToDecimal(eklenecek.UnitPrice);
            ct.UnitsInStock = eklenecek.UnitInStock;
            ct.Quantity     = 1;


            try
            {
                db.SaveChanges(); mc.AddCart(ct);
                Session["sepet"] = mc;
                ViewBag.bilgi    = true;
                return(View(db.Products.OrderByDescending(x => x.ProductID).ToList()));
            }
            catch
            {
                ViewBag.bilgi = false;
            }



            return(RedirectToAction("Index", "Home"));
        }
Exemple #2
0
        public ActionResult Ekle(Admin ad)
        {
            db.Admins.Add(ad);
            try
            {
                db.SaveChanges();
                ViewBag.bilgi = true;
            }
            catch
            {
                ViewBag.bilgi = false;
            }

            return(View());
        }
        public ActionResult Ekle(Category kategori)
        {
            db.Categories.Add(kategori);
            try
            {
                db.SaveChanges();
                ViewBag.bilgi = true;
            }
            catch
            {
                ViewBag.bilgi = false;
            }

            return(View());
        }
Exemple #4
0
        public ActionResult Ekle(User kullanici)
        {
            db.Users.Add(kullanici);
            try
            {
                db.SaveChanges();
                ViewBag.bilgi = true;
            }
            catch
            {
                ViewBag.bilgi = false;
            }

            return(View());
        }
Exemple #5
0
        public ActionResult Sil(int id)
        {
            Order silinecek = db.Orders.Find(id);

            db.Orders.Remove(silinecek);
            db.SaveChanges();

            return(RedirectToAction("Index"));
        }
 public ActionResult Kayit(Admin Admin)
 {
     db.Admins.Add(Admin);
     try
     {
         db.SaveChanges();
     }
     catch (Exception)
     {
         throw;
     }
     return(RedirectToAction("Yonlendirilecek", this));
 }
        public ActionResult Ekle(Product yeniUrun)
        {
            try
            {
                ViewBag.CategoryList = new SelectList(db.Categories.OrderByDescending(a => a.CategoryID).Select(x => new
                {
                    value = x.CategoryID,
                    text  = x.CategoryName
                }), "value", "text");


                db.Products.Add(yeniUrun);


                db.SaveChanges();
                ViewBag.bilgi = true;
            }
            catch
            {
                ViewBag.bilgi = false;
            }

            return(View());
        }
 public ActionResult Kayit(User Kullanici)
 {
     if (ModelState.IsValid)
     {
         try
         {
             db.Users.Add(Kullanici);
             db.SaveChanges();
         }
         catch (Exception)
         {
             ViewBag.Bilgi = "Lütfen zorunlu alanları doldurunuz.";
             return(View());
         }
         return(RedirectToAction("Yonlendirilecek", "Register"));
     }
     return(View());
 }