상속: System.Web.UI.Page
        public ViewResult UseExtensionEnumerable() {

            IEnumerable<Product> products = new ShoppingCart {
                Products = new List<Product> {
                    new Product {Name = "Kayak", Price = 275M},
                    new Product {Name = "Lifejacket", Price = 48.95M},
                    new Product {Name = "Soccer ball", Price = 19.50M},
                    new Product {Name = "Corner flag", Price = 34.95M}
                }
            };

            // create and populate an array of Product objects
            Product[] productArray = {
                new Product {Name = "Kayak", Price = 275M},
                new Product {Name = "Lifejacket", Price = 48.95M},
                new Product {Name = "Soccer ball", Price = 19.50M},
                new Product {Name = "Corner flag", Price = 34.95M}
            };

            // get the total value of the products in the cart
            decimal cartTotal = products.TotalPrices();
            decimal arrayTotal = products.TotalPrices();

            return View("Result",
                (object)String.Format("Cart Total: {0}, Array Total: {1}",
                    cartTotal, arrayTotal));
        }
        /// <summary>
        /// Adds an item to the cart
        /// Level: Logic
        /// </summary>
        /// <param name="UserID">The User ID</param>
        /// <param name="ProductID">The Product ID</param>
        /// <param name="Quantity">The Quantity</param>
        public void AddToCart(Guid UserID, Guid ProductID, int Quantity)
        {
            try
            {
                ShoppingCartRepository myRepository = new ShoppingCartRepository(false);

                if (myRepository.ItemExists(ProductID, UserID))
                {
                    myRepository.ChangeQuantity(ProductID, UserID, Quantity);
                }
                else
                {
                    ShoppingCart myShoppingCartItem = new ShoppingCart();

                    myShoppingCartItem.UserFK = UserID;
                    myShoppingCartItem.ProductFK = ProductID;
                    myShoppingCartItem.Quantity = Quantity;

                    myRepository.AddToCart(myShoppingCartItem);
                }
            }
            catch (Exception Exception)
            {
                throw Exception;
            }
        }
 private static IEnumerable<object> EventsToShoppingCart(IEnumerable<dynamic> source)
 {
     foreach (var @event in source)
     {
         var cart = new ShoppingCart { Id = @event.ShoppingCartId };
         {
             switch ((string)@event.Type)
             {
                 case "Create":
                     cart.Customer = new ShoppingCartCustomer
                     {
                         Id = @event.CustomerId,
                         Name = @event.CustomerName
                     };
                     break;
                 case "Add":
                     cart.AddToCart(@event.ProductId, @event.ProductName, (decimal)@event.Price, 1);
                     break;
                 case "Remove":
                     cart.AddToCart(@event.ProductId, @event.ProductName, (decimal)@event.Price, -1);
                     break;
             }
         }
         yield return new
         {
             @event.__document_id,
             ShoppingCartId = cart.Id,
             Aggregate = cart
         };
     }
 }
 private static IEnumerable<object> Reduce(IEnumerable<dynamic> source)
 {
     foreach (var events in source
         .GroupBy(@event => @event.ShoppingCartId))
     {
         var cart = new ShoppingCart { Id = events.Key };
         foreach (var @event in events.OrderBy(x => x.Timestamp))
         {
             switch ((string)@event.Type)
             {
                 case "Create":
                     cart.Customer = new ShoppingCartCustomer
                     {
                         Id = @event.CustomerId,
                         Name = @event.CustomerName
                     };
                     break;
                 case "Add":
                     cart.AddToCart(@event.ProductId, @event.ProductName, (decimal)@event.Price);
                     break;
                 case "Remove":
                     cart.RemoveFromCart(@event.ProductId);
                     break;
             }
         }
         yield return new
         {
             ShoppingCartId = cart.Id,
             Aggregate = JObject.FromObject(cart)
         };
     }
 }
 public ViewCartDialog(ShoppingCart.Cart cart)
 {
     InitializeComponent();
     this.cart = cart;
     totalLabel.Text = string.Format("${0:#.00}", cart.getTotalPrice());
     totalShippingLabel.Text = string.Format("${0:#.00}", cart.getTotalShipping());
 }
 public ShoppingCartMapper()
 {
     if (shoppingCart == null)
     {
         shoppingCart = new ShoppingCart();
     }
 }
예제 #7
0
        public bool ApplyCoupon(ShoppingCart cart, string coupon)
        {
            if (String.IsNullOrWhiteSpace(coupon))
            {
                return false;
            }

            var oldCoupon = cart.CouponCode;

            cart.CouponCode = coupon;

            var context = PricingContext.CreateFrom(cart);
            new PricingPipeline().Execute(context);

            if (context.AppliedPromotions.Any(p => p.RequireCouponCode && p.CouponCode == coupon))
            {
                return true;
            }

            cart.CouponCode = oldCoupon;

            _repository.Database.SaveChanges();

            return false;
        }
예제 #8
0
    protected void Button_Click(object sender, EventArgs e)
    {
        ShoppingCart curCart;
        string gemtype = Request.QueryString.ToString();
        gemtype = gemtype.Replace("Types=", "");

        if (Session["savedCart"] == null)
        {
            curCart = new ShoppingCart();
        }
        else
        {
            curCart = (ShoppingCart)Session["savedCart"];
        }

        bool addResult = curCart.addItem(gemtype);

        if (addResult == false)
        {
            Button.Text = "Already in Cart";
        }
        else
        {
            Session["savedCart"] = curCart;
            Response.Redirect("shopping.aspx?operation=", false);
        }
    }
        public async Task<IHttpActionResult> PutShoppingCart(int id, ShoppingCart shoppingCart)
        {
            if (!ModelState.IsValid)
            {
                return BadRequest(ModelState);
            }

            if (id != shoppingCart.Id)
            {
                return BadRequest();
            }

            db.Entry(shoppingCart).State = EntityState.Modified;

            try
            {
                await db.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!ShoppingCartExists(id))
                {
                    return NotFound();
                }
                else
                {
                    throw;
                }
            }

            return StatusCode(HttpStatusCode.NoContent);
        }
예제 #10
0
 public static float GetTotalPrice(ShoppingCart[] cart)
 {
     float totalPrice = 0;
     for (var i = 0; i < cart.Length; i++)
         totalPrice += cart[i].Price;
     return totalPrice;
 }
예제 #11
0
 public static ShoppingCart GetCart(HttpContextBase context, IStoretUnitOfWork storetUnitOfWork)
 {
     var cart = new ShoppingCart();
     _storetUnitOfWork = storetUnitOfWork;
     cart.ShoppingCartId = GetCartId(context);
     return cart;
 }
