Example #1
0
        public ActionResult OrderDetail(long?PlaceOrderId)
        {
            long?UserID     = Convert.ToInt64(User.Identity.Name);
            var  OrdersList = (from customer in db.ShopUsers
                               join PlacedOrders in db.PlacedOrders
                               on customer.UserID equals UserID
                               join orders in db.Orders
                               on PlacedOrders.Id equals orders.PlacedOrdersId
                               join ProductDetail in db.Products
                               on orders.ProductID equals ProductDetail.Id
                               where PlacedOrders.Id == PlaceOrderId && customer.Id == UserID
                               select new CustomerOrdersListModel()
            {
                ProductID = ProductDetail.Id,
                Name = ProductDetail.Name,
                Price = orders.Price,
                Description = ProductDetail.Description,
                Discount = orders.Discount,
                Fee = 0,
                Image = ProductDetail.ProductImage,
                Quantity = orders.Quantity,
                TotalPrice = orders.Price * orders.Quantity
            }).OrderByDescending(x => x.ProductID).ToList();

            var ReceiverDetail             = db.PlacedOrders.FirstOrDefault(x => x.Id == PlaceOrderId && x.ShopUser.UserID == UserID);
            OrdersProductsViewModels Model = new OrdersProductsViewModels();

            Model.CustomerOrdersListModel = OrdersList;
            Model.OrderReceiverName       = ReceiverDetail != null ? ReceiverDetail.ReceivedPersonName : string.Empty;
            Model.ReceiverPhoneNo         = ReceiverDetail != null ? ReceiverDetail.ReceivedPhoneNumber : string.Empty;
            Model.ShippingAddress         = ReceiverDetail != null ? ReceiverDetail.ShippingAddress : string.Empty;
            return(View(Model));
        }
Example #2
0
        public ActionResult OrdersItems(int? PoID)
        {
            // validate current sub domain
            domainIndentifier = new DomainIdentifier(Request.Url.Host, Request.ServerVariables["SERVER_NAME"]);
            var User = domainIndentifier.GetUserRelatedDomain();
            UserID = User != null ? User.Id : 0;
            ViewBag.UserID = UserID;
            Session["CurrentUserID"] = UserID;

            //// check user is login or not
            if (string.IsNullOrEmpty(Convert.ToString(Session["WebloggedUserID"])))
            {
                return Redirect("/Account/Login");
            }

            // bussiness logic
            long ShopUserID = Convert.ToInt64(Session["WebloggedUserID"]);
            ViewBag.ShopUserID = ShopUserID;

            var OrdersList = (from PlacedOrders in db.PlacedOrders
                              where PlacedOrders.Id == PoID && PlacedOrders.ShopUserID == ShopUserID
                              join orders in db.Orders
                              on PlacedOrders.Id equals orders.PlacedOrdersId
                              join ProductDetail in db.Products
                              on orders.ProductID equals ProductDetail.Id
                              select new CustomerOrdersListModel()
                              {
                                  ProductID = ProductDetail.Id,
                                  Name = ProductDetail.Name,
                                  Price = orders.Price,
                                  Description = ProductDetail.Description,
                                  Discount = orders.Discount,
                                  Fee = 0,
                                  Image = ProductDetail.ProductImage,
                                  Quantity = orders.Quantity,
                                  TotalPrice = orders.Price * orders.Quantity
                              }).OrderByDescending(x => x.ProductID).ToList();
            var ReceiverDetail = db.PlacedOrders.FirstOrDefault(x => x.ShopUserID == ShopUserID && x.Id == PoID);
            OrdersProductsViewModels Model = new OrdersProductsViewModels();
            Model.CustomerOrdersListModel = OrdersList;
            Model.OrderReceiverName = ReceiverDetail != null ? ReceiverDetail.ReceivedPersonName : string.Empty;
            Model.ReceiverPhoneNo = ReceiverDetail != null ? ReceiverDetail.ReceivedPhoneNumber : string.Empty;
            Model.ShippingAddress = ReceiverDetail != null ? ReceiverDetail.ShippingAddress : string.Empty;
            return View(Model);
        }