private Customer CompositeToCustomer(CompositeCustomer comp)
 {
     return(new Customer()
     {
         Name = comp.CustomerName,
         Address = comp.CustomerAddress,
         PhoneNo = comp.CustomerPhoneNo,
         Email = comp.CustomerEmail,
         Zipcode = comp.CustomerZipcode
     });
 }
        private CompositeCustomer CustomerToComposite(Customer customer)
        {
            CompositeCustomer compositeCustomer = new CompositeCustomer();

            compositeCustomer.CustomerAddress = customer.Address;
            compositeCustomer.CustomerEmail   = customer.Email;
            compositeCustomer.CustomerZipcode = customer.Zipcode;
            compositeCustomer.CustomerPhoneNo = customer.PhoneNo;

            return(compositeCustomer);
        }
        public string ProcessSale(List <CompositeProduct> compProducts, CompositeCustomer compCustomer)
        {
            // Lav Composite objekt om til et "normalt" objekt
            Customer       customer   = CompositeToCustomer(compCustomer);
            List <Product> products   = new List <Product>();
            long           totalPrice = 0;

            // Lokalvariabel til at holde styr på totalprisen for ordren


            // Lav listen af Composite Objekter om til en liste af normale Produkter TEST
            foreach (CompositeProduct compP in compProducts)
            {
                products.Add(CompositeToProduct(compP));
                // For hvert produkt, + prisen til totalprisen
                totalPrice += compP.Price;
            }

            // Lav en Order lokalvariabel, med 7 dages levering
            Order order = new Order(totalPrice, DateTime.Now, DateTime.Now.AddDays(7), customer);

            foreach (Product p in products)
            {
                OrderLine orderLine = new OrderLine();
                orderLine.Product = p;
                order.AddToOrderLine(orderLine);
            }

            try
            {
                return(orderController.ProcessSale(order));
            }
            catch (ProductAlreadyUpdatedException e)
            {
                return(e.Message);
            }
            catch (Exception)
            {
                return("Something went wrong. Please try again");
            }
        }
        public void CreateCustomer(CompositeCustomer composite)
        {
            Customer customer = CompositeToCustomer(composite);

            personController.CreateCustomer(customer);
        }