Ejemplo n.º 1
0
        public ActionResult DeliveryFilter(int x, string deliveryOpt)
        {
            List <OrderDetailsViewModel> od  = new List <OrderDetailsViewModel>();
            CakesPosRepository           cpr = new CakesPosRepository(_connectionString);
            DateTime today = DateTime.Today;

            if (x == -1)
            {
                IEnumerable <OrderHistoryViewModel> orders = cpr.GetOrders().Where(o => o.deliveryOpt == deliveryOpt && o.requiredDate >= today.AddDays(x) && o.requiredDate < today && o.invoice == false);
                foreach (OrderHistoryViewModel o in orders)
                {
                    od.Add(cpr.GetOrderDetails(o.customerId, o.id));
                }
                return(Json(od, JsonRequestBehavior.AllowGet));
            }
            else if (x <= 0)
            {
                IEnumerable <OrderHistoryViewModel> orders = cpr.GetOrders().Where(o => o.deliveryOpt == deliveryOpt && o.requiredDate >= today.AddDays(x) && o.requiredDate <= today && o.invoice == false);
                foreach (OrderHistoryViewModel o in orders)
                {
                    od.Add(cpr.GetOrderDetails(o.customerId, o.id));
                }
                return(Json(od, JsonRequestBehavior.AllowGet));
            }
            else if (x == 1)
            {
                IEnumerable <OrderHistoryViewModel> orders = cpr.GetOrders().Where(o => o.deliveryOpt == deliveryOpt && o.requiredDate == today.AddDays(x) && o.invoice == false);
                foreach (OrderHistoryViewModel o in orders)
                {
                    od.Add(cpr.GetOrderDetails(o.customerId, o.id));
                }
                return(Json(od, JsonRequestBehavior.AllowGet));
            }
            else if (x == 8)
            {
                IEnumerable <OrderHistoryViewModel> orders = cpr.GetOrders().Where(o => o.deliveryOpt == deliveryOpt && o.invoice == false);
                foreach (OrderHistoryViewModel o in orders)
                {
                    od.Add(cpr.GetOrderDetails(o.customerId, o.id));
                }
                return(Json(od, JsonRequestBehavior.AllowGet));
            }
            else
            {
                IEnumerable <OrderHistoryViewModel> orders = cpr.GetOrders().Where(o => o.deliveryOpt == deliveryOpt && o.requiredDate <= today.AddDays(x) && o.requiredDate >= today && o.invoice == false);
                foreach (OrderHistoryViewModel o in orders)
                {
                    od.Add(cpr.GetOrderDetails(o.customerId, o.id));
                }
                return(Json(od, JsonRequestBehavior.AllowGet));
            }
        }
Ejemplo n.º 2
0
        public ActionResult OrderHistoryFilter(int x)
        {
            CakesPosRepository cpr   = new CakesPosRepository(_connectionString);
            DateTime           today = DateTime.Today;

            if (x == -1)
            {
                IEnumerable <OrderHistoryViewModel> yesterdaysOrders = cpr.GetOrders().Where(o => o.requiredDate >= today.AddDays(x) && o.requiredDate < today);
                return(Json(yesterdaysOrders.ToList(), JsonRequestBehavior.AllowGet));
            }
            else if (x <= 0)
            {
                IEnumerable <OrderHistoryViewModel> orders = cpr.GetOrders().Where(o => o.requiredDate >= today.AddDays(x) && o.requiredDate <= today);
                return(Json(orders.OrderByDescending(o => o.requiredDate).ToList(), JsonRequestBehavior.AllowGet));
            }
            else
            {
                IEnumerable <OrderHistoryViewModel> orders = cpr.GetOrders().Where(o => o.requiredDate <= today.AddDays(x) && o.requiredDate >= today);
                return(Json(orders.OrderByDescending(o => o.requiredDate).ToList(), JsonRequestBehavior.AllowGet));
            }
        }
Ejemplo n.º 3
0
        public ActionResult OrderList()
        {
            List <OrderDetailsViewModel>        od     = new List <OrderDetailsViewModel>();
            CakesPosRepository                  cpr    = new CakesPosRepository(_connectionString);
            IEnumerable <OrderHistoryViewModel> orders = cpr.GetOrders().Where(o => o.requiredDate == DateTime.Today && o.invoice == false);

            foreach (OrderHistoryViewModel o in orders)
            {
                od.Add(cpr.GetOrderDetails(o.customerId, o.id));
            }
            return(View(od));
        }