public HeaderDetails CreateSessionModel(int UserId, String FullName) { //this method will creating a datamodel(which contains wishlist and cart details of logged user) decimal? Subtotal = 0; int Count = 0; CartServices service = new CartServices(); HeaderDetails details = new HeaderDetails(); List <CartItem> CartItemlist = new List <CartItem>(); details.cart.CartItemList = service.GetCartItems(UserId); details.wishListCount = service.GetWishListItems(UserId).Count(); details.FullName = FullName; //calculate cart subtotal and count if (details.cart.CartItemList != null) { foreach (var item in details.cart.CartItemList) { Count = Count + item.Qty; Subtotal = Subtotal + (item.Qty * item.Price); } } details.cart.Count = Count; details.cart.SubTotal = Subtotal; return(details); }
public ActionResult AddTOCart(int productId) { var userId = Current.User.Identity.GetUserId(); service.AddTOCart(userId, productId); return(View("Index", CartServices.GetAllProducts())); }
public ActionResult Index() { //this method will get shopping cart details and return the shooping cart view decimal? Subtotal = 0; int Count = 0; CartServices service = new CartServices(); Cart cart = new Cart(); if (Session[SessionConstants.SESSION_CONTEXT_INSTANCE] != null) { //get cart details for the logged in user's userid User user = (User)(Session[SessionConstants.SESSION_CONTEXT_INSTANCE]); List <CartItem> list = service.GetCartItems(user.UserId); //calculate count and subtotal of the cart if (list != null) { foreach (var item in list) { Count = Count + item.Qty; Subtotal = Subtotal + (item.Qty * item.Price); } } cart.CartItemList = list; cart.Count = Count; cart.SubTotal = Subtotal; return(View(cart)); } else { cart.CartItemList = new List <CartItem>(); return(View(cart)); } }
// GET: ShopNow public ActionResult Index() { var userId = Current.User.Identity.GetUserId(); var product = CartServices.GetAllProducts(); service.OpenCart(userId); return(View(product)); }
public ViewResult Index(CartServices cart, string returnUrl) { return(View(new CartIndex { Cart = cart, ReturnUrl = returnUrl })); }
public CartController(bookstoreContext context, CartServices cartServices, IMapper mapper, BookServices bookServices) { _context = context; _cartServices = cartServices; _mapper = mapper; _bookServices = bookServices; }
public RedirectToRouteResult RemoveFromCart(CartServices cart, int bookId, string returnUrl) { BookView book = repository.GetList() .FirstOrDefault(g => g.Id == bookId); if (book != null) { cart.RemoveLine(book); } return(RedirectToAction("Index", new { returnUrl })); }
public InvoiceController(bookstoreContext context, InvoiceService invoiceService, IMapper mapper, CartServices cartServices, InvoiceDetailsService invoiceDetailsService) { _context = context; _invoiceService = invoiceService; _mapper = mapper; _cartServices = cartServices; _invoiceDetailsService = invoiceDetailsService; }
public LaunchMenu(lacrosseContext context, ICustomerRepo custRepo, IManagerRepo managerRepo, ILocationRepo locRepo, ICartRepo cartRepo) { this.context = context; this.custRepo = custRepo; this.locRepo = locRepo; this.cartRepo = cartRepo; this.managerRepo = managerRepo; this.customerServices = new CustomerServices(custRepo); this.locationServices = new LocationServices(locRepo); this.cartServices = new CartServices(cartRepo); this.managerServices = new ManagerServices(managerRepo); }
public CartRedisController(bookstoreContext context, IConnectionMultiplexer connectionMultiplexer, IMapper mapper, CartServices cartServices, BookServices bookServices) { database = connectionMultiplexer.GetDatabase(); _mapper = mapper; _context = context; _cartServices = cartServices; _bookServices = bookServices; }
public ProductDetails2(Customer customer, Sticks stick, lacrosseContext context, ICustomerRepo customerRepo, IInventoryRepo inventoryRepo, IProductRepo productRepo, ICartRepo cartRepo, ICartItemsRepo cartItemsRepo) { this.customer = customer; this.stick = stick; this.customerRepo = customerRepo; this.productRepo = productRepo; this.cartRepo = cartRepo; this.cartItemsRepo = cartItemsRepo; this.inventoryRepo = inventoryRepo; this.customerServices = new CustomerServices(customerRepo); this.inventoryServices = new InventoryServices(inventoryRepo); this.productServices = new ProductServices(productRepo); this.cartServices = new CartServices(cartRepo); this.cartItemServices = new CartItemServices(cartItemsRepo); }
public ActionResult CartItems() { if (HttpContext.Request.Cookies.Get("myaccount") != null) { HttpCookie rqstCookie = HttpContext.Request.Cookies.Get("myaccount"); var memberDataObj = FormsAuthentication.Decrypt(rqstCookie.Value); var memberData = JsonConvert.DeserializeObject <Member>(memberDataObj.UserData); CartServices cartServices = new CartServices(); OrderDetail [] products = cartServices.GetCartItems(memberData.MemberID); return(Json(products, JsonRequestBehavior.AllowGet)); } else { return(null); } }
public JsonResult DeleteCart(int productId) { int id = 0; try { //removing the item from cart CartServices service = new CartServices(); User user = (User)(Session[SessionConstants.SESSION_CONTEXT_INSTANCE]); id = service.DeleteCart(productId, user.UserId); return(Json(new { Status = true, Message = "Delete Success" }, JsonRequestBehavior.AllowGet)); } catch (Exception ex) { return(Json(new { Status = false, Message = "Error Occured" }, JsonRequestBehavior.AllowGet)); } }
public JsonResult Checkout() { int id = 0; try { //removing from shopping cart and add those details to order table CartServices service = new CartServices(); User user = (User)(Session[SessionConstants.SESSION_CONTEXT_INSTANCE]); id = service.Checkout(user.UserId); return(Json(new { Status = true, Message = "Checkout Success" }, JsonRequestBehavior.AllowGet)); } catch (Exception ex) { return(Json(new { Status = false, Message = "Error Occured" }, JsonRequestBehavior.AllowGet)); } }
//回傳一筆Order中 所有的商品數量 public int GetCartAmount() { HttpCookie rqstCookie = HttpContext.Request.Cookies.Get("myaccount"); if (rqstCookie != null) { var memberDataObj = FormsAuthentication.Decrypt(rqstCookie.Value); var memberData = JsonConvert.DeserializeObject <Member>(memberDataObj.UserData); CartServices cartServices = new CartServices(); int amount = cartServices.GetCarQuantity(memberData.MemberID).CountAmount; return(amount); } else { return(0); } }
// GET: WishList public ActionResult Index() { //this method will get wishlist details and return the wishlist view CartServices service = new CartServices(); if (Session[SessionConstants.SESSION_CONTEXT_INSTANCE] != null) { //get wishlist details for the logged in user's userid User user = (User)(Session[SessionConstants.SESSION_CONTEXT_INSTANCE]); List <wishListItem> list = service.GetWishListItems(user.UserId); return(View(list)); } else { List <wishListItem> list = new List <wishListItem>(); return(View(list)); } }
public static ServiceBaseViewModel ToServiceBaseViewModel(this CartServices cartServices) { if (cartServices?.Service == null) { throw new NullReferenceException("Null reference exception occured in mapper class, please make sure you are eager loading the dependency."); } return(new ServiceBaseViewModel { ServiceId = cartServices.CartServiceId, ServiceDescription = cartServices.Service.Description, ServiceImageURL = cartServices.Service.ImageUrl, ServicePrice = cartServices.Service.Price, AvarageAgeOfCustomer = Convert.ToInt32(cartServices.Service.GiftServices.Any() ? cartServices.Service.GiftServices.Average(gs => (double)(DateTime.Now.Year - gs.Gift.User?.YearOfBirth.GetValueOrDefault(1900) ?? 0)) : 0), MinAgeOfUser = cartServices.Service.GiftServices.Any() ? cartServices.Service.GiftServices.Min(gs => DateTime.Now.Year - gs.Gift?.User.YearOfBirth.GetValueOrDefault(1900) ?? 0) : 0, MaxAgeOfUser = cartServices.Service.GiftServices.Any() ? cartServices.Service.GiftServices.Max(gs => DateTime.Now.Year - gs.Gift?.User.YearOfBirth.GetValueOrDefault(1900) ?? 0) :0 }); }
public CheckoutMenu(Customer customer, lacrosseContext context, ICustomerRepo customerRepo, ILocationRepo locationRepo, IInventoryRepo inventoryRepo, IProductRepo productRepo, ICartRepo cartRepo, ICartItemsRepo cartItemsRepo, IOrderRepo orderRepo, ILineItemRepo lineItemRepo) { this.customer = customer; this.customerRepo = customerRepo; this.inventoryRepo = inventoryRepo; this.locationRepo = locationRepo; this.productRepo = productRepo; this.orderRepo = orderRepo; this.cartRepo = cartRepo; this.cartItemsRepo = cartItemsRepo; this.lineItemRepo = lineItemRepo; this.customerServices = new CustomerServices(customerRepo); this.locationServices = new LocationServices(locationRepo); this.inventoryServices = new InventoryServices(inventoryRepo); this.productServices = new ProductServices(productRepo); this.cartServices = new CartServices(cartRepo); this.cartItemServices = new CartItemServices(cartItemsRepo); this.orderServices = new OrderServices(orderRepo); this.lineItemServices = new lineItemServices(lineItemRepo); }
public Linedata PaymentInfo(int memberId, int price) { OrderDetailRepository orderDetail = new OrderDetailRepository(); var productInfo = orderDetail.GetAllCart(memberId).FirstOrDefault(); CartServices cartServices = new CartServices(); //數量 int quantity = cartServices.GetCarQuantity(memberId).CountAmount; JavaScriptSerializer js = new JavaScriptSerializer(); JsonURL url = js.Deserialize <JsonURL>(productInfo.PicUrl); LinePay line = new LinePay(); Linedata linedata = new Linedata() { productName = line.ProductName(quantity, productInfo.ProductName), currency = "TWD", orderId = productInfo.OrderID.ToString(), productImageUrl = url.Url1, amount = price, confirmUrl = Url + "Checkout" }; return(linedata); }
public object BindModel(ControllerContext controllerContext, ModelBindingContext bindingContext) { // Получить объект Cart из сеанса CartServices cart = null; if (controllerContext.HttpContext.Session != null) { cart = (CartServices)controllerContext.HttpContext.Session[sessionKey]; } // Создать объект Cart если он не обнаружен в сеансе if (cart == null) { cart = new CartServices(); if (controllerContext.HttpContext.Session != null) { controllerContext.HttpContext.Session[sessionKey] = cart; } } // Возвратить объект Cart return(cart); }
public InvoiceController(bookstoreContext context, IMapper mapper, CartServices cartServices) { _context = context; _mapper = mapper; _cartServices = cartServices; }
public PartialViewResult Summary(CartServices cart) { return(PartialView(cart)); }
public CartController(IConfiguration configuration) { this.connectionString = configuration.GetConnectionString("ConnectionString"); this.cartService = new CartServices(new CartRepository(connectionString)); }
public CartController(CartServices service, ILogger <CartController> logger) { _service = service; _logger = logger; }
public virtual JsonResult AddProductToCart_Details(int productId, int shoppingCartTypeId, int qty) { if (Session[SessionConstants.SESSION_CONTEXT_INSTANCE] != null) { CartServices service = new CartServices(); //check seesion is available, only logged in users can add to cart/wishlist User user = (User)(Session[SessionConstants.SESSION_CONTEXT_INSTANCE]); //add to shopping cart if (shoppingCartTypeId == 1) { CartItem item = new CartItem(); int cartId = 0; item.Id = productId; item.UserId = user.UserId; item.Qty = qty; List <CartItem> list = service.GetCartItems(item.UserId); //check item is already exists in cart foreach (var cartItem in list) { if (cartItem.Id == item.Id) { cartId = cartItem.cartId; break; } } if (cartId > 0) { //add new items to the cart int id = service.EditCartItems(item); return(Json(new { Status = true, Message = "Succesfully updated the shopping cart..." }, JsonRequestBehavior.AllowGet)); } else { //update the cart with new quantitiesS int id = service.AddCartItems(item); return(Json(new { Status = true, Message = "Succesfully added to the shopping cart..." }, JsonRequestBehavior.AllowGet)); } } //add to wishlist else { wishListItem item = new wishListItem(); item.UserId = user.UserId; item.Id = productId; List <wishListItem> list = service.GetWishListItems(item.UserId); //check item is already exists in wishlist foreach (var wishItem in list) { if (wishItem.Id == item.Id) { //if already item exists alret user return(Json(new { Status = true, Message = "Item already exists in wishlist..." }, JsonRequestBehavior.AllowGet)); } } //if item not in wishlist,add item to the user's wishlist int id = service.AddWishListItems(item); return(Json(new { Status = true, Message = "Succesfully added to the wishlist..." }, JsonRequestBehavior.AllowGet)); } } else { return(Json(new { Status = false, Message = "Not logged-in..." }, JsonRequestBehavior.AllowGet)); } }
public CartsController(ApplicationDbContext context, CartServices cartService) { _context = context; this.cartService = cartService; }
public CartController(CartServices service) { this._cartServices = service; }