Esempio n. 1
0
        public void AddCustomer(string firstName, string lastName, string telephoneNumber, string email)
        {
            Customer customer = new Customer
            {
                FirstName       = firstName,
                LastName        = lastName,
                TelephoneNumber = telephoneNumber,
                Email           = email
            };

            if (!customer.IsValid())
            {
                throw new ArgumentException();
            }

            Data.Customers.Add(customer);
        }
Esempio n. 2
0
        public void AddCustomer(string firstName, string lastName, string telephoneNumber, string email)
        {
            List <Customer> customers         = GetCustomers();
            int             highestCustomerId = customers.Count > 0 ? customers.Max(i => i.Id) : 0;

            Customer customer = new Customer
            {
                Id              = highestCustomerId + 1,
                FirstName       = firstName,
                LastName        = lastName,
                TelephoneNumber = telephoneNumber,
                Email           = email
            };

            if (!customer.IsValid())
            {
                throw new ArgumentException();
            }

            Data.Customers.Add(customer);
        }
Esempio n. 3
0
        public void ChangeCustomer(int customerId, Customer newDetails)
        {
            Customer customer = Data.Customers.SingleOrDefault(c => c.Id == customerId);

            newDetails.Id = customerId;

            List <Customer> customers = GetCustomers();

            if (customer == null || !customers.Contains(customer) || newDetails == null || !newDetails.IsValid())
            {
                throw new ArgumentException();
            }

            int index = customers.FindIndex(c => c == customer);

            customers[index] = newDetails;
        }
Esempio n. 4
0
        public void ChangeCustomer(Customer customer, Customer newDetails)
        {
            List <Customer> customers = GetCustomers();

            if (customer == null || !customers.Contains(customer) || newDetails == null || !newDetails.IsValid())
            {
                throw new ArgumentException();
            }

            int index = customers.FindIndex(c => c == customer);

            customers[index] = newDetails;
        }