예제 #12
0
    static void Main(string[] args)
    {
        // these statements are here so that we can generate
        // results that display US currency values even though
        // the locale of our machines is set to the UK
        System.Globalization.CultureInfo ci = new System.Globalization.CultureInfo("en-US");
        System.Threading.Thread.CurrentThread.CurrentCulture = ci;
        System.Threading.Thread.CurrentThread.CurrentUICulture = ci;

        // create and populate ShoppingCart
        IEnumerable<Product> products = new ShoppingCart {
            Products = new List<Product> {
                new Product {Name = "Kayak", Category = "Watersports", Price = 275M},
                new Product {Name = "Lifejacket", Category = "Watersports", Price = 48.95M},
                new Product {Name = "Soccer ball", Category = "Soccer", Price = 19.50M},
                new Product {Name = "Corner flag", Category = "Soccer", Price = 34.95M}
            }
        };

        IEnumerable<Product> filteredProducts = products.Filter(prod =>
            prod.Category == "Soccer" || prod.Price > 20);

        foreach (Product prod in filteredProducts) {
            Console.WriteLine("Name: {0}, Price: {1:c}", prod.Name, prod.Price);
        }
    }
예제 #13
0
        public ViewResult UseExtentionEnumerable()
        {
            // create and populate Shoppingcart
            ShoppingCart cart = new ShoppingCart
            {
                Products = new List<Product>
                {
                    new Product {Name = "Kayak",Price = 275M },
                    new Product {Name = "Lifejacket",Price = 48.95M },
                    new Product {Name = "Soccer ball",Price = 19.5M },
                    new Product {Name = "Corner flag",Price = 34.95M }
                }
            };

            Product[] productArray = {
                    new Product { Name = "Kayak", Price = 275M },
                    new Product { Name = "Lifejacket", Price = 48.95M },
                    new Product { Name = "Soccer ball", Price = 19.5M },
                    new Product { Name = "Corner flag", Price = 34.95M }
                };

            decimal cartTotal = cart.Totalprices();
            decimal arrayTotal = productArray.Totalprices();

            return View("Result", (object)String.Format("Total: {0:c}, Array Total: {1:c}", cartTotal, arrayTotal ));
        }
예제 #14
0
 // Method to return shopping cart for the session
 public static ShoppingCart GetSessionCart()
 {
     HttpSessionState session = HttpContext.Current.Session;
     if (session["Cart"] != null)
     {
         // Get the cat from session
         ShoppingCart cart = (ShoppingCart)session["Cart"];
         // If there is user ID stored in session but the cart has user ID value set as null,
         // convert it to member cart
         if (session["User"] != null && cart.GetOrderDetails()["UserId"] == null)
         {
             cart.ConvertToMemberCart((session["User"] as Hashtable)["UserId"].ToString());
         }
         return (ShoppingCart)session["Cart"];
     }
     else
     {
         // If no cart stored in session, create a new cart and store it into session
         if (session["User"] == null)
         {
             ShoppingCart cart = new ShoppingCart(null);
             session["Cart"] = cart;
             return cart;
         }
         else
         {
             ShoppingCart cart = new ShoppingCart((session["User"] as Hashtable)["UserId"].ToString());
             session["Cart"] = cart;
             return cart;
         }
     }
 }
예제 #15
0
 public void AssignPromotionsToShoppingCartItems(ShoppingCart cart) {
     foreach (Item item in cart.GetItemsInCart()) {
         if (promotionModel.HasPromotionForItem(item)) {
             cart.AttachPromotionToItem(item, promotionModel.GetPromotionForItem(item));
         }
     }
 }
예제 #16
0
        //http://localhost:50591/Home/UseFilterExtensionMethod2
        public ViewResult UseFilterExtensionMethod2()
        {
            IEnumerable<Product> products = new ShoppingCart
            {
                Products = new List<Product>
                {
                    new Product {Name="p1", Category="apple", Price=10 },
                    new Product {Name="p2", Category="samsung", Price=20 },
                    new Product {Name="p3", Category="apple", Price=30 }
                }
            };


            //람다식
            //Func<in, out> funcName = in => result(out)
            //Func<Product, bool> categoryFilter = prod => prod.Category == "apple";
            Func<Product, bool> categoryFilter = prod => (prod.Category == "apple" && prod.Price > 20);

            decimal total = 0;
            foreach(Product prod in products.Filter(categoryFilter))
            {
                total += prod.Price;
            }

            return View("Result", (object)String.Format("Total: {0}", total));


        }
예제 #17
0
 public void SetUp()
 {
     logger = Substitute.For<Logger>();
     shoppingConsole = Substitute.For<ShoppingConsole>();
     shoppingCartViewModel = new ShoppingCartViewModel(logger);
     shoppingCart = new ShoppingCart(shoppingCartViewModel, shoppingConsole);
 }
예제 #18
0
        public ActionResult Index()
        {
            ShoppingCart cart = new ShoppingCart(calc) { Products = products };
            decimal totalValue = cart.CalculateProductTotal();

            return View(totalValue);
        }
 protected void Page_PreRender(object sender, EventArgs e)
 {
     if (Session["Cart"] != null)
     {
         var oShoppingCart = new ShoppingCart();
         var dt = oShoppingCart.Cart();
         if (dt.Rows.Count == 0)
         {
             lblCountProduct.Text = "0";
         }
         else
         {
             int quantity = 0;
             foreach (DataRow dr in dt.Rows)
             {
                 var Quantity = Convert.ToInt32(string.IsNullOrEmpty(dr["Quantity"].ToString()) ? "0" : dr["Quantity"]);
                 //var Price = Convert.ToDouble(string.IsNullOrEmpty(dr["Price"].ToString()) ? 0 : dr["Price"]);
                 //Total += Quantity * Price;
                 quantity += Quantity;
             }
             lblCountProduct.Text = quantity.ToString();
             //lblTotalPrice.Text = string.Format("{0:##,###.##}", Total).Replace('.', '*').Replace(',', '.').Replace('*', ',');
         }
     }
 }
        public object Put(ShoppingCart request)
        {
            var success = ShoppingCarts.Update(request);

            if (success) return new HttpResult(HttpStatusCode.NoContent, "");
            return new HttpError(HttpStatusCode.BadRequest, "");
        }
예제 #21
0
        public ViewResult UseExtensionEnumerable()
        {
            IEnumerable<Product> products = new ShoppingCart
            {
                Products = new List<Product>
                {
                    new Product {Name = "Kayak", Price = 275M},
                    new Product {Name = "LifeJacket", Price = 48.95M},
                    new Product {Name = "Soccer ball", Price = 19.50M},
                    new Product {Name = "Corner flag", Price = 34.95M}
                }
            };

            //Создать и заполнить массив обьектов Product
            Product[] productArray =
            {
                new Product {Name = "Kayak", Price = 275M},
                new Product {Name = "LifeJacket", Price = 48.95M},
                new Product {Name = "Soccer ball", Price = 19.50M},
                new Product {Name = "Corner flag", Price = 34.95M}
            };
            // Получить общую стоимость товаров в корзине
            var cartTotal = products.TotalPrices();
            var arrayTotal = productArray.TotalPrices();

            return View("Result",
                (object) string.Format("CartTotal: {0:c}, ArrayTotal: {1:c}"
                    , cartTotal, arrayTotal));
        }
