public IActionResult Payment(ShoppingCartVM shoppingCartVM) { string userId = User.FindFirst(ClaimTypes.NameIdentifier).Value; AspNetUsers userNow = usersService.GetUserById(userId); if (!userNow.EmailConfirmed) { ModelState.AddModelError("error", "U moet eerst uw email bevestigen."); return(View("Index", shoppingCartVM)); } else { for (int i = 0; i < shoppingCartVM.ShoppingCart.Count; i++) { CartVM cart = shoppingCartVM.ShoppingCart[i]; shoppingCartVM.ShoppingCart[i].WedstrijdId = cart.WedstrijdId; shoppingCartVM.ShoppingCart[i].ThuisClubId = cart.ThuisClubId; shoppingCartVM.ShoppingCart[i].ThuisClubNaam = cart.ThuisClubNaam; shoppingCartVM.ShoppingCart[i].UitCLubNaam = cart.UitCLubNaam; shoppingCartVM.ShoppingCart[i].StadiumNaam = cart.StadiumNaam; shoppingCartVM.ShoppingCart[i].VakNaam = cart.VakNaam; shoppingCartVM.ShoppingCart[i].WedstrijdDatum = cart.WedstrijdDatum; shoppingCartVM.ShoppingCart[i].Prijs = cart.Prijs; shoppingCartVM.ShoppingCart[i].Aantal = cart.Aantal; } } return(View()); }
// GET: ShoppingCart public ActionResult Index() { string currency = CookieService.GetCurrency(Request.Cookies); ShoppingCartVM viewModel = new ShoppingCartVM() { CurrencyCode = currency }; // If we are a guest on the site use cookies for the shopping cart if (!UserService.IsUserConnected(System.Web.HttpContext.Current.User)) { // Get products using the CookieService viewModel.Products = CookieService.GetShoppingCartProducts(Request.Cookies); viewModel.Subtotal = ShoppingCartService.GetSubTotal(viewModel.Products, currency); // Reverse the list so the most recent products are first viewModel.Products.Reverse(); return(View(viewModel)); } ShoppingCart shoppingCart = new ShoppingCartManager().GetShoppingCartByUser(User.Identity.GetUserId()); viewModel.Products = new ShoppingCartProductManager().GetShoppingCartProductByShoppingCartId(shoppingCart.ShoppingCartId); viewModel.Subtotal = ShoppingCartService.GetSubTotal(viewModel.Products, currency); // Reverse the list so the most recent products are first viewModel.Products.Reverse(); return(View(viewModel)); }
public IActionResult Index() { var claimsIdentity = (ClaimsIdentity)User.Identity; var claim = claimsIdentity.FindFirst(ClaimTypes.NameIdentifier); ShoppingCartVM = new ShoppingCartVM() { OrderHeader = new OrderHeader(), ListCart = _unitOfWork.ShoppingCart.GetAll(c => c.ApplicationUserId == claim.Value, includeProperties: "Product") }; ShoppingCartVM.OrderHeader.OrderTotal = 0; ShoppingCartVM.OrderHeader.ApplicationUser = _unitOfWork.ApplicationUser .GetFirstOrDefault(c => c.Id == claim.Value, includeProperties: "Company"); foreach (var cart in ShoppingCartVM.ListCart) { cart.Price = cart.Product.Price; //Price is not mapped so we need caculator it ShoppingCartVM.OrderHeader.OrderTotal += (cart.Price * cart.Count); cart.Product.Description = SD.ConvertToRawHtml(cart.Product.Description); //Only show maxLengthDes of Description int maxLengthDes = 100; if (cart.Product.Description.Length > maxLengthDes) { cart.Product.Description = cart.Product.Description.Substring(0, maxLengthDes - 1) + "..."; } } return(View(ShoppingCartVM)); }
public IActionResult Delete(int?Item) { if (Item == null) { return(NotFound()); } ShoppingCartVM cartList = HttpContext.Session.GetObject <ShoppingCartVM>("ShoppingCart"); // call SessionID var SessionId = HttpContext.Session.Id; var itemToRemove = cartList.ShoppingCart[Convert.ToInt32(Item)]; if (itemToRemove != null) { cartList.ShoppingCart.Remove(itemToRemove); if (cartList.ShoppingCart.Count == 0) { cartList = null; } HttpContext.Session.SetObject("ShoppingCart", cartList); } return(View("Index", cartList)); }
public IActionResult Index() { var claimsIdentity = (ClaimsIdentity)User.Identity; var claim = claimsIdentity.FindFirst(ClaimTypes.NameIdentifier); ShoppingCartVm = new ShoppingCartVM() { ShoppingCarts = _context.ShoppingCarts .Where(s => s.ApplicationUserId == claim.Value).Include(s => s.Product).ToList(), OrderHeader = new OrderHeader() }; ShoppingCartVm.OrderHeader.OrderTotal = 0; ShoppingCartVm.OrderHeader.ApplicationUser = _context.Users .FirstOrDefault(a => a.Id == claim.Value); foreach (var shoppingCart in ShoppingCartVm.ShoppingCarts) { shoppingCart.Price = SD.GetPriceBasedOnQuatity(shoppingCart.Count, shoppingCart.Product.Price, shoppingCart.Product.Price50, shoppingCart.Product.Price100); ShoppingCartVm.OrderHeader.OrderTotal += (shoppingCart.Price * shoppingCart.Count); } return(View(ShoppingCartVm)); }
public IActionResult Summary() { var claimsIdentity = (ClaimsIdentity)User.Identity; var claim = claimsIdentity.FindFirst(ClaimTypes.NameIdentifier); ShoppingCartVM = new ShoppingCartVM() { OrderHeader = new OrderHeader(), ListCart = _unitOfWork.ShoppingCart.GetAll(c => c.ApplicationUserId == claim.Value, includeProperties: "Product") }; ShoppingCartVM.OrderHeader.ApplicationUser = _unitOfWork.ApplicationUser .GetFirstOrDefault(c => c.Id == claim.Value, includeProperties: "Company"); foreach (var cart in ShoppingCartVM.ListCart) { cart.Price = cart.Product.Price; //Price is not mapped so we need caculator it ShoppingCartVM.OrderHeader.OrderTotal += (cart.Price * cart.Count); } ShoppingCartVM.OrderHeader.Name = ShoppingCartVM.OrderHeader.ApplicationUser.Name; ShoppingCartVM.OrderHeader.StreetAddress = ShoppingCartVM.OrderHeader.ApplicationUser.StreetAddress; ShoppingCartVM.OrderHeader.District = ShoppingCartVM.OrderHeader.ApplicationUser.District; ShoppingCartVM.OrderHeader.ProvinceOrCity = ShoppingCartVM.OrderHeader.ApplicationUser.ProvinceOrCity; ShoppingCartVM.OrderHeader.PostalCode = ShoppingCartVM.OrderHeader.ApplicationUser.PostalCode; ShoppingCartVM.OrderHeader.PhoneNumber = ShoppingCartVM.OrderHeader.ApplicationUser.PhoneNumber; return(View(ShoppingCartVM)); }
//-------------------------------------- // // POST: /ShoppingCart/Index public ActionResult AddToCart(int?id) { try { if (ModelState.IsValid) { ShoppingCartVM scVM = new ShoppingCartVM() { }; if (id > 0) { Product product = db.Products.Find(id); if (product != null) { scVM.ShoppingCartItem.ProductId = product.ProductId; scVM.ShoppingCartItem.PricingRuleId = db.PricingRules.Find(product.PricingRuleId).PricingRuleId; } scVM.ShoppingCartItem.Quantity = 1; db.ShoppingCartItems.Add(scVM.ShoppingCartItem); db.SaveChanges(); } } return(RedirectToAction("Index")); //------------------------------ } catch { return(View()); } }
public IActionResult Index() { var claimsIdentity = (ClaimsIdentity)User.Identity; var claim = claimsIdentity.FindFirst(ClaimTypes.NameIdentifier); //only get shopping cart if user is logged in ShoppingCartVM = new ShoppingCartVM() { //retrieving shopping cart from Db OrderHeader = new Models.OrderHeader(), //get all the shopping cart based on user Id ListCart = _unitOfWork.ShoppingCart.GetAll(u => u.ApplicationUserId == claim.Value, includeProperties: "Product") }; //will calculate in the view ShoppingCartVM.OrderHeader.OrderTotal = 0; //populate Application User inside Order Header with their Company ShoppingCartVM.OrderHeader.ApplicationUser = _unitOfWork.ApplicationUser .GetFirstOrDefault(u => u.Id == claim.Value, includeProperties: "Company"); //iterate through all items in ListCart and print out the total price based on Count foreach (var list in ShoppingCartVM.ListCart) { list.Price = SD.GetPriceBasedOnQuantity(list.Count, list.Product.Price, list.Product.Price50, list.Product.Price100); ShoppingCartVM.OrderHeader.OrderTotal += (list.Price * list.Count); list.Product.Description = SD.ConvertToRawHtml(list.Product.Description); if (list.Product.Description.Length > 100) { list.Product.Description = list.Product.Description.Substring(0, 99) + "..."; } } return(View(ShoppingCartVM)); }
public IActionResult Summary() { Claim claim = GetClaim(); var shoppingCartVM = new ShoppingCartVM() { OrderHeader = new Models.OrderHeader(), ListCart = unitOfWork.ShoppingCart .GetAll(c => c.ApplicationUserId == claim.Value, includeProperties: "Product") }; shoppingCartVM.OrderHeader.ApplicationUser = unitOfWork.ApplicationUser .GetFirstOrDefault(c => c.Id == claim.Value, includeProperties: "Company"); FormatShoppingCart(shoppingCartVM); shoppingCartVM.OrderHeader.Name = shoppingCartVM.OrderHeader.ApplicationUser.Name; //shoppingCartVM.OrderHeader = mapper // .Map<ApplicationUser, OrderHeader>(shoppingCartVM.OrderHeader.ApplicationUser); shoppingCartVM.OrderHeader.Name = shoppingCartVM.OrderHeader.ApplicationUser.Name; shoppingCartVM.OrderHeader.PhoneNumber = shoppingCartVM.OrderHeader.ApplicationUser.PhoneNumber; shoppingCartVM.OrderHeader.StreetAddress = shoppingCartVM.OrderHeader.ApplicationUser.StreetAddress; shoppingCartVM.OrderHeader.City = shoppingCartVM.OrderHeader.ApplicationUser.City; shoppingCartVM.OrderHeader.State = shoppingCartVM.OrderHeader.ApplicationUser.State; shoppingCartVM.OrderHeader.PostalCode = shoppingCartVM.OrderHeader.ApplicationUser.PostalCode; return(View(shoppingCartVM)); }
public IActionResult Index() { // ClaimsIdnetity gets the information of the logged in user var claimsIdentity = (ClaimsIdentity)User.Identity; var claim = claimsIdentity.FindFirst(ClaimTypes.NameIdentifier); ShoppingCartVM = new ShoppingCartVM() { OrderHeader = new Models.OrderHeader(), CartList = _unitOfWork.ShoppingCart.GetAll(u => u.ApplicationUserId == claim.Value, includeProperties: "Product") }; ShoppingCartVM.OrderHeader.OrderTotal = 0; ShoppingCartVM.OrderHeader.ApplicationUser = _unitOfWork.ApplicationUser.GetFirstOrDefault(u => u.Id == claim.Value, includeProperties: "Company"); foreach (var list in ShoppingCartVM.CartList) { list.Price = SD.GetPriceBasedOnQuantity(list.Count, list.Product.Price, list.Product.Price50, list.Product.Price100); ShoppingCartVM.OrderHeader.OrderTotal += (list.Price * list.Count); list.Product.Description = SD.ConvertToRawHtml(list.Product.Description); //Display first 100 characters for description if (list.Product.Description.Length > 100) { list.Product.Description = list.Product.Description.Substring(0, 99) + "..."; } } return(View(ShoppingCartVM)); }
public IActionResult PlaceOrder(ShoppingCartVM shoppingCartVM) { var claimsIdentity = (ClaimsIdentity)this.User.Identity; var claim = claimsIdentity.FindFirst(System.Security.Claims.ClaimTypes.NameIdentifier); shoppingCartVM.listCart = _context.ShoppingCart.Where(c => c.ApplicationUserId == claim.Value).ToList(); OrderHeader orderHeader = shoppingCartVM.OrderHeader; shoppingCartVM.OrderHeader.OrderDate = DateTime.Now; shoppingCartVM.OrderHeader.UserId = claim.Value; shoppingCartVM.OrderHeader.Status = SD.StatusSubmitted; _context.OrderHeader.Add(orderHeader); _context.SaveChanges(); foreach (var item in shoppingCartVM.listCart) { item.menuItem = _context.MenuItem.FirstOrDefault(m => m.Id == item.MenuItemId); OrderDetail orderDetails = new OrderDetail { MenuItemId = item.MenuItemId, OrderId = orderHeader.OrderHeaderId, Name = item.menuItem.Name, Description = item.menuItem.Description, Price = item.menuItem.Price, Count = item.Count }; _context.OrderDetail.Add(orderDetails); } _context.ShoppingCart.RemoveRange(shoppingCartVM.listCart); HttpContext.Session.SetInt32("CartCount", 0); _context.SaveChanges(); return(RedirectToAction("OrderConfirmation", new { id = orderHeader.OrderHeaderId })); }
public IActionResult Details() { ShoppingCartVM shoppingCartVM = new ShoppingCartVM() { OrderHeader = new OrderHeader() }; shoppingCartVM.OrderHeader.OrderTotal = 0; var claimsIdentity = (ClaimsIdentity)this.User.Identity; var claim = claimsIdentity.FindFirst(System.Security.Claims.ClaimTypes.NameIdentifier); var cart = _context.ShoppingCart.Where(c => c.ApplicationUserId == claim.Value); if (cart != null) { shoppingCartVM.listCart = cart.ToList(); } foreach (var list in shoppingCartVM.listCart) { list.menuItem = _context.MenuItem.FirstOrDefault(m => m.Id == list.MenuItemId); shoppingCartVM.OrderHeader.OrderTotal = shoppingCartVM.OrderHeader.OrderTotal + (list.menuItem.Price * list.Count); if (list.menuItem.Description.Length > 100) { list.menuItem.Description = list.menuItem.Description.Substring(0, 99) + "..."; } } return(View(shoppingCartVM)); }
protected override void OnNavigatedTo(NavigationEventArgs e) { var tmp = e.Parameter as Tuple <ShoppingCartVM, string>; if (tmp == null) { // ako je poslan dodatni parametar tipa bool var args = e.Parameter as Tuple <ShoppingCartVM, string, bool>; // Preuzimanje primljenog taga za filtriranje proizvoda ShoppingCartVM = args.Item1; isConfigurationWizard = args.Item3; // ako je potrebno filtrirati proizvode ShoppingCartVM.ProductFilter = args.Item2; } else { // Preuzimanje primljenog taga za filtriranje proizvoda ShoppingCartVM = tmp.Item1; // ako je potrebno filtrirati proizvode ShoppingCartVM.ProductFilter = tmp.Item2; } ShoppingCartVM?.SetTargetPageFrame(Frame); ShoppingCartVM.FilteredProducts = ShoppingCartVM.filterProductByType(); DataContext = ShoppingCartVM; }
public IActionResult Index() { //get login user var claimsIdentity = (ClaimsIdentity)User.Identity; var claim = claimsIdentity.FindFirst(ClaimTypes.NameIdentifier); //set instance ShoppingCartVM = new ShoppingCartVM() { OrderHeader = new Models.OrderHeader(), ListCart = _unitOfWork.ShoppingCart.GetAll(x => x.ApplicationUserId == claim.Value , includeProperties: "Product") }; //manipulate data foreach (var list in ShoppingCartVM.ListCart) { list.Price = SD.GetPriceBasedOnQuantity(list.Count, list.Product.Price, list.Product.Price50, list.Product.Price100); ShoppingCartVM.OrderHeader.OrderTotal += (list.Price * list.Count); list.Product.Description = SD.ConvertToRawHtml(list.Product.Description); if (list.Product.Description.Length > 100) { list.Product.Description = String.Format($"{list.Product.Description.Substring(0, 99)}..."); } } return(View(ShoppingCartVM)); }
public IActionResult Summary() { if (TempData["trxId"] != null) { ViewBag.TrxId = "trxid is missing"; } var claimsIdentity = (ClaimsIdentity)User.Identity; var claim = claimsIdentity.FindFirst(ClaimTypes.NameIdentifier); ShoppingCartVm = new ShoppingCartVM() { OrderHeader = new OrderHeader(), ShoppingCarts = _context.ShoppingCarts.Include(s => s.Product).Where(c => c.ApplicationUserId == claim.Value).ToList() }; ShoppingCartVm.OrderHeader.ApplicationUser = _context.Users .FirstOrDefault(u => u.Id == claim.Value); foreach (var list in ShoppingCartVm.ShoppingCarts) { list.Price = SD.GetPriceBasedOnQuatity(list.Count, list.Product.Price, list.Product.Price50, list.Product.Price100); ShoppingCartVm.OrderHeader.OrderTotal += (list.Price * list.Count); } ShoppingCartVm.OrderHeader.Name = ShoppingCartVm.OrderHeader.ApplicationUser.UserName; ShoppingCartVm.OrderHeader.PhoneNumber = ShoppingCartVm.OrderHeader.ApplicationUser.PhoneNumber; return(View(ShoppingCartVm)); }
public IActionResult Index() { cartVM = new ShoppingCartVM { OrderHeader = new OrderHeader() }; var claimsIdentity = (ClaimsIdentity)User.Identity; var claim = claimsIdentity.FindFirst(ClaimTypes.NameIdentifier); if (claim != null) { cartVM.ListCart = _unitOfWork.ShoppingCart.GetAll(i => i.ApplicationUserId == claim.Value, includeProperties: "Product"); cartVM.OrderHeader.OrderTotal = 0; cartVM.OrderHeader.ApplicationUser = _unitOfWork.ApplicationUser.GetFirstOrDefault(i => i.Id == claim.Value, includeProperties: "Company"); foreach (var item in cartVM.ListCart) { item.Price = SD.GetPriceBasedOnQuantity(item.Count, item.Product.Price, item.Product.Price50, item.Product.Price100); cartVM.OrderHeader.OrderTotal += (item.Price * item.Count); item.Product.Description = SD.ConvertToRawHtml(item.Product.Description); if (item.Product.Description.Length > 100) { item.Product.Description = item.Product.Description.Substring(0, 99) + "..."; } } } return(View(cartVM)); }
public IActionResult Summary() { cartVM = new ShoppingCartVM { OrderHeader = new OrderHeader() }; var claimsIdentity = (ClaimsIdentity)User.Identity; var claim = claimsIdentity.FindFirst(ClaimTypes.NameIdentifier); if (claim != null) { cartVM.OrderHeader.ApplicationUser = _unitOfWork.ApplicationUser.GetFirstOrDefault(i => i.Id == claim.Value, includeProperties: "Company"); cartVM.ListCart = _unitOfWork.ShoppingCart.GetAll(i => i.ApplicationUserId == claim.Value, includeProperties: "Product"); foreach (var item in cartVM.ListCart) { item.Price = SD.GetPriceBasedOnQuantity(item.Count, item.Product.Price, item.Product.Price50, item.Product.Price100); cartVM.OrderHeader.OrderTotal += (item.Price * item.Count); } cartVM.OrderHeader.Name = cartVM.OrderHeader.ApplicationUser.Name; cartVM.OrderHeader.PhoneNumber = cartVM.OrderHeader.ApplicationUser.PhoneNumber; cartVM.OrderHeader.StreetAddress = cartVM.OrderHeader.ApplicationUser.StreetAddress; cartVM.OrderHeader.City = cartVM.OrderHeader.ApplicationUser.City; cartVM.OrderHeader.State = cartVM.OrderHeader.ApplicationUser.State; cartVM.OrderHeader.PostalCode = cartVM.OrderHeader.ApplicationUser.PostalCode; } return(View(cartVM)); }
// GET: /<controller>/ public IActionResult Index() { ShoppingCartVM cartList = HttpContext.Session.GetObject <ShoppingCartVM>("ShoppingCart"); if (cartList != null) { if (cartList.Cart != null) { foreach (CartVM cart in cartList.Cart) { cart.Ringen = new SelectList(ringService.GetAll(), "RingFactor", "Naam"); cart.Vakken = new SelectList(vakService.GetAll(), "VakFactor", "Naam"); } } if (cartList.AbonnementCart != null) { foreach (AbonnementCartVM abonnementCart in cartList.AbonnementCart) { abonnementCart.Ringen = new SelectList(ringService.GetAll(), "RingFactor", "Naam"); abonnementCart.Vakken = new SelectList(vakService.GetAll(), "VakFactor", "Naam"); } } } return(View(cartList)); }
public IActionResult Summary() { var claimsIdentity = (ClaimsIdentity)User.Identity; var claim = claimsIdentity.FindFirst(ClaimTypes.NameIdentifier); ShoppingCartVM = new ShoppingCartVM() { OrderHeader = new Models.OrderHeader(), ListCart = _unitOfWork.ShoppingCart.GetAll(c => c.ApplicationUserId == claim.Value, includeProperties: "Product") }; ShoppingCartVM.OrderHeader.ApplicationUser = _unitOfWork.ApplicationUser.GetFirstOrDefault(c => c.Id == claim.Value, includeProperties: "Company"); foreach (var list in ShoppingCartVM.ListCart) { list.Price = SD.GetPriceBasedOnQuantity(list.Count, list.Product.Price, list.Product.Price50, list.Product.Price100); ShoppingCartVM.OrderHeader.OrderTotal += (list.Price * list.Count); } ShoppingCartVM.OrderHeader.Name = ShoppingCartVM.OrderHeader.ApplicationUser.Name; ShoppingCartVM.OrderHeader.PhoneNumber = ShoppingCartVM.OrderHeader.ApplicationUser.PhoneNumber; ShoppingCartVM.OrderHeader.StreetAddress = ShoppingCartVM.OrderHeader.ApplicationUser.StreetAddress; ShoppingCartVM.OrderHeader.City = ShoppingCartVM.OrderHeader.ApplicationUser.City; ShoppingCartVM.OrderHeader.State = ShoppingCartVM.OrderHeader.ApplicationUser.State; ShoppingCartVM.OrderHeader.PostalCode = ShoppingCartVM.OrderHeader.ApplicationUser.PostalCode; return(View(ShoppingCartVM)); }
public IActionResult Index() { var claimsIdentity = (ClaimsIdentity)User.Identity; var claim = claimsIdentity.FindFirst(ClaimTypes.NameIdentifier); if (claim != null) { ShoppingCartVM = new ShoppingCartVM() { OrderHeader = new Models.OrderHeader(), ListCart = _unitOfWork.ShoppingCart.GetAll(u => u.ApplicationUserId == claim.Value, includeProperties: "Product") }; ShoppingCartVM.OrderHeader.OrderTotal = 0; foreach (var list in ShoppingCartVM.ListCart) { list.Price = StaticDetails.GetPriceBasedOnQuantity(list.Count, list.Product.Price, list.Product.Price50, list.Product.Price100); ShoppingCartVM.OrderHeader.OrderTotal += (list.Price * list.Count); list.Product.Description = StaticDetails.ConvertToRawHtml(list.Product.Description); if (list.Product.Description.Length > 100) { list.Product.Description = list.Product.Description.Substring(0, 99) + "..."; } } return(View(ShoppingCartVM)); } else { return(RedirectToAction("Index", "Home")); } }
public IActionResult Summary() { var claimsIdentity = (ClaimsIdentity)User.Identity; var claim = claimsIdentity.FindFirst(ClaimTypes.NameIdentifier); ShoppingCartVM = new ShoppingCartVM { OrderHeader = new OrderHeader(), ListCart = _unitOfWork.ShoppingCart.GetAll(c => c.ApplicationUserId == claim.Value, IncludeProperties: "Product") }; ShoppingCartVM.OrderHeader.ApplicationUser = _unitOfWork.ApplicationUser .FirstOrDefault(c => c.Id == claim.Value, IncludeProperties: "Company"); //We have to iterate through out list cart to get the total based on the quantity seleted foreach (var list in ShoppingCartVM.ListCart) { list.Price = SD.GetPriceBasedOnQuantity(list.Count, list.Product.Price, list.Product.Price50, list.Product.Price100); ShoppingCartVM.OrderHeader.OrderTotal += (list.Price * list.Count); } //We are poplulating our order header property from our application user ShoppingCartVM.OrderHeader.Name = ShoppingCartVM.OrderHeader.ApplicationUser.Name; ShoppingCartVM.OrderHeader.PhoneNumber = ShoppingCartVM.OrderHeader.ApplicationUser.PhoneNumber; ShoppingCartVM.OrderHeader.StreetAddress = ShoppingCartVM.OrderHeader.ApplicationUser.StreetAddress; ShoppingCartVM.OrderHeader.City = ShoppingCartVM.OrderHeader.ApplicationUser.City; ShoppingCartVM.OrderHeader.State = ShoppingCartVM.OrderHeader.ApplicationUser.State; ShoppingCartVM.OrderHeader.PostalCode = ShoppingCartVM.OrderHeader.ApplicationUser.PostalCode; return(View(ShoppingCartVM)); }
public IActionResult Index() { var claimsIdentity = (ClaimsIdentity)User.Identity; var claim = claimsIdentity.FindFirst(ClaimTypes.NameIdentifier); ShoppingCartVM = new ShoppingCartVM() { OrderHeader = new OrderHeader(), ListCart = _unitOfWork.ShoppingCart.GetAll(c => c.ApplicationUserId == claim.Value, IncludeProperties: "Product"), }; ShoppingCartVM.OrderHeader.OrderTotal = 0; //We will set it to 0 we will calculate it later in the view so we can display the total at the end ShoppingCartVM.OrderHeader.ApplicationUser = _unitOfWork.ApplicationUser .FirstOrDefault(c => c.Id == claim.Value, IncludeProperties: "Company"); //We have to iterate through out list cart to get the total based on the quantity seleted foreach (var list in ShoppingCartVM.ListCart) { list.Price = SD.GetPriceBasedOnQuantity(list.Count, list.Product.Price, list.Product.Price50, list.Product.Price100); ShoppingCartVM.OrderHeader.OrderTotal += (list.Price * list.Count); list.Product.Description = SD.ConvertToRawHtml(list.Product.Description); if (list.Product.Description.Length > 100) { list.Product.Description = list.Product.Description.Substring(0, 99) + "..."; } } return(View(ShoppingCartVM)); }
public async Task <IActionResult> ResetList() { var carts = await _context.ShoppingCarts.Include(c => c.CartItems).OrderByDescending(i => i.Date).ToListAsync(); var list = new List <ShoppingCartVM>(); foreach (var item in carts) { var vm = new ShoppingCartVM { Id = item.Id, RequestCode = item.RequestCode, UserName = item.UserName, Address = item.Address, Price = string.Format("{0:n0}", int.Parse(item.Price)).ToPersianNumbers(), Date = item.Date.ToPersianDateTextify(), PaymentType = "آنلاین", Status = item.Status.ToString(), Payment = item.PaymentType, RequestStatus = item.Status, }; list.Add(vm); } return(Json(new { status = '1', items = list })); }
public IActionResult Index() { var claimsIdentity = (ClaimsIdentity)User.Identity; var claims = claimsIdentity.FindFirst(ClaimTypes.NameIdentifier); ShoppingCartVM = new ShoppingCartVM() { OrderHeader = new OrderHeader(), ListCart = _uow.ShoppingCart.GetAll(u => u.ApplicationUserId == claims.Value, includeProperties: "Product") }; ShoppingCartVM.OrderHeader.OrderTotal = 0; ShoppingCartVM.OrderHeader.ApplicationUser = _uow.ApplicationUser .GetFirstOrDefault(u => u.Id == claims.Value, includeProperties: "Company"); foreach (var cart in ShoppingCartVM.ListCart) { cart.Price = ProjectConstant.GetPriceBaseOnQuantity(cart.Count, cart.Product.Price, cart.Product.Price50, cart.Product.Price100); ShoppingCartVM.OrderHeader.OrderTotal += (cart.Price * cart.Count); cart.Product.Description = ProjectConstant.ConvertToRawHtml(cart.Product.Description); if (cart.Product.Description.Length > 50) { cart.Product.Description = cart.Product.Description.Substring(0, 49) + "...."; } } return(View(ShoppingCartVM)); }
public IActionResult Summary() { var claimsIdentity = (ClaimsIdentity)User.Identity; var claims = claimsIdentity.FindFirst(ClaimTypes.NameIdentifier); ShoppingCartVM = new ShoppingCartVM() { OrderHeader = new OrderHeader(), ListCart = _uow.ShoppingCart.GetAll(u => u.ApplicationUserId == claims.Value, includeProperties: "Product") }; ShoppingCartVM.OrderHeader.ApplicationUser = _uow.ApplicationUser .GetFirstOrDefault(u => u.Id == claims.Value, includeProperties: "Company"); foreach (var item in ShoppingCartVM.ListCart) { item.Price = ProjectConstant.GetPriceBaseOnQuantity(item.Count, item.Product.Price, item.Product.Price50, item.Product.Price100); ShoppingCartVM.OrderHeader.OrderTotal += (item.Price * item.Count); } ShoppingCartVM.OrderHeader.Name = ShoppingCartVM.OrderHeader.ApplicationUser.Name; ShoppingCartVM.OrderHeader.PhoneNumber = ShoppingCartVM.OrderHeader.ApplicationUser.PhoneNumber; ShoppingCartVM.OrderHeader.StreetAddress = ShoppingCartVM.OrderHeader.ApplicationUser.StreetAddress; ShoppingCartVM.OrderHeader.City = ShoppingCartVM.OrderHeader.ApplicationUser.City; ShoppingCartVM.OrderHeader.State = ShoppingCartVM.OrderHeader.ApplicationUser.State; ShoppingCartVM.OrderHeader.PostCode = ShoppingCartVM.OrderHeader.ApplicationUser.PostaCode; return(View(ShoppingCartVM)); }
public IActionResult Index() { var claimsIdentity = (ClaimsIdentity)User.Identity; var claim = claimsIdentity.FindFirst(ClaimTypes.NameIdentifier); ShoppingCartVM = new ShoppingCartVM { OrderHeader = new OrderHeader(), ListCart = _unitOfWork.ShoppingCart .GetAll(u => u.ApplicationUserId == claim.Value, includeProperties: "Product") }; ShoppingCartVM.OrderHeader.OrderTotal = 0; ShoppingCartVM.OrderHeader.ApplicationUser = _unitOfWork.ApplicationUser .GetFirstOrDefault(u => u.Id == claim.Value, includeProperties: "Company"); foreach (var list in ShoppingCartVM.ListCart) { list.Price = SD.GetPriceBasedOnQuantity(list.Count, list.Product.Price, list.Product.Price50, list.Product.Price100); ShoppingCartVM.OrderHeader.OrderTotal += (list.Price * list.Count); list.Product.Description = SD.ConvertToRawHtml(list.Product.Description); if (list.Product.Description.Length > 100) { list.Product.Description = list.Product.Description.Substring(0, 99) + "..."; } } return(View(ShoppingCartVM)); }
public IActionResult Index() { ShoppingCartVM cartList = HttpContext.Session.GetObject <ShoppingCartVM>("ShoppingCart"); return(View(cartList)); }
public async Task <IActionResult> Payment(ShoppingCartVM shoppingcart) { var reservationsFromCart = shoppingcart.Reservations; var subscriptionsFromCart = shoppingcart.Subscriptions; string userID = User.FindFirst(ClaimTypes.NameIdentifier).Value; if (reservationsFromCart != null && reservationsFromCart.Count != 0) { var validations = await IsValidReservations(userID, reservationsFromCart); if (!validations[0]) { ModelState.AddModelError("error", "U kunt maar 10 tickets per match kopen."); return(View("Index", shoppingcart)); } if (!validations[1]) { ModelState.AddModelError("error", "U kunt geen 2 verschillende matchen op dezelfde dag kopen."); return(View("Index", shoppingcart)); } if (!validations[2]) { ModelState.AddModelError("error", "Uw aantal tickets overschrijdt het aantal beschikbare plaatsen."); return(View("Index", shoppingcart)); } List <Reservation> reservations = _mapper.Map <List <Reservation> >(reservationsFromCart); for (var i = 0; i < reservationsFromCart.Count; i++) { reservations[i].CustomerId = userID; shoppingcart.Reservations[i].Price = shoppingcart.Reservations[i].Price * shoppingcart.Reservations[i].NumberOfTickets; reservations[i].Price = shoppingcart.Reservations[i].Price; await _reservationService.CreateAsync(reservations[i]); } } if (subscriptionsFromCart != null && subscriptionsFromCart.Count != 0) { List <Subscription> subscriptions = _mapper.Map <List <Subscription> >(subscriptionsFromCart); foreach (var sub in subscriptions) { sub.CustomerId = userID; await _subscriptionService.CreateAsync(sub); } } var user = await _userManager.FindByIdAsync(userID); var useremail = user.Email; var customer = await _customerService.GetAsync(userID); await _emailSender.SendEmailAsync( useremail, "Betaling Ontvangen", BuildVoucherMessage(shoppingcart, customer.LastName + " " + customer.FirstName) ); HttpContext.Session.SetObject("ShoppingCart", null); return(View(shoppingcart)); }
public ShoppingCartController(ApplicationDbContext db) { _db = db; shoppingCartVM = new ShoppingCartVM() { lstProducts = new List <Models.Products>(), }; }
public async Task <IActionResult> ShoppingCartList() { var model = new ShoppingCartVM() { ShoppingCartItems = await _shoppingCartService.GetAllShoppingCartItems(GetCartId()) }; return(View(model)); }