예제 #1
0
        public void getLocationHistory(Model.Customers customer)
        {
            var queryCustomerLocationHistory = (
                from loc in _context.LocationVisiteds
                join store in _context.Stores on loc.StoreId equals store.StoreId
                where loc.CustomerId == customer.CustomerID
                select new { store.StoreName, store.StoreLocation }
                ).Distinct();

            if (!queryCustomerLocationHistory.Any())
            {
                Console.WriteLine("| Seems like you haven't visited any stores.               |");
                Console.WriteLine("| Please visit a shop and see what they have to offer!     |");
            }
            else
            {
                foreach (var item in queryCustomerLocationHistory)
                {
                    Console.WriteLine("| {0, -26} | {1, 27} |", item.StoreName, item.StoreLocation);
                }
            }
        }
예제 #2
0
        public void getOrderHistory(Model.Customers customer)
        {
            var queryCustomerOrderHistory = (
                from track in _context.TrackOrders
                join order in _context.Orders on track.OrderId equals order.OrderId
                where track.CustomerId == customer.CustomerID
                select new { track.OrderId, order.OrderDate, order.OrderTotal }
                ).Distinct();

            if (!queryCustomerOrderHistory.Any())
            {
                Console.WriteLine("| Seems like you haven't made an order                |");
                Console.WriteLine("| Please visit a shop to make your first order.       |");
            }
            else
            {
                foreach (var item in queryCustomerOrderHistory)
                {
                    int   total = (int)item.OrderTotal;
                    int[] money = new int[4];
                    for (int i = 3; i >= 0; i--)
                    {
                        if (i == 0)
                        {
                            money[i] = total;
                        }
                        else
                        {
                            money[i] = total % 10;
                            total    = (int)total / 10;
                        }
                    }
                    Console.WriteLine(String.Format("| {0,-20} | {1, -22} | {2, 3}{3, 1} {4, 3}{5, 1} {6, 3}{7, 1} {8, 3}{9, 1} |", item.OrderId, item.OrderDate, money[0], "p", money[1], "g", money[2], "s", money[3], "c"));
                }
            }
        }
예제 #3
0
 public void getOrderHistory(Model.Customers customer, int number)
 {
     if (number == 0)
     {
         var queryCustomerOrderHistory = (
             from track in _context.TrackOrders
             join order in _context.Orders on track.OrderId equals order.OrderId
             where track.CustomerId == customer.CustomerID
             orderby order.OrderDate descending
             select new { track.OrderId, order.OrderDate, order.OrderTotal }
             ).Distinct().OrderByDescending(s => s.OrderDate);
         if (!queryCustomerOrderHistory.Any())
         {
             Console.WriteLine("| Seems like you haven't made an order                |");
             Console.WriteLine("| Please visit a shop to make your first order.       |");
         }
         else
         {
             foreach (var item in queryCustomerOrderHistory)
             {
                 Console.WriteLine(String.Format("| {0,-12} | {1, -22} | {2, 10}c |", item.OrderId, item.OrderDate, item.OrderTotal));
             }
         }
     }
     else if (number == 1)
     {
         var queryCustomerOrderHistory = (
             from track in _context.TrackOrders
             join order in _context.Orders on track.OrderId equals order.OrderId
             where track.CustomerId == customer.CustomerID
             orderby order.OrderDate ascending
             select new { track.OrderId, order.OrderDate, order.OrderTotal }
             ).Distinct().OrderBy(s => s.OrderDate);
         if (!queryCustomerOrderHistory.Any())
         {
             Console.WriteLine("| Seems like you haven't made an order                |");
             Console.WriteLine("| Please visit a shop to make your first order.       |");
         }
         else
         {
             foreach (var item in queryCustomerOrderHistory)
             {
                 Console.WriteLine(String.Format("| {0,-12} | {1, -22} | {2, 10}c |", item.OrderId, item.OrderDate, item.OrderTotal));
             }
         }
     }
     else if (number == 2)
     {
         var queryCustomerOrderHistory = (
             from track in _context.TrackOrders
             join order in _context.Orders on track.OrderId equals order.OrderId
             where track.CustomerId == customer.CustomerID
             orderby order.OrderTotal descending
             select new { track.OrderId, order.OrderDate, order.OrderTotal }
             ).Distinct().OrderByDescending(s => s.OrderTotal);
         if (!queryCustomerOrderHistory.Any())
         {
             Console.WriteLine("| Seems like you haven't made an order                |");
             Console.WriteLine("| Please visit a shop to make your first order.       |");
         }
         else
         {
             foreach (var item in queryCustomerOrderHistory)
             {
                 Console.WriteLine(String.Format("| {0,-12} | {1, -22} | {2, 10}c |", item.OrderId, item.OrderDate, item.OrderTotal));
             }
         }
     }
     else if (number == 3)
     {
         var queryCustomerOrderHistory = (
             from track in _context.TrackOrders
             join order in _context.Orders on track.OrderId equals order.OrderId
             where track.CustomerId == customer.CustomerID
             orderby order.OrderTotal ascending
             select new { track.OrderId, order.OrderDate, order.OrderTotal }
             ).Distinct().OrderBy(s => s.OrderTotal);
         if (!queryCustomerOrderHistory.Any())
         {
             Console.WriteLine("| Seems like you haven't made an order                |");
             Console.WriteLine("| Please visit a shop to make your first order.       |");
         }
         else
         {
             foreach (var item in queryCustomerOrderHistory)
             {
                 Console.WriteLine(String.Format("| {0,-12} | {1, -22} | {2, 10}c |", item.OrderId, item.OrderDate, item.OrderTotal));
             }
         }
     }
     else
     {
         var queryCustomerOrderHistory = (
             from track in _context.TrackOrders
             join order in _context.Orders on track.OrderId equals order.OrderId
             where track.CustomerId == customer.CustomerID
             select new { track.OrderId, order.OrderDate, order.OrderTotal }
             ).Distinct();
         if (!queryCustomerOrderHistory.Any())
         {
             Console.WriteLine("| Seems like you haven't made an order                |");
             Console.WriteLine("| Please visit a shop to make your first order.       |");
         }
         else
         {
             foreach (var item in queryCustomerOrderHistory)
             {
                 Console.WriteLine(String.Format("| {0,-12} | {1, -22} | {2, 10}c |", item.OrderId, item.OrderDate, item.OrderTotal));
             }
         }
     }
 }