예제 #22
0
        public static void Main()
        {
            var cart = new ShoppingCart {
                Products = new List<Product> {
                    new Product {Name="Pencil",Category="Stationery" },
                    new Product {Name="Tie",Category="Clothes" },
                    new Product {Name="Pen",Category="Stationery" }
                }
            };

            Func<Product, bool> clothesFilter = delegate (Product product) {
                return product.Category == "Clothes";
            };
            foreach (var product in cart.Filter(clothesFilter)) {
                Console.Write(product.Name + ", ");
            }
            Console.WriteLine();

            var stationeryItems = cart.Filter(delegate (Product product) {
                return product.Category == "Stationery";
            });
            foreach (var product in stationeryItems) {
                Console.Write(product.Name + ", ");
            }
            Console.WriteLine();
        }
    private void DeleteShoppingCart()
    {
        ShoppingCart shoppingCart = new ShoppingCart();
        shoppingCart.CartGuid = this.CartGUID;

        ProcessGetShoppingCart getShoppingCart = new ProcessGetShoppingCart();
        getShoppingCart.ShoppingCart = shoppingCart;

        try
        {
            getShoppingCart.Invoke();
        }
        catch (Exception ex)
        {
            Response.Redirect("ErrorPage.aspx");
        }

        ProcessDeleteShoppingCartByGuid deleteCart = new ProcessDeleteShoppingCartByGuid();
        deleteCart.ShoppingCart = getShoppingCart.ShoppingCart;

        try
        {
            deleteCart.Invoke();
            Utilities.DeleteCartGUID();
        }
        catch (Exception ex)
        {
            Response.Redirect("ErrorPage.aspx");
        }
    }
    protected void UpdateStockLevel()
    {
        ShoppingCart shoppingCart = new ShoppingCart();
        shoppingCart.CartGuid = this.CartGUID;

        ProcessGetShoppingCart getShoppingCart = new ProcessGetShoppingCart();
        getShoppingCart.ShoppingCart = shoppingCart;

        ProcessUpdateStockLevel updateStockLevel = new ProcessUpdateStockLevel();

        try
        {
            getShoppingCart.Invoke();
        }
        catch (Exception ex)
        {
            Response.Redirect("ErrorPage.aspx");
        }

        updateStockLevel.ShoppingCart = getShoppingCart.ShoppingCart;

        try
        {
            updateStockLevel.Invoke();
        }
        catch (Exception ex)
        {
            Response.Redirect("ErrorPage.aspx");
        }
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            try
            {
                Cart = HttpContext.Current.Session["Cart"] as ShoppingCart;
                if (Cart == null)
                {
                    Cart = new ShoppingCart("ProductsGrid");
                    HttpContext.Current.Session["Cart"] = Cart;
                }

                ProductsGrid.DataSource = Cart.ToTable();
                ProductsGrid.DataBind();

                if (ProductsGrid.Rows.Count > 0)
                {
                    CartTotal.Text = "<p class='total'>Grand Total: "  String.Format("{0:c}", Cart.Total)  "</p>";
                }
                else
                {
                    CartBody.Text = "<p>Your cart is empty!</p>";
                }
            }
            catch (Exception ex)
            {
                CartBody.Text = "<p>Error: "  ex.Message  "</p>";
            }
        }
    }
예제 #26
0
        //http://localhost:50070/Home/UseExtensionEnumerable
        public ViewResult UseExtensionEnumerable()
        {
            //A Type
            IEnumerable<Product> products = new ShoppingCart {
                Products = new List<Product>
                {
                    new Product { Name="p1", Price=10 },
                    new Product { Name="p2", Price=20 },
                    new Product { Name="p3", Price=30 }
                }
            };

            //B Type  (배열도 IEnumerable 인터페이스를 구현하고 있다)
            Product[] productArray =
            {
                new Product { Name="p1", Price=10 },
                new Product { Name="P2", Price=20 },
                new Product { Name="p3", Price=30 }
            };

            //Total
            decimal cartTotal = products.TotalPrices();
            decimal arrayTotal = productArray.TotalPrices();

            return View("Result", (object)String.Format("Cart Total : {0}, Array Total: {1}", cartTotal, arrayTotal));
        }
		public void AddItemInputValidationSpecifications()
		{
			ShoppingCart cart = null;
			"Given new ShoppingCart".Context(() => cart = new ShoppingCart());

			"AddItem throws when ArgumentNullException when null product name is passed".AssertThrows<ArgumentNullException>(() => cart.AddItem(null));
		}
        // Generates an item number based on the attributes of an Item object.
        public static int getItemNumber(ShoppingCart.Item item)
        {
            int itemNumber = (int)item.getType() + 1;
            itemNumber = (itemNumber * 10) + (int)item.getStain();

            // Based on the type of the item, generate additional digits for the item number based on that Item_Types attributes.
            if(item.getType() == ShoppingCart.Item.Item_Type.Board){
                itemNumber = (itemNumber * 10) + (int)((ShoppingCart.Chalkboard)item).getMagneticType();
                itemNumber = (itemNumber * 10) + (int)((ShoppingCart.Chalkboard)item).getFrameStyle();
                itemNumber = (itemNumber * 10) + (int)((ShoppingCart.Chalkboard)item).getHangingDirection();
                itemNumber = (itemNumber * 100) + (int)((ShoppingCart.Chalkboard)item).getLength();
                itemNumber = (itemNumber * 100) + (int)((ShoppingCart.Chalkboard)item).getWidth();
            }
            else if(item.getType() == ShoppingCart.Item.Item_Type.Sconce){
                // Item number multiplied by 10000000 to match length of chalkboard item number.
                itemNumber = (itemNumber * 10000000) + (int)((ShoppingCart.Sconce)item).getHeight();
            }
            else if(item.getType() == ShoppingCart.Item.Item_Type.Box){
                // Item number multiplied by 10000000 to match length of chalkboard item number.
                itemNumber = (itemNumber * 10000000) + (int)((ShoppingCart.Box)item).getLength();
            }
            else if(item.getType() == ShoppingCart.Item.Item_Type.Organizer){
                // Item number multiplied by 10000000 to match length of chalkboard item number.
                itemNumber = (itemNumber * 10) + (int)((ShoppingCart.JarOrganizer)item).getJarCount();
                itemNumber = (itemNumber * 1000000) + (int)((ShoppingCart.JarOrganizer)item).getWidth();
            }
            else if(item.getType() == ShoppingCart.Item.Item_Type.JarSconce){
                // Item number multiplied by 10000000 to match length of chalkboard item number.
                itemNumber = (itemNumber * 10) + (int)((ShoppingCart.JarSconce)item).getSconceCount();
                itemNumber = (itemNumber * 1000000) + (int)((ShoppingCart.JarSconce)item).getHeight();
            }
            return itemNumber;
        }
        public object Delete(ShoppingCart.ShoppingCartItem request)
        {
            var success = ShoppingCarts.RemoveFromCart(UserId, request.Product.Id);

            if (success) return new HttpResult(HttpStatusCode.NoContent, "");
            return new HttpError(HttpStatusCode.BadRequest, "");
        }
		public void ConstructorSpecifications()
		{
			ShoppingCart cart = null;
			"Given new ShoppingCart".Context(() => cart = new ShoppingCart());

			"number of Items is 0".Assert(() => cart.Items.Count.ShouldEqual(0));
		}
