示例#1
0
        /// <summary>
        /// Takes a DB Location and maps it to a store Location. Will add
        /// to the model if not already there.
        /// </summary>
        /// <param name="DbLocation">The DB representation of the location.</param>
        /// <returns>The Model representation of the location.</returns>
        public static Store.Location MapLocationToStore(DataModel.Location DbLocation)
        {
            Store.Location StoreLocation;
            string         lname = DbLocation.LocationName;

            // if not, add to model
            if (!Locations.Instance.HasLocation(lname))
            {
                StoreLocation = Locations.Instance.RegisterLocation(lname);

                //get invintory
                foreach (Invintory inv in DbLocation.Invintories)
                {
                    try
                    {
                        StoreLocation.AddInventory(inv.ItemName, inv.Quantity);
                    } catch (ItemNotFoundException e)
                    {
                        Console.WriteLine(e.Message);
                        StoreCatalogue.Instance.RegisterItem(inv.ItemName, inv.ItemNameNavigation.ItemPrice);
                        StoreLocation.AddInventory(inv.ItemName, inv.Quantity);
                    }
                }
            }
            else
            {
                StoreLocation = Store.Locations.Instance.GetLocation(lname);
            }

            return(StoreLocation);
        }
示例#2
0
        public void AddLocation(Location location)
        {
            using var context = new StoredbContext(_contextOptions);
            var new_location = new DataModel.Location
            {
                Name = location.Name
            };

            context.Locations.Add(new_location);
            context.SaveChanges();
        }
示例#3
0
        public void CustomerUI()
        {
            Console.WriteLine("Are You a returning customer?  y/n:");
            string input = null;

            while (input != "y" && input != "n")
            {
                Console.WriteLine("Enter 'Y' For Yes, 'N' for No :");
                input = GetUserInput().ToLower();
            }
            if (input == "n")
            {
                newUserUI();
            }
            else
            {
                oldUserUI();
            }

            try
            {
                Library.Customer customerCheck = storeRepo.GetCustomerByName(FirstName, LastName);
            }
            catch (Exception)
            {
                Console.WriteLine("There is no Customer By That Name.");
                Console.WriteLine();
                Console.WriteLine("Please Create A New User");
                newUserUI();
            }

            Library.Customer customer = storeRepo.GetCustomerByName(FirstName, LastName);
            customerId = customer.CustomerId;
            Console.Clear();
            Console.WriteLine($"Welcome\t{customer.FirstName}\t{customer.LastName}\t Email: {customer.Email}");
            Console.WriteLine();
            Console.WriteLine("Enter 'D' To Order From Default Store  or 'O' View Other Locations or 'X' to Exit: ");
            string store = GetUserInput().ToLower();

            while (store != "d" && store != "o" && store != "X")
            {
                Console.WriteLine("Enter 'D' for Default store, 'O' for Other locations or 'X' to Exit:");
                input = GetUserInput().ToLower();
            }
            if (store == "O")
            {
                GetuserLocation();
            }
            else if (store == "X")
            {
                Console.WriteLine("GoodBye!");
                return;
            }
            DataModel.Location location = storeRepo.GetLocationById(locationId);
            Console.WriteLine($"Your Store Location is \t{location.Name}\t{location.Address}\t{location.City}\t{location.State}");
            Console.WriteLine();
            Console.WriteLine("Here is the Current Inventory of This Store");
            GetInventory(locationId);
            Console.WriteLine();
            Console.WriteLine(" Enter 'o' to order an Item or Enter 'e' to Exit:");
            string userOrder = GetUserInput();

            while (userOrder != "o" && userOrder != "e")
            {
                Console.WriteLine("Enter 'o' to order an Item or Enter 'e' to Exit:");
                userOrder = GetUserInput().ToLower();
            }
            if (userOrder == "e")
            {
                Console.WriteLine($"Good Bye");
                return;
            }
            else
            {
                GetUserOrder();
            }
            bool keepOrdering = true;

            while (keepOrdering)
            {
                Console.WriteLine("Order another item? y/n:");
                string moreOrders = GetUserInput().ToLower();
                while (moreOrders != "y" && moreOrders != "n")
                {
                    Console.WriteLine("Enter 'Y' to keep ordering or 'N' to exit :");
                    moreOrders = GetUserInput().ToLower();
                }

                if (moreOrders == "y")
                {
                    GetUserOrder();
                }
                else
                {
                    GetCustomerOrder();
                    Console.WriteLine($"Order Total:   ${total}");
                    Console.WriteLine($"Good Bye");
                    keepOrdering = false;
                }
            }
        }
示例#4
0
 public Location()
 {
     _location = new DataModel.Location();
 }