public bool Add(ShoppingCartModelView ShoppingCart) //Bu metodu bozmayalım { ShoppingCart newShoppingCart = new ShoppingCart(); newShoppingCart.UserID = ShoppingCart.UserID; newShoppingCart.ProductID = ShoppingCart.ProductID; newShoppingCart.Quantity = ShoppingCart.Quantity; ShoppingCart existShoppingCart = _shoppingCartService.GetByFilter(a => a.UserID == newShoppingCart.UserID & a.ProductID == newShoppingCart.ProductID); if (existShoppingCart == null) { if (_shoppingCartService.Add(newShoppingCart)) { return(true); } return(false); } else { existShoppingCart.Quantity += newShoppingCart.Quantity; if (_shoppingCartService.Update(existShoppingCart)) { return(true); } return(false); } }
public ActionResult ShoppingCart(int factorId) { D_APIModelFiller DMF = new D_APIModelFiller(); var model = new ShoppingCartModelView() { FactorModel = DMF.shoppingCart(factorId), Ostan = DMF.Ostanha() }; return(View(model)); }
public ActionResult customershoppingCart() { CustomerModelFiller modelFiller = new CustomerModelFiller(); tbl_Customer_Main tcm = new tbl_Customer_Main(); if (HttpContext.Request.Cookies.Get(ProjectProperies.AuthCustomerCode()) != null) { var coockie = HttpContext.Request.Cookies.Get(ProjectProperies.AuthCustomerCode()); tcm = CoockieController.SayWhoIsHE(coockie.Value); } else { return(RedirectToAction("loginandregister", "CustomerSide_Register")); } int CustomerId = Convert.ToInt32(tcm.id_Customer); if (HttpContext.Request.Cookies.Get(ProjectProperies.AuthCustomerShoppingBasket()) != null) { var coockie = JsonConvert.DeserializeObject <ShoppingBasket>(HttpContext.Request.Cookies.Get(ProjectProperies.AuthCustomerShoppingBasket()).Value); var model = new ShoppingCartModelView() { FactorModel = modelFiller.shoppingCart(coockie), Ostan = modelFiller.Ostanha(), Adresses = modelFiller.CustomerAddresses(CustomerId), Customer = modelFiller.customerDetail(CustomerId) }; FactorPopUpModel fpm = model.FactorModel; var userCookieIDV = new HttpCookie(ProjectProperies.CustomerShoppingFactor()); userCookieIDV.Value = CoockieController.SetCustomerShopFactorCookie(fpm); userCookieIDV.Expires = DateTime.Now.AddDays(2); Response.SetCookie(userCookieIDV); return(View(model)); } else { return(RedirectToAction("index", "CustomerSide_Pages")); } }