예제 #31
0
 public OrderController(IOrderRepository orderRepository, ShoppingCart shoppingCart)
 {
     _orderRepository = orderRepository;
     _shoppingCart    = shoppingCart;
 }
예제 #32
0
 /// <summary>
 /// The method adds a cart in list
 /// </summary>
 /// <param name="cart">session cart</param>
 /// <param name="shopingCart">shopping cart</param>
 /// <returns>return bool</returns>
 public bool AddToCart(Cart cart, ShoppingCart shopingCart)
 {
     return(cart.AddItem(shopingCart, 1));
 }
예제 #33
0
        public string GetFramedHostedCheckout(Customer thisCustomer)
        {
            ShoppingCart cart = new ShoppingCart(thisCustomer.SkinID, thisCustomer, CartTypeEnum.ShoppingCart, 0, false);

            return(GetFramedHostedCheckout(cart));
        }
예제 #34
0
 private void SaveCart(ShoppingCart cart)
 {
     HttpContext.Session.SetJson("Cart", cart);
 }
예제 #35
0
        private ShoppingCart GetCart()
        {
            ShoppingCart cart = HttpContext.Session.GetJson <ShoppingCart>("Cart") ?? new ShoppingCart();

            return(cart);
        }
예제 #36
0
 public ShoppingCartController(StoreContext context, ShoppingCart cartService)
 {
     _context     = context;
     shoppingCart = cartService;
 }
예제 #37
0
 public ShoppingCartSummary(ShoppingCart shoppingCart)
 {
     _shoppingCart = shoppingCart;
 }
        public void CalculateTotals_Should_Be_RightTotals()
        {
            var item1 = new LineItem {
                ListPrice = 10.99m, SalePrice = 9.66m, DiscountAmount = 1.33m, TaxPercentRate = 0.12m, Fee = 0.33m, Quantity = 2
            };
            var item2 = new LineItem {
                ListPrice = 55.22m, SalePrice = 49.33m, DiscountAmount = 5.89m, TaxPercentRate = 0.12m, Fee = 0.12m, Quantity = 5
            };
            var item3 = new LineItem {
                ListPrice = 88.45m, SalePrice = 77.67m, DiscountAmount = 10.78m, TaxPercentRate = 0.12m, Fee = 0.08m, Quantity = 12
            };
            var payment = new Payment {
                Price = 44.52m, DiscountAmount = 10, TaxPercentRate = 0.12m
            };
            var shipment = new Shipment {
                Price = 22.0m, DiscountAmount = 5m, TaxPercentRate = 0.12m
            };

            var cart = new ShoppingCart
            {
                TaxPercentRate = 0.12m,
                Fee            = 13.11m,
                Items          = new List <LineItem> {
                    item1, item2, item3
                },
                Payments = new List <Payment> {
                    payment
                },
                Shipments = new List <Shipment> {
                    shipment
                }
            };
            var totalsCalculator = new DefaultShoppingCartTotalsCalculator();

            totalsCalculator.CalculateTotals(cart);

            Assert.Equal(12.3088m, item1.ListPriceWithTax);
            Assert.Equal(10.8192m, item1.SalePriceWithTax);
            Assert.Equal(9.66m, item1.PlacedPrice);
            Assert.Equal(19.32m, item1.ExtendedPrice);
            Assert.Equal(1.4896m, item1.DiscountAmountWithTax);
            Assert.Equal(2.66m, item1.DiscountTotal);
            Assert.Equal(0.3696m, item1.FeeWithTax);
            Assert.Equal(10.8192m, item1.PlacedPriceWithTax);
            Assert.Equal(21.6384m, item1.ExtendedPriceWithTax);
            Assert.Equal(2.9792m, item1.DiscountTotalWithTax);
            Assert.Equal(2.358m, item1.TaxTotal);

            Assert.Equal(5.6m, shipment.DiscountAmountWithTax);
            Assert.Equal(24.64m, shipment.PriceWithTax);
            Assert.Equal(0.0m, shipment.FeeWithTax);
            Assert.Equal(17.0m, shipment.Total);
            Assert.Equal(19.04m, shipment.TotalWithTax);
            Assert.Equal(2.04m, shipment.TaxTotal);

            Assert.Equal(34.52m, payment.Total);
            Assert.Equal(49.8624m, payment.PriceWithTax);
            Assert.Equal(38.6624m, payment.TotalWithTax);
            Assert.Equal(11.2m, payment.DiscountAmountWithTax);
            Assert.Equal(4.1424m, payment.TaxTotal);

            Assert.Equal(1359.48m, cart.SubTotal);
            Assert.Equal(161.47m, cart.SubTotalDiscount);
            Assert.Equal(180.85m, cart.SubTotalDiscountWithTax);
            Assert.Equal(1522.62m, cart.SubTotalWithTax);
            Assert.Equal(17.00m, cart.ShippingTotal);
            Assert.Equal(19.04m, cart.ShippingTotalWithTax);
            Assert.Equal(22.00m, cart.ShippingSubTotal);
            Assert.Equal(24.64m, cart.ShippingSubTotalWithTax);
            Assert.Equal(44.52m, cart.PaymentSubTotal);
            Assert.Equal(49.86m, cart.PaymentSubTotalWithTax);
            Assert.Equal(150.01m, cart.TaxTotal);
            Assert.Equal(176.47m, cart.DiscountTotal);
            Assert.Equal(197.65m, cart.DiscountTotalWithTax);
            Assert.Equal(13.64m, cart.FeeTotal);
            Assert.Equal(15.28m, cart.FeeTotalWithTax);
            Assert.Equal(14.68m, cart.FeeWithTax);
            Assert.Equal(1413.18m, cart.Total);
        }
