public IActionResult CustSignUp(Customer customer)
 {
     try
     {
         List <Customer> custs = customerServices.GetAllCustomers();
         if (ValidInvalidServices.ValidEmail(customer.email) == false && validInvalidServices.IsUniqueEmail(customer.email, custs) == false)
         {
             return(StatusCode(409));
         }
         customerServices.AddCustomer(customer);
         Customer newCust = customerServices.GetCustomerByEmail(customer.email);
         Cart     cart    = new Cart();
         cart.custId = newCust.Id;
         cartServices.AddCart(cart);
         return(Ok());
     }
     catch (Exception)
     {
         return(BadRequest());
     }
 }
예제 #2
0
        public Customer NewCustomerValidation()
        {
            string          NewLoc;
            List <Customer> custs = customerServices.GetAllCustomers();
            Customer        cust  = new Customer();

            do
            {
                Console.WriteLine("Enter First Name: ");
                cust.FirstName = Console.ReadLine();
                Console.WriteLine("Enter Last Name: ");
                cust.LastName = Console.ReadLine();
                Console.WriteLine("Enter email: ");
                cust.email = Console.ReadLine();
            } while (ValidInvalidServices.ValidEmail(cust.email) == false && validInvalidServices.IsUniqueEmail(cust.email, custs) == false);
            Boolean keepRunning = true;

            do
            {
                Console.WriteLine("Choose from the follow locations: ");
                Console.WriteLine("[1] Location 1 \n[2] Location 2 \n[3] Location 3");
                NewLoc = Console.ReadLine();
                switch (NewLoc)
                {
                case "1":
                    cust.LocationId = 1;
                    keepRunning     = false;
                    break;

                case "2":
                    cust.LocationId = 2;
                    keepRunning     = false;
                    break;

                case "3":
                    cust.LocationId = 3;
                    keepRunning     = false;
                    break;

                default:
                    ValidInvalidServices.InvalidInput();
                    break;
                }
            } while (keepRunning);
            Console.WriteLine("New Customer Created");
            return(cust);
        }