Exemple #1
0
        public void newUserUI()
        {
            Console.WriteLine("Please enter your First Name, Last Name and Email");
            Console.WriteLine("First Name:");
            FirstName = GetUserInput();
            while (string.IsNullOrEmpty(FirstName))
            {
                Console.WriteLine("First Name can't be empty. Input your First Name");
                FirstName = GetUserInput();
            }
            Console.WriteLine("Last Name:");
            LastName = GetUserInput();
            while (string.IsNullOrEmpty(LastName))
            {
                Console.WriteLine("Last Name can't be empty. Input your First Name");
                LastName = GetUserInput();
            }
            Console.WriteLine("Email:");
            string Email = GetUserInput();

            while (string.IsNullOrEmpty(LastName))
            {
                Console.WriteLine("Last Name can't be empty. Input your First Name");
                LastName = GetUserInput();
            }
            Library.Customer newCustomer = new Library.Customer(FirstName, LastName, Email);

            storeRepo.AddCustomer(newCustomer);
        }
Exemple #2
0
        public ActionResult Create(StoreApp.Library.Customer customer)
        {
            if (!ModelState.IsValid)
            {
                return(View(customer));
            }
            try
            {
                _storeRepo.AddCustomer(customer);
                return(RedirectToAction("Index"));
            }
            catch (Exception ex)
            {
                _logger.LogError(ex, "Error While adding customer");
                ModelState.AddModelError("", "There was some Error, try again");

                return(View());
            }
        }