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.PostCode; return(View(ShoppingCartVM)); }
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 Plus(int id) { try { var cart = _uow.ShoppingCart.GetFirstOrDefault(x => x.Id == id, includeProperties: "Product"); if (cart == null) { return(Json(false)); } //return RedirectToAction("Index"); cart.Count += 1; cart.Price = ProjectConstant.GetPriceBaseOnQuantity(cart.Count, cart.Product.Price, cart.Product.Price50, cart.Product.Price100); _uow.Save(); //var allShoppingCart = _uow.ShoppingCart.GetAll(); return(Json(true)); //return RedirectToAction("Index"); } catch (Exception ex) { return(Json(false)); } }
protected override void Execute(SpecificationContext ctx) { ProjectConstant theConstant = null; // Perform the main work of the task here. if (ctx.Project.Constants.TryGetConstant(MyName.Value, ref theConstant)) { // Set the constant value. theConstant.Value = MyValue.Value; //Check if Value is empty or null if (string.IsNullOrEmpty(MyValue.Value)) { //Report Value is empty. this.SetState(NodeExecutionState.SuccessfulWithWarnings, "The constant value was successfully cleared."); } else { // Mark the Task as successful. this.SetState(NodeExecutionState.Successful, "The constant value was successfully set."); } //Set node output value MyNodeOutput.Fulfill(string.Format("The constant '{0}' value was successfully set.", MyName.Value)); } else { // Mark the Task as failed and report that we could not find the constant. this.SetState(NodeExecutionState.Failed, string.Format("The constant '{0}' does not exist.", MyName.Value)); // Set node output value MyNodeOutput.Fulfill(string.Format("The constant '{0}' does not exist.", MyName.Value)); } }
public static void SetErrorConstant(this Project iProject, bool iIsError) { ProjectConstant theConstant = null; iProject.Constants.TryGetConstant(iProject.GetProjectSettings().ErrorConstantName, ref theConstant); theConstant.Value = iIsError; }
public IActionResult Plus(int cartId) { var cart = _uow.ShoppingCart.GetFirstOrDefault(x => x.Id == cartId, includeProperties: "Product"); if (cart == null) { return(RedirectToAction("Index")); } cart.Count += 1; cart.Price = ProjectConstant.GetPriceBaseOnQuantity(cart.Count, cart.Product.Price, cart.Product.Price50, cart.Product.Price100); _uow.Save(); return(RedirectToAction("Index")); }
public IActionResult Minus(int cartId) { var cart = _uow.ShoppingCart.GetFirstOrDefault(x => x.Id == cartId, includeProperties: "Product"); if (cart.Count == 1) { var cnt = _uow.ShoppingCart.GetAll(u => u.ApplicationUserId == cart.ApplicationUserId).ToList().Count; _uow.ShoppingCart.Remove(cart); _uow.Save(); HttpContext.Session.SetInt32(ProjectConstant.shoppingCart, cnt - 1); } else { cart.Count -= 1; cart.Price = ProjectConstant.GetPriceBaseOnQuantity(cart.Count, cart.Product.Price, cart.Product.Price50, cart.Product.Price100); _uow.Save(); } return(RedirectToAction("Index")); }
public IActionResult SummaryPost(string stripeToken) { var claimsIdentity = (ClaimsIdentity)User.Identity; var claims = claimsIdentity.FindFirst(ClaimTypes.NameIdentifier); ShoppingCartVM.OrderHeader.ApplicationUser = _uow.ApplicationUser.GetFirstOrDefault(a => a.Id == claims.Value, includeProperties: "Company"); ShoppingCartVM.ListCart = _uow.ShoppingCart.GetAll(s => s.ApplicationUserId == claims.Value, includeProperties: "Product"); ShoppingCartVM.OrderHeader.PaymentStatus = ProjectConstant.PaymentStatusPending; ShoppingCartVM.OrderHeader.OrderStatus = ProjectConstant.StatusPending; ShoppingCartVM.OrderHeader.ApplicationUserId = claims.Value; ShoppingCartVM.OrderHeader.OrderDate = DateTime.Now; _uow.OrderHeader.Add(ShoppingCartVM.OrderHeader); _uow.Save(); List <OrderDetails> orderDetails = new List <OrderDetails>(); foreach (var orderDetail in ShoppingCartVM.ListCart) { orderDetail.Price = ProjectConstant.GetPriceBaseOnQuantity(orderDetail.Count, orderDetail.Product.Price, orderDetail.Product.Price50, orderDetail.Product.Price100); OrderDetails oDetails = new OrderDetails() { ProductId = orderDetail.ProductId, OrderId = ShoppingCartVM.OrderHeader.Id, Price = orderDetail.Price, Count = orderDetail.Count }; ShoppingCartVM.OrderHeader.OrderTotal += oDetails.Count * oDetails.Price; _uow.OrderDetails.Add(oDetails); } _uow.ShoppingCart.RemoveRange(ShoppingCartVM.ListCart); HttpContext.Session.SetInt32(ProjectConstant.shoppingCart, 0); if (stripeToken == null) { ShoppingCartVM.OrderHeader.PaymentDueDate = DateTime.Now.AddDays(30); ShoppingCartVM.OrderHeader.PaymentStatus = ProjectConstant.PaymentStatusDelayed; ShoppingCartVM.OrderHeader.OrderStatus = ProjectConstant.StatusApproved; } else { var options = new ChargeCreateOptions() { Amount = Convert.ToInt32(ShoppingCartVM.OrderHeader.OrderTotal * 100), Currency = "usd", Description = "Order id:" + ShoppingCartVM.OrderHeader.Id, Source = stripeToken }; var service = new ChargeService(); Charge charge = service.Create(options); if (charge.BalanceTransactionId == null) { ShoppingCartVM.OrderHeader.PaymentStatus = ProjectConstant.PaymentStatusRejected; } else { ShoppingCartVM.OrderHeader.TransactionId = charge.BalanceTransactionId; } if (charge.Status.ToLower() == "succeeded") { ShoppingCartVM.OrderHeader.PaymentStatus = ProjectConstant.PaymentStatusApproved; ShoppingCartVM.OrderHeader.OrderStatus = ProjectConstant.StatusApproved; ShoppingCartVM.OrderHeader.PaymentDate = DateTime.Now; } } _uow.Save(); return(RedirectToAction("OrderConfirmation", "Cart", new { id = ShoppingCartVM.OrderHeader.Id })); }