예제 #39
0
        public virtual ShoppingCart ToShoppingCart(cartDto.ShoppingCart cartDto, Currency currency, Language language, User user)
        {
            var result = new ShoppingCart(currency, language);

            result.ChannelId      = cartDto.ChannelId;
            result.Comment        = cartDto.Comment;
            result.CustomerId     = cartDto.CustomerId;
            result.CustomerName   = cartDto.CustomerName;
            result.Id             = cartDto.Id;
            result.Name           = cartDto.Name;
            result.ObjectType     = cartDto.ObjectType;
            result.OrganizationId = cartDto.OrganizationId;
            result.Status         = cartDto.Status;
            result.StoreId        = cartDto.StoreId;

            result.Customer = user;

            if (cartDto.Coupon != null)
            {
                result.Coupon = new Coupon
                {
                    Code = cartDto.Coupon,
                    AppliedSuccessfully = !string.IsNullOrEmpty(cartDto.Coupon)
                };
            }

            if (cartDto.Items != null)
            {
                result.Items = cartDto.Items.Select(i => ToLineItem(i, currency, language)).ToList();
                result.HasPhysicalProducts = result.Items.Any(i =>
                                                              string.IsNullOrEmpty(i.ProductType) ||
                                                              !string.IsNullOrEmpty(i.ProductType) && i.ProductType.Equals("Physical", StringComparison.OrdinalIgnoreCase));
            }

            if (cartDto.Addresses != null)
            {
                result.Addresses = cartDto.Addresses.Select(ToAddress).ToList();
            }

            if (cartDto.Payments != null)
            {
                result.Payments = cartDto.Payments.Select(p => ToPayment(p, result)).ToList();
            }

            if (cartDto.Shipments != null)
            {
                result.Shipments = cartDto.Shipments.Select(s => ToShipment(s, result)).ToList();
            }

            if (cartDto.DynamicProperties != null)
            {
                result.DynamicProperties = cartDto.DynamicProperties.Select(ToDynamicProperty).ToList();
            }

            if (cartDto.TaxDetails != null)
            {
                result.TaxDetails = cartDto.TaxDetails.Select(td => ToTaxDetail(td, currency)).ToList();
            }

            result.DiscountAmount       = new Money(cartDto.DiscountAmount ?? 0, currency);
            result.HandlingTotal        = new Money(cartDto.HandlingTotal ?? 0, currency);
            result.HandlingTotalWithTax = new Money(cartDto.HandlingTotalWithTax ?? 0, currency);
            result.IsAnonymous          = cartDto.IsAnonymous == true;
            result.IsRecuring           = cartDto.IsRecuring == true;
            result.VolumetricWeight     = (decimal)(cartDto.VolumetricWeight ?? 0);
            result.Weight = (decimal)(cartDto.Weight ?? 0);

            return(result);
        }
예제 #40
0
 public ShoppingCartController(IPieRepo pieRepo, ShoppingCart shoppingCart)
 {
     _pieRepo      = pieRepo;
     _shoppingCart = shoppingCart;
 }
예제 #41
0
        public virtual Payment ToCartPayment(PaymentMethod paymentMethod, Money amount, ShoppingCart cart)
        {
            var result = new Payment(cart.Currency);

            result.Amount             = amount;
            result.PaymentGatewayCode = paymentMethod.Code;
            result.Price          = paymentMethod.Price;
            result.DiscountAmount = paymentMethod.DiscountAmount;
            result.TaxPercentRate = paymentMethod.TaxPercentRate;
            result.TaxDetails     = paymentMethod.TaxDetails;

            return(result);
        }
예제 #42
0
 public static Payment ToPayment(this cartDto.Payment paymentDto, ShoppingCart cart)
 {
     return(CartConverterInstance.ToPayment(paymentDto, cart));
 }
예제 #43
0
 public static PromotionEvaluationContext ToPromotionEvaluationContext(this ShoppingCart cart)
 {
     return(CartConverterInstance.ToPromotionEvaluationContext(cart));
 }
예제 #44
0
 public static TaxEvaluationContext ToTaxEvalContext(this ShoppingCart cart, Store store)
 {
     return(CartConverterInstance.ToTaxEvalContext(cart, store));
 }
예제 #45
0
        public virtual CartShipmentItem ToShipmentItem(cartDto.ShipmentItem shipmentItemDto, ShoppingCart cart)
        {
            var result = new CartShipmentItem();

            result.Quantity = shipmentItemDto.Quantity ?? 0;

            result.LineItem = cart.Items.FirstOrDefault(x => x.Id == shipmentItemDto.LineItemId);

            return(result);
        }
예제 #46
0
        public virtual PaymentMethod ToPaymentMethod(cartDto.PaymentMethod paymentMethodDto, ShoppingCart cart)
        {
            var retVal = new PaymentMethod(cart.Currency);

            retVal.Code                   = paymentMethodDto.Code;
            retVal.Description            = paymentMethodDto.Description;
            retVal.LogoUrl                = paymentMethodDto.LogoUrl;
            retVal.Name                   = paymentMethodDto.Name;
            retVal.PaymentMethodGroupType = paymentMethodDto.PaymentMethodGroupType;
            retVal.PaymentMethodType      = paymentMethodDto.PaymentMethodType;
            retVal.TaxType                = paymentMethodDto.TaxType;

            retVal.Priority = paymentMethodDto.Priority ?? 0;

            if (paymentMethodDto.Settings != null)
            {
                retVal.Settings = paymentMethodDto.Settings.Where(x => !x.ValueType.EqualsInvariant("SecureString")).Select(x => x.JsonConvert <platformDto.Setting>().ToSettingEntry()).ToList();
            }

            retVal.Currency       = cart.Currency;
            retVal.Price          = new Money(paymentMethodDto.Price ?? 0, cart.Currency);
            retVal.DiscountAmount = new Money(paymentMethodDto.DiscountAmount ?? 0, cart.Currency);
            retVal.TaxPercentRate = (decimal?)paymentMethodDto.TaxPercentRate ?? 0m;

            if (paymentMethodDto.TaxDetails != null)
            {
                retVal.TaxDetails = paymentMethodDto.TaxDetails.Select(td => ToTaxDetail(td, cart.Currency)).ToList();
            }

            return(retVal);
        }
예제 #47
0
 public static Shipment ToShipment(this cartDto.Shipment shipmentDto, ShoppingCart cart)
 {
     return(CartConverterInstance.ToShipment(shipmentDto, cart));
 }
예제 #48
0
 public static cartDto.ShoppingCart ToShoppingCartDto(this ShoppingCart cart)
 {
     return(CartConverterInstance.ToShoppingCartDto(cart));
 }
예제 #49
0
 public static PaymentMethod ToPaymentMethod(this cartDto.PaymentMethod paymentMethodDto, ShoppingCart cart)
 {
     return(CartConverterInstance.ToPaymentMethod(paymentMethodDto, cart));
 }
예제 #50
0
 public static CartShipmentItem ToShipmentItem(this cartDto.ShipmentItem shipmentItemDto, ShoppingCart cart)
 {
     return(CartConverterInstance.ToShipmentItem(shipmentItemDto, cart));
 }
예제 #51
0
 public IActionResult MenuDetails(ShoppingCart shoppingCart)
 {
     return(View());
 }
