public ActionResult Create(Customer customer)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    Lib.Location libStore = StoreRepo.GetAllStores().First();
                    CustomerRepo.AddCustomer(new Lib.Customer
                    {
                        FirstName = customer.FirstName,
                        LastName  = customer.LastName,
                        Birthday  = customer.Birthday,
                        StoreId   = libStore.LocationId
                    });
                    CustomerRepo.Save();



                    return(RedirectToAction(nameof(Index)));
                }
                return(View(customer));
            }
            catch
            {
                return(View());
            }
        }
        public ActionResult Create(P1B.Customer customer)
        {
            try
            {
                if (customer.FirstName.Length == 0 || customer.LastName.Length == 0)
                {
                    string message = "The customer must have a first and last name.";
                    TempData["ErrorMessage"] = message;
                    _logger.LogWarning(message);
                    return(RedirectToAction("Error", "Home"));
                }
                if (CustomerRepo.CheckCustomerFullNameExists(customer.ReturnFullName()))
                {
                    string message = "There is already a customer in the system with that first and last name.";
                    TempData["ErrorMessage"] = message;
                    _logger.LogWarning(message);
                    return(RedirectToAction("Error", "Home"));
                }
                int defLocation = customer.DefaultLocation ?? 0;
                if (defLocation != 0)
                {
                    bool LocationExists = LocRepo.CheckLocationExists(defLocation);
                    if (!LocationExists)
                    {
                        string message = "This location is not in the database.";
                        TempData["ErrorMessage"] = message;
                        _logger.LogWarning(message);
                        return(RedirectToAction("Error", "Home"));
                    }
                }

                // TODO: Add insert logic here
                var newCustomer = new P1B.Customer
                {
                    FirstName       = customer.FirstName,
                    LastName        = customer.LastName,
                    DefaultLocation = customer.DefaultLocation ?? null
                };

                // TODO: Add insert logic here
                CustomerRepo.AddCustomer(newCustomer);
                return(RedirectToAction(nameof(Index)));
                // TODO: Add insert logic here
            }
            catch (Exception ex)
            {
                _logger.LogError(ex.ToString());
                return(RedirectToAction("Error", "Home"));
            }
        }
        public void AddNewCustomer()
        {
            Outputter.Write("Enter first name for new customer: ");
            string firstName = Inputter.GetStringInput();

            Outputter.Write("Enter last name for new customer: ");
            string lastName = Inputter.GetStringInput();

            Outputter.Write("Enter an email for new customer: ");
            string email = Inputter.GetAnyInput();

            Outputter.Write("Enter an address for new customer: ");
            string address = Inputter.GetAnyInput();

            CustomerRepo.AddCustomer(new Customer(firstName, lastName, email, address));
            Outputter.WriteLine("Customer added successfully!");
        }
Exemple #4
0
 public HttpResponseMessage CreateCustomer([FromBody] Customer customer)
 {
     try
     {
         customer.FullName    = $"{customer.FirstName} {customer.LastName}";
         customer.CreatedBy   = Thread.CurrentPrincipal.Identity.Name;
         customer.CreatedDate = DateTime.Now;
         if (_CustomerRepo.AddCustomer(customer))
         {
             return(Request.CreateResponse(HttpStatusCode.OK, "Customer added successfully."));
         }
         return(Request.CreateResponse(HttpStatusCode.InternalServerError, $"An error has occured. Error details: Customer record is not saved."));
     }
     catch (Exception ex)
     {
         return(Request.CreateResponse(HttpStatusCode.InternalServerError, $"An error has occured. Error details: {ex.Message}"));
     }
 }
 public void TestCreateCustomer()
 {
     //Arrange
     {
         Customer customer       = new Customer();
         string   FirstName      = "Brittany";
         string   LastName       = "Korycki";
         string   TypeOfCustomer = "current";
         //Act
         customer.FirstName      = FirstName;
         customer.LastName       = LastName;
         customer.TypeOfCustomer = TypeOfCustomer;
         customerRepo.AddCustomer(customer);
         Customer customer1 = customerRepo.GetCustomersByLastName(LastName);
         //Assert
         Assert.AreSame(customer1.LastName, "Korycki", "Customer name does not match.");
     }
 }
