Beispiel #1
0
        public ActionResult IndexCustomerActive()
        {
            var user = new UserProfile();
            using (CanteenContext ctx = new CanteenContext())
            {
                user = (from o in ctx.UserProfiles orderby o.UserId where o.UserName == User.Identity.Name select o).ToList().FirstOrDefault();
            }
            var orders = new List<Order>();

            using (CanteenContext ctx = new CanteenContext())
            {
                orders = (from o in ctx.Orders.Include("User") orderby o.OrderId where o.User.UserId == user.UserId && o.IsDelivered == false select o).ToList();
            }
            var fullOrders = new List<OrderDTO>();

            foreach (var order in orders)
            {
                var fullOrder = new OrderDTO(order);
                var orderItems = new List<OrderItemDTO>();
                using (CanteenContext ctx = new CanteenContext())
                {
                    var orderItemsFull = (from o in ctx.OrderItems orderby o.OrderItemId where o.OrderId == fullOrder.OrderId select o).ToList();
                    foreach (var i in orderItemsFull)
                    {
                        var menuItem = (from o in ctx.MenuItems orderby o.MenuItemId where o.MenuItemId == i.MenuItemId select o).ToList().FirstOrDefault();
                        var orderX = new OrderItemDTO(i);
                        orderX.MenuItem = menuItem;
                        if (menuItem != null)
                            orderItems.Add(orderX);
                    }

                }
                fullOrder.OrderItems = orderItems;
                if (fullOrder.OrderItems.Count() > 0)
                    fullOrders.Add(fullOrder);
            }
            return View("IndexCustomer", fullOrders);
        }
Beispiel #2
0
        public ActionResult EditEmployee(int id = 0)
        {
            Order order = db.Orders.Find(id);

            if (order == null)
            {
                return HttpNotFound();
            }
            var fullOrder = new OrderDTO(order);

            var orderItems = new List<OrderItemDTO>();
            var orderItemsSorted = new List<OrderItemDTO>();
            using (CanteenContext ctx = new CanteenContext())
            {
                var orderItemsFull = (from o in ctx.OrderItems orderby o.OrderItemId where o.OrderId == fullOrder.OrderId select o).ToList();
                foreach (var i in orderItemsFull)
                {
                    var menuItem = (from o in ctx.MenuItems orderby o.MenuItemId where o.MenuItemId == i.MenuItemId select o).ToList().FirstOrDefault();
                    var orderX = new OrderItemDTO(i);
                    orderX.MenuItem = menuItem;
                    if (menuItem != null)
                    {
                        orderItems.Add(orderX);
                    }
                }

            }
            if (orderItems.Count > 0)
            {

                fullOrder.OrderItems = orderItems.OrderBy(o => o.MenuItemId).ToList();

            }
            return View(fullOrder);
            /* orig
            Order order = db.Orders.Find(id);
            if (order == null)
            {
                return HttpNotFound();
            }

            return View(order);*/
        }
Beispiel #3
0
        public ActionResult Index()
        {
            var orders = db.Orders.ToList();
            var fullOrders = new List<OrderDTO>();

            foreach (var order in orders)
            {
                var fullOrder = new OrderDTO(order);
                var orderItems = new List<OrderItemDTO>();
                using (CanteenContext ctx = new CanteenContext())
                {
                    var orderItemsFull = (from o in ctx.OrderItems orderby o.OrderItemId where o.OrderId == fullOrder.OrderId select o).ToList();
                    foreach (var i in orderItemsFull)
                    {
                        var menuItem = (from o in ctx.MenuItems orderby o.MenuItemId where o.MenuItemId == i.MenuItemId select o).ToList().FirstOrDefault();
                        var orderX = new OrderItemDTO(i);
                        orderX.MenuItem = menuItem;
                        if (menuItem != null)
                            orderItems.Add(orderX);
                    }

                }
                fullOrder.OrderItems = orderItems;
                if (fullOrder.OrderItems.Count() > 0)
                    fullOrders.Add(fullOrder);
            }
            return View(fullOrders);
        }
        //
        // GET: /Statistics/
        public ActionResult Index()
        {
            Statistics statistics = new Statistics();
            var today = new DateTime();
            //var dayOrders = new List<Order>();
            //var monthOrders = new List<Order>();
            //var fullOrderDay = new List<OrderDTO>();
            //var fullOrderMonth = new List<OrderDTO>();
            using (CanteenContext ctx = new CanteenContext())
            {

                statistics.TotalNumberOfUsers = (from o in ctx.UserProfiles select o).Count();
                statistics.TotalNumberOfOrders = (from o in ctx.OrderItems select o).Count();
                statistics.TotalSalesToday = (from o in ctx.Orders where o.IsDelivered == true && o.DateDelivered.Day == today.Day select o).Count();
                statistics.TotalSalesThisMonth = (from o in ctx.Orders where o.IsDelivered == true && o.DateDelivered.Month == today.Month select o).Count();

                var dayOrders = (from o in ctx.Orders where o.IsDelivered == true && o.DateDelivered.Day == today.Day select o).ToList();
                var monthOrders = (from o in ctx.Orders where o.IsDelivered == true && o.DateDelivered.Month == today.Month select o).ToList();

                var orderItemsDay = new List<OrderItemDTO>();
                var orderItemsMonth = new List<OrderItemDTO>();
                var orderItemsDayFull = new List<OrderItem>();
                var orderItemsMonthFull = new List<OrderItem>();
                var fullOrderDay = new List<OrderDTO>();
                var fullOrderMonth = new List<OrderDTO>();

                foreach (var i in dayOrders)
                {
                    fullOrderDay.Add(new OrderDTO(i));
                }
                foreach (var i in monthOrders)
                {
                    fullOrderMonth.Add(new OrderDTO(i));
                }

                foreach (var i in fullOrderDay)
                {
                    orderItemsDayFull = (from o in ctx.OrderItems orderby o.OrderItemId where o.OrderId == i.OrderId select o).ToList();
                }
                foreach (var i in fullOrderMonth)
                {
                    orderItemsMonthFull = (from o in ctx.OrderItems orderby o.OrderItemId where o.OrderId == i.OrderId select o).ToList();
                }

                foreach (var i in orderItemsDayFull)
                {
                    var menuItem = (from o in ctx.MenuItems orderby o.MenuItemId where o.MenuItemId == i.MenuItemId select o).ToList().FirstOrDefault();
                    var orderX = new OrderItemDTO(i);
                    orderX.MenuItem = menuItem;
                    if (menuItem != null)
                    {
                        orderItemsDay.Add(orderX);
                    }
                }
                foreach (var i in orderItemsMonthFull)
                {
                    var menuItem = (from o in ctx.MenuItems orderby o.MenuItemId where o.MenuItemId == i.MenuItemId select o).ToList().FirstOrDefault();
                    var orderX = new OrderItemDTO(i);
                    orderX.MenuItem = menuItem;
                    if (menuItem != null)
                    {
                        orderItemsMonth.Add(orderX);
                    }
                }

                if (orderItemsDay.Count > 0)
                {
                    foreach (var i in orderItemsDay)
                    {

                    }
                }

                //db.Statistics.Add(statistics);
                //db.SaveChanges();

            }
            return View("Details", statistics);
        }