예제 #52
0
 public static Payment ToCartPayment(this PaymentMethod paymentMethod, Money amount, ShoppingCart cart)
 {
     return(CartConverterInstance.ToCartPayment(paymentMethod, amount, cart));
 }
예제 #53
0
        public OperationsStatus InsertOrderForApp(Order orderObj)
        {
            OperationsStatus operationsStatusObj = null;

            try
            {
                ShoppingCart cartObj = new ShoppingCart();
                cartObj.CustomerID             = orderObj.CustomerID;
                cartObj.LocationID             = orderObj.shippingLocationID;
                cartObj.logDetails             = new LogDetails();
                cartObj.logDetails.CreatedDate = orderObj.commonObj.CreatedDate;

                List <OrderDetail>  OrderDetaillist = new List <OrderDetail>();
                List <ShoppingCart> cartlist        = null;
                cartlist = _Cart_WishlistBusiness.GetCustomerShoppingCart(cartObj);
                for (int i = 0; i < cartlist.Count; i++)
                {
                    if (cartlist[i].FreeDeliveryYN == true)
                    {
                        cartlist[i].ShippingCharge = 0;
                    }
                }


                foreach (var i in cartlist)
                {
                    OrderDetail orderDetailObj = new OrderDetail();

                    orderDetailObj.ItemID         = i.ItemID;
                    orderDetailObj.ProductID      = i.ProductID;
                    orderDetailObj.ProductSpecXML = i.ProductSpecXML;//check if the value passed is correct
                    orderDetailObj.ItemStatus     = "1";
                    orderDetailObj.Qty            = i.Qty;
                    orderDetailObj.Price          = i.CurrentPrice;
                    orderDetailObj.TaxAmt         = orderDetailObj.TaxAmt;
                    orderDetailObj.DiscountAmt    = i.Discount;
                    orderDetailObj.CartId         = i.ID;//For Cart Status Update
                    if (i.StockAvailableYN == true)
                    {
                        OrderDetaillist.Add(orderDetailObj);
                    }
                    else
                    {
                        _Cart_WishlistBusiness.RemoveProductFromCart(i.ID);//Updating Shopping Cart Status as DisCard.
                    }
                }
                if (OrderDetaillist.Count > 0)
                {
                    orderObj.OrderDetailsList = OrderDetaillist;
                    orderObj.OrderStatus      = "1";
                    orderObj.CurrencyCode     = "QAR";
                    operationsStatusObj       = InsertOrderHeaderForApp(orderObj);
                    if (operationsStatusObj.StatusCode == 1)
                    {
                        if (orderObj.OrderDetailsList != null)
                        {
                            foreach (var i in orderObj.OrderDetailsList)
                            {
                                i.OrderID   = int.Parse(operationsStatusObj.ReturnValues.ToString());
                                i.commonObj = orderObj.commonObj;
                                InsertOrderDetail(i);
                                _Cart_WishlistBusiness.UpdateShoppingCartStatus(i.CartId);//Updating Shopping Cart Status as Purchased.
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return(operationsStatusObj);
        }
예제 #54
0
 public ActionResult CountItemsInCart(ShoppingCart cart)
 {
     return(PartialView(cart));
 }
예제 #55
0
 public OrderController(UserManager <AppUser> userManager, ShoppingCart shoppingCart)
 {
     this.userManager  = userManager;
     this.shoppingCart = shoppingCart;
 }
    /// <summary>
    /// Process valid values of this step.
    /// </summary>
    public override bool ProcessStep()
    {
        if (plcAccount.Visible)
        {
            string siteName = SiteContext.CurrentSiteName;

            // Existing account
            if (radSignIn.Checked)
            {
                // Authenticate user
                UserInfo ui = AuthenticationHelper.AuthenticateUser(txtUsername.Text.Trim(), txtPsswd1.Text, SiteContext.CurrentSiteName, false);
                if (ui == null)
                {
                    lblError.Text    = GetString("ShoppingCartCheckRegistration.LoginFailed");
                    lblError.Visible = true;
                    return(false);
                }

                // Sign in customer with existing account
                AuthenticationHelper.AuthenticateUser(ui.UserName, false);

                // Registered user has already started shopping as anonymous user -> Drop his stored shopping cart
                ShoppingCartInfoProvider.DeleteShoppingCartInfo(ui.UserID, siteName);

                // Assign current user to the current shopping cart
                ShoppingCart.User = ui;

                // Save changes to database
                if (!ShoppingCartControl.IsInternalOrder)
                {
                    ShoppingCartInfoProvider.SetShoppingCartInfo(ShoppingCart);
                }

                // Log "login" activity
                ContactID = ModuleCommands.OnlineMarketingGetUserLoginContactID(ui);
                Activity activity = new ActivityUserLogin(ContactID, ui, DocumentContext.CurrentDocument, AnalyticsContext.ActivityEnvironmentVariables);
                activity.Log();

                LoadStep(true);

                // Return false to get to Edit customer page
                return(false);
            }
            // New registration
            else if (radNewReg.Checked)
            {
                txtEmail2.Text             = txtEmail2.Text.Trim();
                pnlCompanyAccount1.Visible = chkCorporateBody.Checked;

                string[] siteList = { siteName };

                // If AssignToSites field set
                if (!String.IsNullOrEmpty(ShoppingCartControl.AssignToSites))
                {
                    siteList = ShoppingCartControl.AssignToSites.Split(';');
                }

                // Check if user exists
                UserInfo ui = UserInfoProvider.GetUserInfo(txtEmail2.Text);
                if (ui != null)
                {
                    lblError.Visible = true;
                    lblError.Text    = GetString("ShoppingCartUserRegistration.ErrorUserExists");
                    return(false);
                }

                // Check all sites where user will be assigned
                if (!UserInfoProvider.IsEmailUnique(txtEmail2.Text.Trim(), siteList, 0))
                {
                    lblError.Visible = true;
                    lblError.Text    = GetString("UserInfo.EmailAlreadyExist");
                    return(false);
                }

                // Create new customer and user account and sign in
                // User
                ui           = new UserInfo();
                ui.UserName  = txtEmail2.Text.Trim();
                ui.Email     = txtEmail2.Text.Trim();
                ui.FirstName = txtFirstName1.Text.Trim();
                ui.LastName  = txtLastName1.Text.Trim();
                ui.FullName  = ui.FirstName + " " + ui.LastName;
                ui.Enabled   = true;
                ui.UserIsGlobalAdministrator = false;
                ui.UserURLReferrer           = MembershipContext.AuthenticatedUser.URLReferrer;
                ui.UserCampaign = Service <ICampaignService> .Entry().CampaignCode;

                ui.UserSettings.UserRegistrationInfo.IPAddress = RequestContext.UserHostAddress;
                ui.UserSettings.UserRegistrationInfo.Agent     = HttpContext.Current.Request.UserAgent;

                try
                {
                    UserInfoProvider.SetPassword(ui, passStrength.Text);

                    foreach (string site in siteList)
                    {
                        UserInfoProvider.AddUserToSite(ui.UserName, site);

                        // Add user to roles
                        if (ShoppingCartControl.AssignToRoles != "")
                        {
                            AssignUserToRoles(ui.UserName, ShoppingCartControl.AssignToRoles, site);
                        }
                    }

                    // Log registered user
                    AnalyticsHelper.LogRegisteredUser(siteName, ui);

                    Activity activity = new ActivityRegistration(ui, DocumentContext.CurrentDocument, AnalyticsContext.ActivityEnvironmentVariables);
                    if (activity.Data != null)
                    {
                        activity.Data.ContactID = ModuleCommands.OnlineMarketingGetUserLoginContactID(ui);
                        activity.Log();
                    }
                }
                catch (Exception ex)
                {
                    lblError.Visible = true;
                    lblError.Text    = ex.Message;
                    return(false);
                }

                // Customer
                CustomerInfo ci = new CustomerInfo();
                ci.CustomerFirstName = txtFirstName1.Text.Trim();
                ci.CustomerLastName  = txtLastName1.Text.Trim();
                ci.CustomerEmail     = txtEmail2.Text.Trim();

                ci.CustomerCompany           = "";
                ci.CustomerOrganizationID    = "";
                ci.CustomerTaxRegistrationID = "";
                if (chkCorporateBody.Checked)
                {
                    ci.CustomerCompany = txtCompany1.Text.Trim();
                    if (mShowOrganizationIDField)
                    {
                        ci.CustomerOrganizationID = txtOrganizationID.Text.Trim();
                    }
                    if (mShowTaxRegistrationIDField)
                    {
                        ci.CustomerTaxRegistrationID = txtTaxRegistrationID.Text.Trim();
                    }
                }

                ci.CustomerUserID  = ui.UserID;
                ci.CustomerSiteID  = 0;
                ci.CustomerEnabled = true;
                ci.CustomerCreated = DateTime.Now;
                CustomerInfoProvider.SetCustomerInfo(ci);

                // Track successful registration conversion
                string name = ShoppingCartControl.RegistrationTrackConversionName;
                ECommerceHelper.TrackRegistrationConversion(ShoppingCart.SiteName, name);

                // Log "customer registration" activity and update profile
                var activityCustomerRegistration = new ActivityCustomerRegistration(ci, MembershipContext.AuthenticatedUser, AnalyticsContext.ActivityEnvironmentVariables);
                if (activityCustomerRegistration.Data != null)
                {
                    if (ContactID <= 0)
                    {
                        activityCustomerRegistration.Data.ContactID = ModuleCommands.OnlineMarketingGetUserLoginContactID(ui);
                    }
                    activityCustomerRegistration.Log();
                }

                // Sign in
                if (ui.UserEnabled)
                {
                    AuthenticationHelper.AuthenticateUser(ui.UserName, false);
                    ShoppingCart.User = ui;

                    ContactID = ModuleCommands.OnlineMarketingGetUserLoginContactID(ui);
                    Activity activity = new ActivityUserLogin(ContactID, ui, DocumentContext.CurrentDocument, AnalyticsContext.ActivityEnvironmentVariables);
                    activity.Log();
                }

                ShoppingCart.ShoppingCartCustomerID = ci.CustomerID;

                // Send new registration notification email
                if (ShoppingCartControl.SendNewRegistrationNotificationToAddress != "")
                {
                    SendRegistrationNotification(ui);
                }
            }
            // Anonymous customer
            else if (radAnonymous.Checked)
            {
                CustomerInfo ci = null;
                if (ShoppingCart.ShoppingCartCustomerID > 0)
                {
                    // Update existing customer account
                    ci = CustomerInfoProvider.GetCustomerInfo(ShoppingCart.ShoppingCartCustomerID);
                }
                if (ci == null)
                {
                    // Create new customer account
                    ci = new CustomerInfo();
                }

                ci.CustomerFirstName = txtFirstName2.Text.Trim();
                ci.CustomerLastName  = txtLastName2.Text.Trim();
                ci.CustomerEmail     = txtEmail3.Text.Trim();

                ci.CustomerCompany           = "";
                ci.CustomerOrganizationID    = "";
                ci.CustomerTaxRegistrationID = "";

                if (chkCorporateBody2.Checked)
                {
                    ci.CustomerCompany = txtCompany2.Text.Trim();
                    if (mShowOrganizationIDField)
                    {
                        ci.CustomerOrganizationID = txtOrganizationID2.Text.Trim();
                    }
                    if (mShowTaxRegistrationIDField)
                    {
                        ci.CustomerTaxRegistrationID = txtTaxRegistrationID2.Text.Trim();
                    }
                }

                ci.CustomerEnabled = true;
                ci.CustomerCreated = DateTime.Now;
                ci.CustomerSiteID  = SiteContext.CurrentSiteID;
                CustomerInfoProvider.SetCustomerInfo(ci);

                // Log "customer registration" activity
                var activity = new ActivityCustomerRegistration(ci, MembershipContext.AuthenticatedUser, AnalyticsContext.ActivityEnvironmentVariables);
                if (activity.Data != null)
                {
                    ContactID = ModuleCommands.OnlineMarketingGetCurrentContactID();
                    activity.Data.ContactID = ContactID;
                    activity.Log();
                }

                // Assign customer to shoppingcart
                ShoppingCart.ShoppingCartCustomerID = ci.CustomerID;
            }
            else
            {
                return(false);
            }
        }
        else
        {
            // Save the customer data
            bool         newCustomer = false;
            CustomerInfo ci          = CustomerInfoProvider.GetCustomerInfoByUserID(ShoppingCartControl.UserInfo.UserID);
            if (ci == null)
            {
                ci = new CustomerInfo();
                ci.CustomerUserID  = ShoppingCartControl.UserInfo.UserID;
                ci.CustomerSiteID  = 0;
                ci.CustomerEnabled = true;
                newCustomer        = true;
            }

            // Old email address
            string oldEmail = ci.CustomerEmail.ToLowerCSafe();

            ci.CustomerFirstName = txtEditFirst.Text.Trim();
            ci.CustomerLastName  = txtEditLast.Text.Trim();
            ci.CustomerEmail     = txtEditEmail.Text.Trim();

            pnlCompanyAccount2.Visible = chkEditCorpBody.Checked;

            ci.CustomerCompany           = "";
            ci.CustomerOrganizationID    = "";
            ci.CustomerTaxRegistrationID = "";
            if (chkEditCorpBody.Checked)
            {
                ci.CustomerCompany = txtEditCompany.Text.Trim();
                if (mShowOrganizationIDField)
                {
                    ci.CustomerOrganizationID = txtEditOrgID.Text.Trim();
                }
                if (mShowTaxRegistrationIDField)
                {
                    ci.CustomerTaxRegistrationID = txtEditTaxRegID.Text.Trim();
                }
            }

            // Update customer data
            CustomerInfoProvider.SetCustomerInfo(ci);

            // Update corresponding user email when required
            if (oldEmail != ci.CustomerEmail.ToLowerCSafe())
            {
                UserInfo user = UserInfoProvider.GetUserInfo(ci.CustomerUserID);
                if (user != null)
                {
                    user.Email = ci.CustomerEmail;
                    UserInfoProvider.SetUserInfo(user);
                }
            }

            // Log "customer registration" activity and update contact profile
            if (newCustomer)
            {
                var activity = new ActivityCustomerRegistration(ci, MembershipContext.AuthenticatedUser, AnalyticsContext.ActivityEnvironmentVariables);
                activity.Log();
            }

            // Set the shopping cart customer ID
            ShoppingCart.ShoppingCartCustomerID = ci.CustomerID;
        }

        try
        {
            if (!ShoppingCartControl.IsInternalOrder)
            {
                ShoppingCartInfoProvider.SetShoppingCartInfo(ShoppingCart);
            }

            ShoppingCart.InvalidateCalculations();
            return(true);
        }
        catch
        {
            return(false);
        }
    }
예제 #57
0
        public string GetFramedHostedCheckout(ShoppingCart cart)
        {
            //fill in code here to display error when none USD currency.
            if ("USD" != Currency.GetDefaultCurrency())
            {
                return("This gateway only supports US Dollars.");
            }

            string  response;
            string  AuthServer = AppLogic.AppConfig("1stPay.PaymentModuleURL");
            decimal cartTotal  = cart.Total(true);

            total = cartTotal - CommonLogic.IIF(cart.Coupon.CouponType == CouponTypeEnum.GiftCard
                                                , CommonLogic.IIF(cartTotal < cart.Coupon.DiscountAmount, cartTotal, cart.Coupon.DiscountAmount)
                                                , 0);
            email          = cart.ThisCustomer.EMail;
            operation_type = TransactionType.ecom_auth;

            //Try to load up the address to be passed into the iframe for the customer
            Address address = new Address(cart.ThisCustomer.CustomerID);

            if (cart.CartItems.Count > 0 && cart.CartItems[0].BillingAddressID > 0)
            {
                address.LoadFromDB(cart.CartItems[0].BillingAddressID);
            }
            else
            {
                address.LoadFromDB(cart.FirstItemShippingAddressID());
            }

            //Load up default
            if (address.AddressID < 1)
            {
                address.LoadFromDB(cart.ThisCustomer.PrimaryBillingAddressID);
            }

            if (address.AddressID > 0)
            {
                name    = (address.FirstName + " " + address.LastName).Trim();
                street  = address.Address1;
                street2 = address.Address2;
                city    = address.City;
                state   = address.State;
                zip     = address.Zip;
                country = address.Country;
                phone   = address.Phone;
            }

            if (cim_on)
            {
                cim_ref_num = cart.ThisCustomer.CustomerGUID;
            }

            if (level_ii_on)
            {
                //Level 2 fields wants the shipping rather than billing zip so load that up.
                Address shipAddress = new Address(cart.ThisCustomer.CustomerID);
                shipAddress.LoadFromDB(cart.FirstItemShippingAddressID());

                //Load up default
                if (shipAddress.AddressID < 1)
                {
                    shipAddress.LoadFromDB(cart.ThisCustomer.PrimaryShippingAddressID);
                }

                tax_amount   = cart.TaxTotal();
                shipping_zip = shipAddress.Zip;
            }

            string RequestID = System.Guid.NewGuid().ToString("N");
            string rawResponseString;

            int  MaxTries       = AppLogic.AppConfigUSInt("GatewayRetries") + 1;
            int  CurrentTry     = 0;
            bool CallSuccessful = false;

            //Make sure the server is up.
            do
            {
                CurrentTry++;
                HttpWebRequest myRequest = (HttpWebRequest)WebRequest.Create(AuthServer + string.Format("?transaction_center_id={0}&embedded={1}&operation_type={2}&respond_inline={3}"
                                                                                                        , transaction_center_id
                                                                                                        , embedded
                                                                                                        , operation_type
                                                                                                        , Convert.ToInt32(respond_inline)
                                                                                                        ));
                myRequest.Method        = "POST";
                myRequest.ContentType   = "text/namevalue";
                myRequest.ContentLength = 0;
                myRequest.Timeout       = 30000;
                try
                {
                    HttpWebResponse myResponse;
                    myResponse = (HttpWebResponse)myRequest.GetResponse();
                    using (StreamReader sr = new StreamReader(myResponse.GetResponseStream()))
                    {
                        rawResponseString = sr.ReadToEnd();
                        sr.Close();
                    }
                    myResponse.Close();

                    CallSuccessful = ValidStatusCodes.Any(vsc => myResponse.StatusCode == vsc);
                }
                catch
                {
                    CallSuccessful = false;
                }
            }while (!CallSuccessful && CurrentTry < MaxTries);

            if (CallSuccessful && order_id < 1)
            {
                order_id = AppLogic.GetNextOrderNumber();
            }


            if (CallSuccessful)
            {
                StringBuilder transactionCommand        = BuildPortalTransactionCommand();
                OrderTransactionCollection transactions = new OrderTransactionCollection(order_id);

                //If we haven't already logged the transaction command for this same order/iframe url combo then add it to the transaction log.
                if (!transactions.Transactions.Any(t => t.TransactionType == (AppLogic.TransactionModeIsAuthCapture() ? AppLogic.ro_TXModeAuthCapture : AppLogic.ro_TXModeAuthOnly) &&
                                                   t.TransactionCommand == transactionCommand.ToString() &&
                                                   t.PaymentGateway == DisplayName(cart.ThisCustomer.LocaleSetting) &&
                                                   t.Amount == total
                                                   ))
                {
                    transactions.AddTransaction(AppLogic.TransactionModeIsAuthCapture() ? AppLogic.ro_TXModeAuthCapture : AppLogic.ro_TXModeAuthOnly, transactionCommand.ToString(), null, null, null, AppLogic.ro_PMCreditCard, DisplayName(cart.ThisCustomer.LocaleSetting), total);
                }

                response = GetFrameSrc(0, 500, transactionCommand.ToString());
            }
            else
            {
                response = "Unable to connect to the server, please try again later.";
            }

            return(response);
        }
예제 #58
0
 public ShoppingCartController(IClothesRepository clothesRepository, ShoppingCart shoppingCart)
 {
     _clothesRepository = clothesRepository;
     _shoppingCart      = shoppingCart;
 }
예제 #59
0
 public virtual Task TakeCartAsync(ShoppingCart cart)
 {
     Cart = cart;
     return(Task.FromResult((object)null));
 }
예제 #60
0
 public OrderService(OnlineShopDbContext db, ShoppingCart shoppingCart)
 {
     this.db           = db;
     this.shoppingCart = shoppingCart;
 }