Exemple #6
0
 public IActionResult Post(Customer customer)
 {
     if (customer == null)
     {
         return(BadRequest("The Customer you are trying to add is empty"));
     }
     else
     {
         if (!ModelState.IsValid)
         {
             return(BadRequest(ModelState));
         }
         else
         {
             repo.AddCustomer(customer);
             return(CreatedAtAction(nameof(Get), new { id = customer.Id }, customer));
         }
     }
 }
        public void AddCustomer()
        {
            Console.WriteLine("Enter the new customers first name:");
            string first = Console.ReadLine();

            Console.WriteLine("Enter the new customers last name:");
            string last = Console.ReadLine();

            Customer.CustomerType newCustType = InputEventTypeHelper("\nEnter the type of customer this is:");
            // test cutomertype and addcustomer. if both true, customer was added
            if (newCustType != Customer.CustomerType.Invalid && customerList.AddCustomer(first, last, newCustType))
            {
                Console.WriteLine("\nCustomer added.");
            }
            else
            {
                Console.WriteLine("\nCustomer not added.");
            }
        }
Exemple #8
0
        public ActionResult Register(Customer customer)
        {
            if (ModelState.IsValid)
            {
                string validationMessage = CustomerRepo.AddCustomer(customer);
                if (validationMessage == "Success")
                {
                    Session["email"]    = customer.Email;
                    Session["Customer"] = customer;

                    return(RedirectToAction("Index", "Home"));
                }
                else
                {
                    ViewBag.ValidationMessage = validationMessage;
                    return(View(customer));
                }
            }
            else
            {
                return(View(customer));
            }
        }
Exemple #9
0
        //Create
        private void CreateCustomer()
        {
            string type = String.Empty;

            Console.Clear();
            Customer newCustomer = new Customer();

            Console.WriteLine("Enter the customer's first name:");
            newCustomer.FirstName = Console.ReadLine();
            Console.WriteLine("Enter the customer's last name:");
            newCustomer.LastName = Console.ReadLine();
            while (type.ToLower() != "past" && type.ToLower() != "current" && type.ToLower() != "potential")
            {
                Console.WriteLine("Please enter the type of customer:");
                type = Console.ReadLine();
            }
            newCustomer.TypeOfCustomer = type;
            Console.WriteLine("Enter the customer's email address:");
            newCustomer.EmailAddress = Console.ReadLine();
            _customerRepo.AddCustomer(newCustomer);

            _customerRepo.EmailToSend(newCustomer.TypeOfCustomer, newCustomer.EmailAddress);
        }
        public int CreateCustomer(RegisterInputModel model)
        {
            var customer = new Customer
            {
                FirstName    = model.FirstName,
                LastName     = model.LastName,
                Email        = model.Email,
                FavoriteBook = model.FavoriteBook,
                PhoneNumber  = model.PhoneNumber
            };

            var address = new Address
            {
                City      = model.City,
                CountryId = model.CountryId,
                ZipCode   = model.Zipcode,
                Street    = model.Street
            };

            _customerRepo.AddCustomer(customer);
            _addressRepo.AddAddress(address);
            _addressRepo.AddAddressToCustomer(customer.Id, address.Id);
            return(customer.Id);
        }
        public async Task <IActionResult> Post(CustomerDto customerDto)
        {
            try
            {
                if (customerDto == null)
                {
                    _logger.LogError("Customer object sent from client is null.");
                    return(BadRequest("Customer object is null"));
                }
                if (!ModelState.IsValid)
                {
                    _logger.LogError("Invalid Customer object sent from client.");
                    return(BadRequest("Invalid model object"));
                }

                bool customerExists = _repo.DoesCustomerAlreadyExists(customerDto);

                if (!customerExists)
                {
                    var result = await _repo.AddCustomer(customerDto);

                    _logger.LogInformation($"customer Added with First Name : {customerDto.FirstName} and Last Name : {customerDto.LastName}");
                    return(CreatedAtRoute("GetCustomerById", new { id = result.Id }, customerDto));
                }
                else
                {
                    _logger.LogError($"customer already exists with the given First Name : {customerDto.FirstName} and Last Name : {customerDto.LastName}");
                }
                return(StatusCode(200, $"customer already exists with the given First Name : {customerDto.FirstName} and Last Name : {customerDto.LastName}"));
            }
            catch (Exception ex)
            {
                _logger.LogError($"Something went wrong inside Add Customer action: {ex.Message}");
                return(StatusCode(500, "Internal server error :" + ex.Message));
            }
        }
