/// <summary> /// aaaaaaaaaaaaaaaaaaaaaaaaaaa /// </summary> /// <param name="id"></param> /// <returns></returns> public ActionResult add(int id) { Product sepetEklenecekUrun = db.Products.Find(id); ProductVM model = new ProductVM { ID = sepetEklenecekUrun.ProductID, ProductName = sepetEklenecekUrun.ProductName, UnitPrice = (decimal)sepetEklenecekUrun.UnitPrice, Quantity = 1 }; if (Session["sepet"] != null) { ProductCart cart = Session["sepet"] as ProductCart; Session["sepet"] = cart; } else { ProductCart cart = new ProductCart(); cart.AddCart(model); Session.Add("sepet", cart); } return(Json("sepete eklendi")); }
public JsonResult Add(int id) { Product product = _service.Products.Find(id); ProductVM model = new ProductVM() { Id = product.ProductID, ProductName = product.ProductName, UnitPrice = product.UnitPrice, UnitsInStock = product.UnitsInStock, Quantity = 1 }; if (Session["sepet"] != null) { ProductCart cart = Session["sepet"] as ProductCart; cart.AddCart(model); Session["sepet"] = cart; } else { ProductCart cart = new ProductCart(); cart.AddCart(model); Session.Add("sepet", cart); } return(Json("")); }
public JsonResult Add(int id) { Recipe recipe = _recipeService.Get(id); ProductVM vm = new ProductVM { Id = recipe.RecipeID, ProductName = recipe.RecipeName, UnitPrice = recipe.Price, UnitsInstock = 0, Quantity = 1 }; if (Session["sepet"] != null) { ProductCart cart = Session["sepet"] as ProductCart; cart.AddCart(vm); Session["sepet"] = cart; } else { ProductCart cart = new ProductCart(); cart.AddCart(vm); Session.Add("sepet", cart); } return(Json("")); }
public JsonResult Add(Guid id) { Product product = _productService.GetByID(id); ProductVM vm = new ProductVM { ID = product.ID, ProductName = product.Name, UnitPrice = product.Price, UnitInStock = product.UnitInStock, Quantity = 1, ImagePath = product.ImagePath }; if (Session["sepet"] != null) { ProductCart cart = Session["sepet"] as ProductCart; cart.AddCart(vm); Session["sepet"] = cart; } else { ProductCart cart = new ProductCart(); cart.AddCart(vm); Session.Add("sepet", cart); } return(Json("")); }
public JsonResult Add(Guid id) { Product product = _productService.GetByID(id); ProductVM model = new ProductVM { ID = product.ID, Name = product.Name, Price = product.Price, UnitsInStock = product.UnitsInStock, Quantity = 1 }; if (Session["sepet"] != null) { ProductCart cart = Session["sepet"] as ProductCart; cart.AddCart(model); Session["sepet"] = cart; } else { ProductCart cart = new ProductCart(); cart.AddCart(model); Session.Add("sepet", cart); } return(Json("OK", JsonRequestBehavior.AllowGet)); }
public JsonResult Add(Guid id) { Product eklenecek = _productService.GetById(id); CartProductVM model = new CartProductVM { Id = eklenecek.ID, ImagePath = eklenecek.ImagePath, ProductName = eklenecek.Name, UnitPrice = eklenecek.Price, Quantity = 1 }; if (Session["sepet"] != null) { ProductCart cart = Session["sepet"] as ProductCart; cart.AddCart(model); Session["sepet"] = cart; } else { ProductCart cart = new ProductCart(); cart.AddCart(model); Session.Add("sepet", cart); } return(Json("")); }
public ActionResult Add(Guid id) { //gelen id'ye ait ürünü yakalıyoruz. Product sepeteEklenecekUrun = _productService.GetById(id); CartProductVM model = new CartProductVM { ID = sepeteEklenecekUrun.ID, ProductCode = sepeteEklenecekUrun.ProductCode, Name = sepeteEklenecekUrun.Name, Quantity = 1 }; //Session Nedir ? //Server taraflı verileri tutmak için tasarlanmış bir yapıdır. //Kullanıcı oturumlarını, sepet vb yapıları client-server iletişimi sırasında saklamamıza yarar. //Session object tipinde değer tutar bu nedenle cast etmek gereklidir. if (Session["sepet"] != null) { //Eğer sepet varsa, session içerisinden o sepeti getiriyorum. ProductCart cart = Session["sepet"] as ProductCart; cart.AddCart(model); //Ürün eklendikten sonra yeni sepeti tekrar session'a atıyoruz Session["sepet"] = cart; } else { //eğer session içerisinde sepet yoksa yenisi oluşturulur. ProductCart cart = new ProductCart(); cart.AddCart(model); Session.Add("sepet", cart); Session["sepet"] = cart; } //İsterseniz mesaj gönderebilirsiniz. return(Json("Sepete başarıyla eklendi!")); }
//Sepete Ekleme public ActionResult Add(Guid id) { //gelen idye ait ürünü yakalıyoruz. Product sepeteEklenecekurun = _productService.GetById(id); CartProductVM model = new CartProductVM(); model.ID = sepeteEklenecekurun.ID; model.ProductName = sepeteEklenecekurun.Name; model.UnitPrice = sepeteEklenecekurun.Price; model.Quantity = 1; //Session Nedir ? //Server taraflı verileri tutmak için tasarlanmış bir yapıdır. //Kullanıcı oturumlarını, sepet vb yapıları client-server iletişimi sırasında saklamamıza yarar. //Session object tipinde değer tutar bu nedenle cast etmek gereklidir. if (Session["sepet"] != null) { //Session içerisinde bir sepet varsa ProductCart cart = Session["sepet"] as ProductCart; cart.AddCart(model); //Ürün eklendikten sonra sepetin son halini sessiona at Session["sepet"] = cart; } else { //Session içerisinde bir sepet yoksa ProductCart cart = new ProductCart(); cart.AddCart(model); //Session'ı ilk kez oluşturuyoruz. Session.Add("sepet", cart); } ProductCart cartSon = Session["sepet"] as ProductCart; return(Json(cartSon.CartProductList.Count)); }