예제 #1
0
        //My account / Order details page
        public ActionResult Details(int Id)
        {
            var orderDao   = new OrderDao();
            var addressDao = new AddressDao();

            var order = orderDao.GetOrderByOrderNumber(Id);

            order.Address1 = addressDao.GetAddressById(order.BillingAddressId);
            var shippingAddressId = order.ShippingAddressId.HasValue ? (int)order.ShippingAddressId : 0;

            order.Address2 = addressDao.GetAddressById(shippingAddressId);

            if (order == null || order.Deleted)
            {
                return(null);
            }

            return(View(order));
        }
예제 #2
0
        public JsonResult SelectBillingAddress(int addressId, bool shipToSameAddress)
        {
            if (Session[CommonConstants.USER_SESSION] != null)
            {
                var customerDao     = new CustomerDao();
                var addressDao      = new AddressDao();
                var customerSession = (OnlineShop.Common.UserLogin)Session[OnlineShop.Common.CommonConstants.USER_SESSION];
                var customer        = customerDao.GetCustomerById(Convert.ToInt32(customerSession.UserId));
                var address         = addressDao.GetAddressById(addressId);

                if (customer.ShoppingCartItems.Where(x => x.ShoppingCartTypeId == 1).Count() > 0)
                {
                    Order order = new Order()
                    {
                        OrderGuid         = Guid.NewGuid(),
                        CustomerId        = customer.Id,
                        BillingAddressId  = address.Id,
                        ShippingAddressId = shipToSameAddress ? address.Id : 0,
                    };

                    foreach (var item in customer.ShoppingCartItems)
                    {
                        if (item.ShoppingCartTypeId == 1)
                        {
                            OrderItem orderItem = new OrderItem()
                            {
                                OrderItemGuid         = Guid.NewGuid(),
                                ProductId             = item.ProductId,
                                Quantity              = item.Quantity,
                                UnitPriceInclTax      = item.Product.Price,
                                UnitPriceExclTax      = item.Product.Price,
                                PriceInclTax          = item.Product.Price,
                                PriceExclTax          = item.Product.Price,
                                DiscountAmountInclTax = 0,
                                DiscountAmountExclTax = 0,
                                OriginalProductCost   = item.Product.ProductCost,
                                ItemWeight            = item.Product.Weight,
                                RentalStartDateUtc    = item.RentalStartDateUtc,
                                RentalEndDateUtc      = item.RentalEndDateUtc
                            };
                            order.OrderItems.Add(orderItem);
                        }
                    }
                    customer.Orders.Add(order);
                    TempData["Customer"] = customer;
                    return(Json(new
                    {
                        Status = true
                    }));
                    //return PartialView("ShippingMethod", customer);
                    //return RedirectToAction("ShippingMethod", "CheckOut");
                }
                else
                {
                    return(Json(new
                    {
                        Status = false
                    }));
                }
            }
            else
            {
                return(Json(new
                {
                    Status = false
                }));
            }
        }