Exemple #12
0
 public ActionResult Ödeme(Customer customer)
 {
     customer.ShopList = ShoppingList;
     CustomerRepo.AddCustomer(customer);
     return(RedirectToAction("Index", "Home"));
 }
        // POST: api/Customer
        public HttpResponseMessage Post(Customer customer)
        {
            var id = _repo.AddCustomer(customer);

            return(Request.CreateResponse(HttpStatusCode.Created, customer));
        }
        public void TestAdd()
        {
            testCustomerRepo.AddCustomer("John", "Doe", Customer.CustomerType.Current);

            Assert.IsNotNull(testCustomerRepo);
        }
Exemple #15
0
 private void btn_Add_Click(object sender, EventArgs e)
 {
     try
     {
         if (txt_Firstname.Text == string.Empty)
         {
             MessageBox.Show("Firstname is required!", "Superior Investment", MessageBoxButtons.OK, MessageBoxIcon.Warning);
             txt_Firstname.Focus();
             return;
         }
         if (txt_Lastname.Text == string.Empty)
         {
             MessageBox.Show("Lastname is required!", "Superior Investment", MessageBoxButtons.OK, MessageBoxIcon.Warning);
             txt_Lastname.Focus();
             return;
         }
         if (txt_Email.Text == string.Empty)
         {
             MessageBox.Show("Email is required!", "Superior Investment", MessageBoxButtons.OK, MessageBoxIcon.Warning);
             txt_Email.Focus();
             return;
         }
         if (txt_Phone.Text == string.Empty)
         {
             MessageBox.Show("Phone number is required!", "Superior Investment", MessageBoxButtons.OK, MessageBoxIcon.Warning);
             txt_Phone.Focus();
             return;
         }
         if (txt_Commission.Text == string.Empty)
         {
             MessageBox.Show("Commission is required!", "Superior Investment", MessageBoxButtons.OK, MessageBoxIcon.Warning);
             txt_Commission.Focus();
             return;
         }
         if (txt_Firstname.Text != string.Empty && txt_Lastname.Text != string.Empty &&
             Utilities.IsValidEmail(txt_Email.Text) && isEmailExisting == false && isPhoneNoExisting == false && Utilities.EnsureNumericOnly(txt_Phone.Text) &&
             Utilities.EnsureCurrencyOnly(txt_Commission.Text) && txt_Email.Text != string.Empty && txt_Phone.Text != string.Empty && txt_Commission.Text != string.Empty)
         {
             Customer customer = new Customer()
             {
                 FirstName     = txt_Firstname.Text,
                 LastName      = txt_Lastname.Text,
                 AccountNumber = _CustomerRepo.GetLastAssignedAccountNumber() + 1,
                 Email         = txt_Email.Text,
                 PhoneNumber   = txt_Phone.Text,
                 Product       = txt_Product.Text,
                 Commission    = decimal.Parse(Utilities.RemoveCommasAndDots(txt_Commission.Text)),
                 CreatedBy     = Utilities.USERNAME,
                 CreatedDate   = DateTime.Now.Date
             };
             if (_CustomerRepo.AddCustomer(customer))
             {
                 MessageBox.Show("Customer added successfully!", "Superior Investment", MessageBoxButtons.OK, MessageBoxIcon.Information);
                 txt_Firstname.Text  = string.Empty; txt_Firstname.Focus(); toolTip.Hide(lb_DangerFirstname); lb_DangerFirstname.Hide();
                 txt_Lastname.Text   = string.Empty; toolTip.Hide(lb_DangerLastname); lb_DangerLastname.Hide();
                 txt_Commission.Text = string.Empty; toolTip.Hide(lb_DangerCommission); lb_DangerCommission.Hide();
                 txt_Email.Text      = string.Empty; toolTip.Hide(lb_DangerEmail); lb_DangerEmail.Hide();
                 txt_Phone.Text      = string.Empty; toolTip.Hide(lb_DangerPhone); lb_DangerPhone.Hide();
                 txt_Product.Text    = string.Empty;
             }
         }
         else
         {
             MessageBox.Show("Please ensure filled-in information is correct and complete!", "Superior Investment", MessageBoxButtons.OK, MessageBoxIcon.Warning);
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show($"{Utilities.ERRORMESSAGE} \n Error details: {ex.Message}", "Superior Investment!", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
        static void Main(string[] args)
        {
            var               saveLocation = "../../../../json.txt";
            string            input;
            List <PizzaStore> stores;
            List <Orders>     orders;
            List <Library.Models.Customer> customers;
            //List<Inventory> storeInventory;
            var dataSource = new List <PizzaStore>();  //for initializing repo

            var optionsBuilder = new DbContextOptionsBuilder <project0Context>();

            optionsBuilder.UseSqlServer(secretConfiguration.ConnectionString); //pass options builder what sql server to use and login info
            var options   = optionsBuilder.Options;
            var dbContext = new project0Context(options);

            var storeRepository    = new PizzaStoreRepository(dbContext);
            var orderRepository    = new OrderRepo(dbContext);
            var customerRepository = new CustomerRepo(dbContext);

            //var inventoryRepository = new InventoryRepo(dbContext);

            //testing serialization worked with multiple stores
            //storeRepository.AddStore(new PizzaStore());
            //storeRepository.AddStore(new PizzaStore());

            while (true) //loop until exit command given
            {
                Console.WriteLine("p:\tDisplay or modify pizza stores.");
                Console.WriteLine("a:\tTo add pizza store.");
                Console.WriteLine("c:\tDisplay or add customers.");
                //Console.WriteLine("o:\tTo place order");
                Console.WriteLine("s:\tSave data to disk.");
                //Console.WriteLine("l:\tLoad data from disk.");
                Console.Write("Enter valid menu option, or \"exit\" to quit: ");
                input = Console.ReadLine(); //read command from console

                if (input == "p")           //still need other use cases
                {
                    while (true)
                    {
                        DisplayOrModifyStores();
                        input = Console.ReadLine();

                        if (input == "b")
                        {
                            break;
                        }
                        else if (int.TryParse(input, out var storeNum) &&
                                 storeNum > 0 && storeNum <= stores.Count)   //if input is a valid store number
                        {
                            while (true)
                            {
                                //display chosen stores info
                                var store       = stores[storeNum - 1];
                                var storeString = $"ID: {store.Id}, Name: \"{store.Name}\"";
                                //storeString += ", at Location: " + store.Location.ToString();

                                Console.WriteLine(storeString);
                                Console.WriteLine();

                                Console.WriteLine("o:\tDisplay orders.");
                                Console.WriteLine("i:\tDisplay or modify inventory");
                                Console.Write("Enter valid menu option, or b to go back: ");

                                input = Console.ReadLine();
                                if (input == "b")
                                {
                                    break;
                                }
                                else if (input == "o")
                                {
                                    DisplayOrdersOfStore(store.Id);
                                }
                                else if (input == "i")
                                {
                                    if (store.Inventory == null)
                                    {
                                        Console.WriteLine("No inventory.");
                                    }
                                    else
                                    {
                                        Console.WriteLine("Inventory: ");
                                        foreach (var item in store.Inventory)
                                        {
                                            Console.WriteLine($"Item Name: \"{item.Key}\", " +
                                                              $"Item Quantity: \"{item.Value}\"");
                                        }
                                    }

                                    while (true)
                                    {
                                        Console.WriteLine("a:\tAdd inventory item.");
                                        Console.Write("Enter valid menu option, or b to go back: ");
                                        input = Console.ReadLine();

                                        if (input == "a")
                                        {
                                            Dictionary <string, int> inv = store.Inventory;
                                            AddInventoryItem(ref inv);
                                            store.Inventory = inv;
                                            storeRepository.UpdateStore(store);
                                        }
                                        else if (input == "b")
                                        {
                                            break;
                                        }
                                    }
                                }
                            }
                        }
                        else
                        {
                            Console.WriteLine();
                            Console.WriteLine($"Invalid input \"{input}\".");
                            Console.WriteLine();
                        }
                    }
                }
                else if (input == "a")
                {
                    AddNewPizzaStore();
                }
                else if (input == "c")
                {
                    while (true)
                    {
                        DisplayAddOrModifyCustomers();

                        input = Console.ReadLine();
                        if (input == "b")
                        {
                            break;
                        }
                        else if (input == "a")
                        {
                            AddNewCustomer();
                        }
                        else if (int.TryParse(input, out var custNum) &&
                                 custNum > 0 && custNum <= customers.Count)   //if input is a valid store number
                        {
                            while (true)
                            {
                                //display chosen stores info
                                var cust       = customers[custNum - 1];
                                var custString = $"ID: {cust.Id}, Name: \"{cust.FirstName} {cust.LastName}\"";

                                Console.WriteLine(custString);

                                Console.WriteLine("c:\tModify customer");
                                Console.Write("Enter valid menu option, or b to go back: ");

                                input = Console.ReadLine();
                                if (input == "b")
                                {
                                    break;
                                }
                                else if (input == "c")
                                {
                                    ////Modify Customer!!!!!!!
                                }
                            }
                        }
                    }
                }
                //else if (input == "o")
                //{

                //}
                else if (input == "s")  //use serializer to save data to file
                {
                    SaveToFile();
                }
                //else if (input == "l") //loading data from file
                //{
                //    LoadFromFile();
                //}
                else if (input == "exit") //exits loop and therefore program
                {
                    break;
                }
                else
                {
                    Console.WriteLine();
                    Console.WriteLine($"Invalid input \"{input}\".");
                    Console.WriteLine();
                }
            }



            void DisplayAddOrModifyCustomers()
            {
                customers = customerRepository.GetAllCustomer().ToList();
                Console.WriteLine();
                if (customers.Count == 0)
                {
                    Console.WriteLine("No customers.");
                }
                else
                {
                    for (var i = 1; i <= customers.Count; i++)
                    {
                        var customer   = customers[i - 1]; //indexing starts at 0
                        var custString = $"{i}: \"{customer.FirstName} {customer.LastName}\" ";
                        //storeString += $", at Location: {store.Location.ToString()}";

                        Console.WriteLine(custString);
                    }
                }

                Console.WriteLine("a:\tAdd customer.");
                Console.WriteLine();
                Console.WriteLine("Enter valid menu option, or \"b\" to go back: ");
            }

            void DisplayOrModifyStores()
            {
                stores = storeRepository.GetStores().ToList();
                Console.WriteLine();
                if (stores.Count == 0)
                {
                    Console.WriteLine("No pizza stores.");
                }

                for (var i = 1; i <= stores.Count; i++)
                {
                    var store       = stores[i - 1]; //indexing starts at 0
                    var storeString = $"{i}: \"{store.Name}\"";
                    //storeString += $", at Location: {store.Location.ToString()}";

                    Console.WriteLine(storeString);
                }

                Console.WriteLine();
                Console.WriteLine("Enter valid menu option, or \"b\" to go back: ");
            }

            void DisplayOrdersOfStore(int id)
            {
                orders = orderRepository.GetOrdersOfLocation(id).ToList();
                Console.WriteLine();
                if (orders.Count == 0)
                {
                    Console.WriteLine("No orders.");
                }

                for (var i = 1; i <= orders.Count; i++)
                {
                    var order     = orders[i - 1]; //indexing starts at 0
                    var ordString = $"{i}: Store\\: \"{order.StoreId}\", Customer\\: " +
                                    $"\"{order.CustomerId}\", Time\\: \"{order.OrderTime}";

                    Console.WriteLine(ordString);
                }
            }

            PizzaStore AddNewPizzaStore()
            {
                Console.WriteLine();

                string name = null;
                //Library.Models.Address address = null;
                Dictionary <string, int> inventory = null;

                while (true)
                {
                    Console.Write("Would you like to use the default name? (y/n)");
                    input = Console.ReadLine();
                    if (input == "y")
                    {
                        break;
                    }
                    else if (input == "n")
                    {
                        Console.Write("Enter the new pizza restaurant's name: ");
                        name = Console.ReadLine();
                        break;
                    }
                }

                //while (true)
                //{
                //    Console.Write("Would you like to use a default location? (y/n)");
                //    input = Console.ReadLine();

                //    if (input == "y")
                //    {
                //        break;
                //    }
                //    else if (input == "n")
                //    {
                //        address = NewAddress();
                //        break;
                //    }
                //}

                while (true)
                {
                    Console.Write("Would you like to use the default inventory? (y/n)");
                    input = Console.ReadLine();

                    if (input == "y")
                    {
                        break;
                    }
                    else if (input == "n")
                    {
                        inventory = NewInventory();
                        break;
                    }
                }

                //PizzaStore restaurant = new PizzaStore(name, inventory, address);
                PizzaStore restaurant = new PizzaStore(name, inventory);

                storeRepository.AddStore(restaurant);
                return(restaurant);
            }

            void AddNewCustomer()
            {
                Console.WriteLine();

                Console.Write("Enter the new customer's firstname: ");
                string firstname = Console.ReadLine();

                Console.Write("Enter the new customer's lastname: ");
                string lastname = Console.ReadLine();

                PizzaStore store;

                while (true)
                {
                    Console.Write("Would you like to use the default store? (y/n)");
                    input = Console.ReadLine();

                    if (input == "y")
                    {
                        store = new PizzaStore();
                        break;
                    }
                    else if (input == "n")
                    {
                        while (true)
                        {
                            Console.Write("Would you like to use a new store? (y/n)");
                            input = Console.ReadLine();
                            if (input == "y")
                            {
                                store = AddNewPizzaStore();
                                break;
                            }
                            else if (input == "n")
                            {
                                Console.Write("Enter existing store id: ");
                                input = Console.ReadLine();

                                store = storeRepository.GetStoreById(Convert.ToInt32(input));
                                break;
                            }
                        }

                        break;
                    }
                }

                Library.Models.Customer cust = new Library.Models.Customer(firstname, lastname, store);

                customerRepository.AddCustomer(cust);
            }

            void AddInventoryItem(ref Dictionary <string, int> inv)
            {
                Console.WriteLine("Enter the new item's name: ");
                string name = Console.ReadLine();

                Console.WriteLine("Enter the new item's amount: ");
                int amount = Convert.ToInt32(Console.ReadLine());

                inv.Add(name, amount);
                Console.WriteLine("Added");
            }

            Dictionary <string, int> NewInventory()
            {
                Dictionary <string, int> inventory = new Dictionary <string, int>();

                while (true)
                {
                    Console.Write("Would you like to add an inventory item? (y/n)");
                    input = Console.ReadLine();

                    if (input == "y")
                    {
                        try
                        {
                            AddInventoryItem(ref inventory);
                        }
                        catch (ArgumentException e)
                        {
                            //log it

                            Console.WriteLine(e.Message);
                            return(inventory);
                        }
                    }
                    else if (input == "n")
                    {
                        break;
                    }
                }

                return(inventory);
            }

            //Library.Models.Address NewAddress()
            //{
            //    string street, city, state, zipcode, country;
            //    Console.Write("Enter the new pizza restaurant's location - street: ");
            //    street = Console.ReadLine();
            //    Console.Write("Enter the new pizza restaurant's location - city: ");
            //    city = Console.ReadLine();
            //    Console.Write("Enter the new pizza restaurant's location - state: ");
            //    state = Console.ReadLine();
            //    Console.Write("Enter the new pizza restaurant's location - zipcode: ");
            //    zipcode = Console.ReadLine();
            //    Console.Write("Enter the new pizza restaurant's location - country: ");
            //    country = Console.ReadLine();
            //    try
            //    {
            //        return new Library.Models.Address(street, city, state, zipcode, country);
            //    }
            //    catch (ArgumentException ex)
            //    {
            //        Console.WriteLine(ex.Message);
            //    }
            //    return null;
            //}

            void SaveToFile()
            {
                Console.WriteLine();

                stores = storeRepository.GetStores().ToList(); //get list of all pizza stores

                try
                {
                    var serialized = JsonConvert.SerializeObject(stores, Formatting.Indented); //serialize to the file
                    File.WriteAllTextAsync(saveLocation, serialized);
                    Console.WriteLine("Saving Success.");
                }
                catch (SecurityException ex)
                {
                    Console.WriteLine($"Error while saving: {ex.Message}");
                }
                catch (IOException ex)
                {
                    Console.WriteLine($"Error while saving: {ex.Message}");
                }
                //other exceptions
            }

            //void LoadFromFile()
            //{
            //    Console.WriteLine();
            //    try
            //    {
            //        var deserialized = new List<PizzaStore>();
            //        deserialized = JsonConvert.DeserializeObject<List<PizzaStore>>(File.ReadAllText(saveLocation));
            //        if (deserialized != null)
            //        {
            //            deserialized.ToList();
            //        }

            //        Console.WriteLine("Loading Success.");
            //        var allStores = storeRepository.GetAllStores().ToList();

            //        foreach (var item in allStores) //delete current repo one restaraunt at a time
            //        {
            //            //try
            //            //{
            //                storeRepository.DeleteStore(item); //throws error!
            //            //}
            //            //catch (ArgumentOutOfRangeException e)
            //            //{
            //            //    Console.WriteLine(e.Message);
            //            //}
            //        }

            //        if (deserialized != null)
            //        {
            //            foreach (var item in deserialized) //replace with repo data from file
            //            {
            //                storeRepository.AddStore(item);
            //            }
            //        }
            //    }
            //    catch (FileNotFoundException) //if no save file
            //    {
            //        Console.WriteLine("No saved data found.");
            //    }
            //    catch (SecurityException ex)
            //    {
            //        Console.WriteLine($"Error while loading: {ex.Message}");
            //    }
            //    catch (IOException ex)
            //    {
            //        Console.WriteLine($"Error while loading: {ex.Message}");
            //    }
            //    //other exceptions?
            //}
        }