public virtual ActionResult Podsumowanie(Cart shoppingCart) { if (!shoppingCart.Lines.Any() || shoppingCart.ShippingId == 0 || shoppingCart.PaymentId == 0 || shoppingCart.UserAddressModel == null) { return(RedirectToAction(MVC.Koszyk.Index())); } SharedShippingOrderSummaryModels paymentModel; SharedShippingOrderSummaryModels shippingModel; decimal totaltotalvalue; var discount = 0; var user = _userManager.FindById(User.Identity.GetUserId <int>()); if (user != null) { discount = user.Rabat; } var orderitemsummary = OrderViewItemsTotal(shoppingCart, out paymentModel, out shippingModel, out totaltotalvalue, discount); var userModel = new CartAddressModel { NazwaFirmy = shoppingCart.UserAddressModel.NazwaFirmy, Nip = shoppingCart.UserAddressModel.Nip, Imie = shoppingCart.UserAddressModel.Imie, KodPocztowy = shoppingCart.UserAddressModel.KodPocztowy, Miasto = shoppingCart.UserAddressModel.Miasto, Nazwisko = shoppingCart.UserAddressModel.Nazwisko, Numer = shoppingCart.UserAddressModel.Numer, Telefon = shoppingCart.UserAddressModel.Telefon, Ulica = shoppingCart.UserAddressModel.Ulica, Email = shoppingCart.Email }; var orderModel = new OrderViewModelsSummary { OrderViewItemsTotal = orderitemsummary, OrderPayment = paymentModel, OrderShipping = shippingModel, UserAddressModel = userModel, TotalTotalValue = totaltotalvalue - Convert.ToDecimal((orderitemsummary.TotalValue * discount) / 100), Discount = discount, DiscountValue = Convert.ToDecimal((orderitemsummary.TotalValue * discount) / 100).ToString("c").Replace(",", ".") }; if (shoppingCart.UserAddressModel.Nip != null) { orderModel.Firma = true; } return(View(orderModel)); }
public ActionResult CartOrder(int?AddId) { Guid UserId = Guid.Empty; CartAddressModel models = new CartAddressModel(); if (Session["User"] != null) { string UserModel = Session["User"].ToString(); UserId = new Guid(UserModel.Split('|')[1]); } if (UserId == Guid.Empty) { return(RedirectToAction("Login", "Account", new { ReturnUrl = "/Cart/CartOrder" })); } if (AddId > 0) { models.AddModel = AdSer.GetAddressDetailById(AddId.Value); } else { models.AddModel = AdSer.GetTop1Address(UserId); } if (this.Carts != null) { models.CartModel = this.Carts; } else { return(RedirectToAction("Index", "Home")); } //models.UserModel = USer.GetUserDetail(UserId); //models.ShangPinTolit = 0; //models.YLGole = models.UserModel.Gold ?? 0; //models.YLStock = models.UserModel.Stock ?? 0; return(View(models)); }