} // End of the Add method /// <summary> /// Add customer files /// </summary> /// <param name="order">A reference to the order</param> public static void AddCustomerFiles(Order order) { // Get the current domain Domain domain = Tools.GetCurrentDomain(); // Get the order rows List<OrderRow> orderRows = OrderRow.GetByOrderId(order.id); // Get the customer Customer customer = Customer.GetOneById(order.customer_id); // Loop all of the order rows for (int i = 0; i < orderRows.Count; i++) { // Get the product Product product = Product.GetOneById(orderRows[i].product_id, domain.back_end_language); // Continue if the product is null if (product == null) { continue; } // Check if the product has a downloadable files if (product.downloadable_files == true) { // Create the customer file CustomerFile customerFile = new CustomerFile(); customerFile.customer_id = customer.id; customerFile.product_id = product.id; customerFile.language_id = customer.language_id; customerFile.order_date = order.order_date; // Check if the file already exists CustomerFile savedFile = CustomerFile.GetOneById(customerFile.customer_id, customerFile.product_id, customerFile.language_id); if (savedFile == null) { // Add the customer file CustomerFile.Add(customerFile); } } } } // End of the AddCustomerFiles method