diff --git a/TechTest/AnyCompany/AnyCompany.csproj b/TechTest/AnyCompany.Models/AnyCompany.Models.csproj
similarity index 87%
rename from TechTest/AnyCompany/AnyCompany.csproj
rename to TechTest/AnyCompany.Models/AnyCompany.Models.csproj
index 5b0498d..542c4e8 100644
--- a/TechTest/AnyCompany/AnyCompany.csproj
+++ b/TechTest/AnyCompany.Models/AnyCompany.Models.csproj
@@ -4,13 +4,14 @@
Debug
AnyCPU
- {C7E15594-7D8F-4C18-9DD7-14F3FBB1572D}
+ {ACF38111-C769-4BEA-B9B8-AB3B71A14731}
Library
Properties
- AnyCompany
- AnyCompany
+ AnyCompany.Models
+ AnyCompany.Models
v4.6.1
512
+ true
true
@@ -41,10 +42,7 @@
-
-
-
diff --git a/TechTest/AnyCompany/Customer.cs b/TechTest/AnyCompany.Models/Customer.cs
similarity index 55%
rename from TechTest/AnyCompany/Customer.cs
rename to TechTest/AnyCompany.Models/Customer.cs
index aa994b6..8bb3be4 100644
--- a/TechTest/AnyCompany/Customer.cs
+++ b/TechTest/AnyCompany.Models/Customer.cs
@@ -1,13 +1,18 @@
using System;
+using System.Collections.Generic;
-namespace AnyCompany
+namespace AnyCompany.Models
{
public class Customer
{
- public string Country { get; set; }
+ public int CustomerId { get; set; }
+
+ public string Name { get; set; }
public DateTime DateOfBirth { get; set; }
- public string Name { get; set; }
+ public string Country { get; set; }
+
+ public List Orders { get; set; }
}
}
diff --git a/TechTest/AnyCompany/Order.cs b/TechTest/AnyCompany.Models/Order.cs
similarity index 68%
rename from TechTest/AnyCompany/Order.cs
rename to TechTest/AnyCompany.Models/Order.cs
index fec8e7b..c23d592 100644
--- a/TechTest/AnyCompany/Order.cs
+++ b/TechTest/AnyCompany.Models/Order.cs
@@ -1,8 +1,9 @@
-namespace AnyCompany
+namespace AnyCompany.Models
{
public class Order
{
public int OrderId { get; set; }
+ public int CustomerId { get; set; }
public double Amount { get; set; }
public double VAT { get; set; }
}
diff --git a/TechTest/AnyCompany.Models/Properties/AssemblyInfo.cs b/TechTest/AnyCompany.Models/Properties/AssemblyInfo.cs
new file mode 100644
index 0000000..5d10fab
--- /dev/null
+++ b/TechTest/AnyCompany.Models/Properties/AssemblyInfo.cs
@@ -0,0 +1,36 @@
+using System.Reflection;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+
+// General Information about an assembly is controlled through the following
+// set of attributes. Change these attribute values to modify the information
+// associated with an assembly.
+[assembly: AssemblyTitle("AnyCompany.Models")]
+[assembly: AssemblyDescription("")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("")]
+[assembly: AssemblyProduct("AnyCompany.Models")]
+[assembly: AssemblyCopyright("Copyright © 2020")]
+[assembly: AssemblyTrademark("")]
+[assembly: AssemblyCulture("")]
+
+// Setting ComVisible to false makes the types in this assembly not visible
+// to COM components. If you need to access a type in this assembly from
+// COM, set the ComVisible attribute to true on that type.
+[assembly: ComVisible(false)]
+
+// The following GUID is for the ID of the typelib if this project is exposed to COM
+[assembly: Guid("acf38111-c769-4bea-b9b8-ab3b71a14731")]
+
+// Version information for an assembly consists of the following four values:
+//
+// Major Version
+// Minor Version
+// Build Number
+// Revision
+//
+// You can specify all the values or you can default the Build and Revision Numbers
+// by using the '*' as shown below:
+// [assembly: AssemblyVersion("1.0.*")]
+[assembly: AssemblyVersion("1.0.0.0")]
+[assembly: AssemblyFileVersion("1.0.0.0")]
diff --git a/TechTest/AnyCompany.Repository/AnyCompany.Repository.csproj b/TechTest/AnyCompany.Repository/AnyCompany.Repository.csproj
new file mode 100644
index 0000000..b0f73ad
--- /dev/null
+++ b/TechTest/AnyCompany.Repository/AnyCompany.Repository.csproj
@@ -0,0 +1,60 @@
+
+
+
+
+ Debug
+ AnyCPU
+ {4C883089-3973-43FD-B6B0-337968CBD1EE}
+ Library
+ Properties
+ AnyCompany.Repository
+ AnyCompany.Repository
+ v4.6.1
+ 512
+ true
+
+
+
+ true
+ full
+ false
+ bin\Debug\
+ DEBUG;TRACE
+ prompt
+ 4
+
+
+ pdbonly
+ true
+ bin\Release\
+ TRACE
+ prompt
+ 4
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ {acf38111-c769-4bea-b9b8-ab3b71a14731}
+ AnyCompany.Models
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/TechTest/AnyCompany.Repository/App.config b/TechTest/AnyCompany.Repository/App.config
new file mode 100644
index 0000000..afbd032
--- /dev/null
+++ b/TechTest/AnyCompany.Repository/App.config
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/TechTest/AnyCompany.Repository/CustomerRepository.cs b/TechTest/AnyCompany.Repository/CustomerRepository.cs
new file mode 100644
index 0000000..b721e36
--- /dev/null
+++ b/TechTest/AnyCompany.Repository/CustomerRepository.cs
@@ -0,0 +1,92 @@
+using AnyCompany.Models;
+using System;
+using System.Collections.Generic;
+using System.Configuration;
+using System.Data;
+using System.Data.SqlClient;
+
+namespace AnyCompany.Repository
+{
+ public static class CustomerRepository
+ {
+ private static string _connectionString = ConfigurationManager.ConnectionStrings["AnyCompany"].ConnectionString;
+
+ public static Customer Save(Customer customer)
+ {
+ using (SqlConnection connection = new SqlConnection(_connectionString))
+ {
+
+ SqlCommand command = new SqlCommand("INSERT INTO Customer (Name, DateOfBirth, Country) OUTPUT INSERTED.CustomerId VALUES (@Name, @DateOfBirth, @Country) ", connection);
+
+ command.Parameters.AddWithValue("@Name", customer.Name);
+ command.Parameters.AddWithValue("@DateOfBirth", customer.DateOfBirth);
+ command.Parameters.AddWithValue("@Country", customer.Country);
+
+ connection.Open();
+
+ customer.CustomerId = (int)command.ExecuteScalar();
+
+ }
+
+ return customer;
+ }
+
+ public static Customer Load(int customerId)
+ {
+ Customer customer = new Customer();
+
+ using (SqlConnection connection = new SqlConnection(_connectionString))
+ {
+ SqlCommand command = new SqlCommand("SELECT * FROM Customer WHERE CustomerId = " + customerId, connection);
+
+ connection.Open();
+
+ var reader = command.ExecuteReader();
+
+ while (reader.Read())
+ {
+ customer.CustomerId = Int32.Parse(reader["CustomerId"].ToString());
+ customer.Name = reader["Name"].ToString();
+ customer.DateOfBirth = DateTime.Parse(reader["DateOfBirth"].ToString());
+ customer.Country = reader["Country"].ToString();
+ }
+
+ reader.Close();
+
+ }
+
+ return customer;
+ }
+
+ public static List LoadCollection()
+ {
+ List customers = new List();
+
+ using (SqlConnection connection = new SqlConnection(_connectionString))
+ {
+ SqlCommand command = new SqlCommand("SELECT * FROM Customer", connection);
+
+ connection.Open();
+
+ var reader = command.ExecuteReader();
+
+ while (reader.Read())
+ {
+ Customer customer = new Customer()
+ {
+ CustomerId = Int32.Parse(reader["CustomerId"].ToString()),
+ Name = reader["Name"].ToString(),
+ DateOfBirth = DateTime.Parse(reader["DateOfBirth"].ToString()),
+ Country = reader["Country"].ToString()
+ };
+
+ customers.Add(customer);
+ }
+
+ reader.Close();
+ }
+
+ return customers;
+ }
+ }
+}
diff --git a/TechTest/AnyCompany.Repository/OrderRepository.cs b/TechTest/AnyCompany.Repository/OrderRepository.cs
new file mode 100644
index 0000000..ae8a0cc
--- /dev/null
+++ b/TechTest/AnyCompany.Repository/OrderRepository.cs
@@ -0,0 +1,58 @@
+using AnyCompany.Models;
+using System;
+using System.Collections.Generic;
+using System.Configuration;
+using System.Data.SqlClient;
+
+namespace AnyCompany.Repository
+{
+ public static class OrderRepository
+ {
+ private static string _connectionString = ConfigurationManager.ConnectionStrings["AnyCompany"].ConnectionString;
+
+ public static Order Save(Order order)
+ {
+ using (SqlConnection connection = new SqlConnection(_connectionString))
+ {
+ SqlCommand command = new SqlCommand("INSERT INTO Orders (CustomerId, Amount, VAT) OUTPUT INSERTED.OrderId VALUES (@CustomerId, @Amount, @VAT)", connection);
+
+ command.Parameters.AddWithValue("@CustomerId", order.CustomerId);
+ command.Parameters.AddWithValue("@Amount", order.Amount);
+ command.Parameters.AddWithValue("@VAT", order.VAT);
+
+ connection.Open();
+
+ order.OrderId = (int)command.ExecuteScalar();
+ }
+
+ return order;
+ }
+
+ public static List LoadCollection(int customerId)
+ {
+ List orders = new List();
+
+ using (SqlConnection connection = new SqlConnection(_connectionString))
+ {
+ SqlCommand command = new SqlCommand("SELECT * FROM Orders WHERE CustomerId = " + customerId, connection);
+
+ connection.Open();
+
+ var reader = command.ExecuteReader();
+
+ while (reader.Read())
+ {
+ Order order = new Order()
+ {
+ CustomerId = Int32.Parse(reader["CustomerId"].ToString()),
+ Amount = double.Parse(reader["Amount"].ToString()),
+ VAT = double.Parse(reader["VAT"].ToString())
+ };
+
+ orders.Add(order);
+ }
+ }
+ return orders;
+ }
+ }
+}
diff --git a/TechTest/AnyCompany.Repository/Properties/AssemblyInfo.cs b/TechTest/AnyCompany.Repository/Properties/AssemblyInfo.cs
new file mode 100644
index 0000000..ccd4377
--- /dev/null
+++ b/TechTest/AnyCompany.Repository/Properties/AssemblyInfo.cs
@@ -0,0 +1,36 @@
+using System.Reflection;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+
+// General Information about an assembly is controlled through the following
+// set of attributes. Change these attribute values to modify the information
+// associated with an assembly.
+[assembly: AssemblyTitle("AnyCompany.Repository")]
+[assembly: AssemblyDescription("")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("")]
+[assembly: AssemblyProduct("AnyCompany.Repository")]
+[assembly: AssemblyCopyright("Copyright © 2020")]
+[assembly: AssemblyTrademark("")]
+[assembly: AssemblyCulture("")]
+
+// Setting ComVisible to false makes the types in this assembly not visible
+// to COM components. If you need to access a type in this assembly from
+// COM, set the ComVisible attribute to true on that type.
+[assembly: ComVisible(false)]
+
+// The following GUID is for the ID of the typelib if this project is exposed to COM
+[assembly: Guid("4c883089-3973-43fd-b6b0-337968cbd1ee")]
+
+// Version information for an assembly consists of the following four values:
+//
+// Major Version
+// Minor Version
+// Build Number
+// Revision
+//
+// You can specify all the values or you can default the Build and Revision Numbers
+// by using the '*' as shown below:
+// [assembly: AssemblyVersion("1.0.*")]
+[assembly: AssemblyVersion("1.0.0.0")]
+[assembly: AssemblyFileVersion("1.0.0.0")]
diff --git a/TechTest/AnyCompany.Tests/AnyCompany.Tests.csproj b/TechTest/AnyCompany.Tests/AnyCompany.Tests.csproj
index b537fc2..2b53817 100644
--- a/TechTest/AnyCompany.Tests/AnyCompany.Tests.csproj
+++ b/TechTest/AnyCompany.Tests/AnyCompany.Tests.csproj
@@ -1,16 +1,25 @@
-
-
-
+
+
+
Debug
AnyCPU
- cd5d577e-bdc9-4dfc-ac6a-b1da474995f3
+ {F28E9C99-352F-4A74-8156-7D20B86852EA}
Library
Properties
AnyCompany.Tests
AnyCompany.Tests
v4.6.1
512
+ {3AC096D0-A1C2-E12C-1390-A8335801FDAB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}
+ 10.0
+ $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)
+ $(ProgramFiles)\Common Files\microsoft shared\VSTT\$(VisualStudioVersion)\UITestExtensionPackages
+ False
+ UnitTest
+
+
+
true
@@ -30,24 +39,73 @@
4
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+ ..\packages\MSTest.TestFramework.1.3.2\lib\net45\Microsoft.VisualStudio.TestPlatform.TestFramework.dll
+
+
+ ..\packages\MSTest.TestFramework.1.3.2\lib\net45\Microsoft.VisualStudio.TestPlatform.TestFramework.Extensions.dll
+
+
+
+
+
+
+
+
+
+
-
+
+
+
+
+
+
+
+ {acf38111-c769-4bea-b9b8-ab3b71a14731}
+ AnyCompany.Models
+
+
+ {c7e15594-7d8f-4c18-9dd7-14f3fbb1572d}
+ AnyCompany.Business
+
+
+
+
+
+
+ False
+
+
+ False
+
+
+ False
+
+
+ False
+
+
+
+
+
-
+
+
+ This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/TechTest/AnyCompany.Tests/App.config b/TechTest/AnyCompany.Tests/App.config
new file mode 100644
index 0000000..58a697e
--- /dev/null
+++ b/TechTest/AnyCompany.Tests/App.config
@@ -0,0 +1,7 @@
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/TechTest/AnyCompany.Tests/Class1.cs b/TechTest/AnyCompany.Tests/Class1.cs
deleted file mode 100644
index 5957505..0000000
--- a/TechTest/AnyCompany.Tests/Class1.cs
+++ /dev/null
@@ -1,12 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-
-namespace AnyCompany.Tests
-{
- public class Class1
- {
- }
-}
diff --git a/TechTest/AnyCompany.Tests/OrderServiceTests.cs b/TechTest/AnyCompany.Tests/OrderServiceTests.cs
new file mode 100644
index 0000000..12bc58f
--- /dev/null
+++ b/TechTest/AnyCompany.Tests/OrderServiceTests.cs
@@ -0,0 +1,49 @@
+using Microsoft.VisualStudio.TestTools.UnitTesting;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using AnyCompany.Models;
+
+namespace AnyCompany.Business.Tests
+{
+ [TestClass()]
+ public class OrderServiceTests
+ {
+ [TestMethod()]
+ public void OrderServiceTest()
+ {
+ OrderService service = new OrderService();
+
+ var testCustomer = service.RetrieveCustomerOrders().Where(c => c.Orders == null || c.Orders.Count == 0).FirstOrDefault();
+
+ if (testCustomer == null)
+ {
+ testCustomer = service.NewCustomer(new Customer()
+ {
+ Name = "Test Customer",
+ DateOfBirth = DateTime.Now.AddYears(-21),
+ Country = "UK"
+ });
+ }
+
+ for (int i = 1; i <= 5; i++)
+ {
+ Order order = new Order()
+ {
+ CustomerId = testCustomer.CustomerId,
+ Amount = 100 + i
+ };
+
+ service.PlaceOrder(order);
+ }
+
+ var result = service.RetrieveCustomerOrders();
+
+ int orderCount = result.Where(c => c.CustomerId == testCustomer.CustomerId).FirstOrDefault()?.Orders?.Count() ?? 0;
+
+ Assert.AreEqual(orderCount, 5);
+ }
+ }
+}
\ No newline at end of file
diff --git a/TechTest/AnyCompany.Tests/Properties/AssemblyInfo.cs b/TechTest/AnyCompany.Tests/Properties/AssemblyInfo.cs
index 726eefa..0b1f673 100644
--- a/TechTest/AnyCompany.Tests/Properties/AssemblyInfo.cs
+++ b/TechTest/AnyCompany.Tests/Properties/AssemblyInfo.cs
@@ -2,34 +2,34 @@
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
-// General Information about an assembly is controlled through the following
+// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
-[assembly: AssemblyTitle("AnyCompany.Tests")]
+[assembly: AssemblyTitle("AnyCompany.Tests1")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
-[assembly: AssemblyCompany("Investec Bank")]
-[assembly: AssemblyProduct("AnyCompany.Tests")]
-[assembly: AssemblyCopyright("Copyright © Investec Bank 2018")]
+[assembly: AssemblyCompany("")]
+[assembly: AssemblyProduct("AnyCompany.Tests1")]
+[assembly: AssemblyCopyright("Copyright © 2020")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
-// Setting ComVisible to false makes the types in this assembly not visible
-// to COM components. If you need to access a type in this assembly from
+// Setting ComVisible to false makes the types in this assembly not visible
+// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]
// The following GUID is for the ID of the typelib if this project is exposed to COM
-[assembly: Guid("cd5d577e-bdc9-4dfc-ac6a-b1da474995f3")]
+[assembly: Guid("f28e9c99-352f-4a74-8156-7d20b86852ea")]
// Version information for an assembly consists of the following four values:
//
// Major Version
-// Minor Version
+// Minor Version
// Build Number
// Revision
//
-// You can specify all the values or you can default the Build and Revision Numbers
+// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
diff --git a/TechTest/AnyCompany.Tests/packages.config b/TechTest/AnyCompany.Tests/packages.config
new file mode 100644
index 0000000..102a45c
--- /dev/null
+++ b/TechTest/AnyCompany.Tests/packages.config
@@ -0,0 +1,5 @@
+
+
+
+
+
\ No newline at end of file
diff --git a/TechTest/AnyCompany/AnyCompany.Business.csproj b/TechTest/AnyCompany/AnyCompany.Business.csproj
new file mode 100644
index 0000000..6cdd882
--- /dev/null
+++ b/TechTest/AnyCompany/AnyCompany.Business.csproj
@@ -0,0 +1,57 @@
+
+
+
+
+ Debug
+ AnyCPU
+ {C7E15594-7D8F-4C18-9DD7-14F3FBB1572D}
+ Library
+ Properties
+ AnyCompany.Business
+ AnyCompany.Business
+ v4.6.1
+ 512
+
+
+ true
+ full
+ false
+ bin\Debug\
+ DEBUG;TRACE
+ prompt
+ 4
+
+
+ pdbonly
+ true
+ bin\Release\
+ TRACE
+ prompt
+ 4
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ {acf38111-c769-4bea-b9b8-ab3b71a14731}
+ AnyCompany.Models
+
+
+ {4c883089-3973-43fd-b6b0-337968cbd1ee}
+ AnyCompany.Repository
+
+
+
+
\ No newline at end of file
diff --git a/TechTest/AnyCompany/CustomerRepository.cs b/TechTest/AnyCompany/CustomerRepository.cs
deleted file mode 100644
index e3de9b7..0000000
--- a/TechTest/AnyCompany/CustomerRepository.cs
+++ /dev/null
@@ -1,33 +0,0 @@
-using System;
-using System.Data.SqlClient;
-
-namespace AnyCompany
-{
- public static class CustomerRepository
- {
- private static string ConnectionString = @"Data Source=(local);Database=Customers;User Id=admin;Password=password;";
-
- public static Customer Load(int customerId)
- {
- Customer customer = new Customer();
-
- SqlConnection connection = new SqlConnection(ConnectionString);
- connection.Open();
-
- SqlCommand command = new SqlCommand("SELECT * FROM Customer WHERE CustomerId = " + customerId,
- connection);
- var reader = command.ExecuteReader();
-
- while (reader.Read())
- {
- customer.Name = reader["Name"].ToString();
- customer.DateOfBirth = DateTime.Parse(reader["DateOfBirth"].ToString());
- customer.Country = reader["Country"].ToString();
- }
-
- connection.Close();
-
- return customer;
- }
- }
-}
diff --git a/TechTest/AnyCompany/OrderRepository.cs b/TechTest/AnyCompany/OrderRepository.cs
deleted file mode 100644
index 3229885..0000000
--- a/TechTest/AnyCompany/OrderRepository.cs
+++ /dev/null
@@ -1,25 +0,0 @@
-using System.Data.SqlClient;
-
-namespace AnyCompany
-{
- internal class OrderRepository
- {
- private static string ConnectionString = @"Data Source=(local);Database=Orders;User Id=admin;Password=password;";
-
- public void Save(Order order)
- {
- SqlConnection connection = new SqlConnection(ConnectionString);
- connection.Open();
-
- SqlCommand command = new SqlCommand("INSERT INTO Orders VALUES (@OrderId, @Amount, @VAT)", connection);
-
- command.Parameters.AddWithValue("@OrderId", order.OrderId);
- command.Parameters.AddWithValue("@Amount", order.Amount);
- command.Parameters.AddWithValue("@VAT", order.VAT);
-
- command.ExecuteNonQuery();
-
- connection.Close();
- }
- }
-}
diff --git a/TechTest/AnyCompany/OrderService.cs b/TechTest/AnyCompany/OrderService.cs
index ebfb103..f8c030b 100644
--- a/TechTest/AnyCompany/OrderService.cs
+++ b/TechTest/AnyCompany/OrderService.cs
@@ -1,24 +1,82 @@
-namespace AnyCompany
+using AnyCompany.Models;
+using AnyCompany.Repository;
+using System;
+using System.Collections.Generic;
+
+namespace AnyCompany
{
public class OrderService
{
- private readonly OrderRepository orderRepository = new OrderRepository();
-
- public bool PlaceOrder(Order order, int customerId)
+ public bool PlaceOrder(Order order)
{
- Customer customer = CustomerRepository.Load(customerId);
+ try
+ {
+ Customer customer = CustomerRepository.Load(order.CustomerId);
+
+ if (customer != null)
+ {
+ order.CustomerId = customer.CustomerId;
+
+ if (order.Amount == 0)
+ return false;
+
+ if (customer.Country == "UK")
+ order.VAT = 0.2d;
+ else
+ order.VAT = 0;
+
+ order = OrderRepository.Save(order);
- if (order.Amount == 0)
+ return order?.OrderId > 0;
+ }
+ else
+ {
+ //To-do: Implement proper error logging
+ Console.WriteLine("Error : Customer doesn't exist");
+ return false;
+ }
+ }
+ catch (Exception ex)
+ {
+ //To-do: Implement proper error logging
+ Console.WriteLine("Error : " + ex.Message);
return false;
+ }
+ }
- if (customer.Country == "UK")
- order.VAT = 0.2d;
- else
- order.VAT = 0;
+ public List RetrieveCustomerOrders()
+ {
+ try
+ {
+ List customers = CustomerRepository.LoadCollection();
- orderRepository.Save(order);
+ foreach (var customer in customers)
+ {
+ customer.Orders = OrderRepository.LoadCollection(customer.CustomerId);
+ }
- return true;
+ return customers;
+ }
+ catch (Exception ex)
+ {
+ //To-do: Implement proper error logging
+ Console.WriteLine("Error : " + ex.Message);
+ return new List();
+ }
+ }
+
+ public Customer NewCustomer(Customer customer)
+ {
+ try
+ {
+ return CustomerRepository.Save(customer);
+ }
+ catch (Exception ex)
+ {
+ //To-do: Implement proper error logging
+ Console.WriteLine("Error : " + ex.Message);
+ return customer;
+ }
}
}
}
diff --git a/TechTest/TechTest.sln b/TechTest/TechTest.sln
index 1c1c57a..343b1bb 100644
--- a/TechTest/TechTest.sln
+++ b/TechTest/TechTest.sln
@@ -1,17 +1,21 @@
Microsoft Visual Studio Solution File, Format Version 12.00
-# Visual Studio 15
-VisualStudioVersion = 15.0.27004.2005
+# Visual Studio Version 16
+VisualStudioVersion = 16.0.29006.145
MinimumVisualStudioVersion = 10.0.40219.1
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AnyCompany", "AnyCompany\AnyCompany.csproj", "{C7E15594-7D8F-4C18-9DD7-14F3FBB1572D}"
-EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AnyCompany.Tests", "AnyCompany.Tests\AnyCompany.Tests.csproj", "{CD5D577E-BDC9-4DFC-AC6A-B1DA474995F3}"
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AnyCompany.Business", "AnyCompany\AnyCompany.Business.csproj", "{C7E15594-7D8F-4C18-9DD7-14F3FBB1572D}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{B6D3C1BB-2A37-4E17-9EE3-DEF28286E782}"
ProjectSection(SolutionItems) = preProject
Instructions.txt = Instructions.txt
EndProjectSection
EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AnyCompany.Repository", "AnyCompany.Repository\AnyCompany.Repository.csproj", "{4C883089-3973-43FD-B6B0-337968CBD1EE}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AnyCompany.Models", "AnyCompany.Models\AnyCompany.Models.csproj", "{ACF38111-C769-4BEA-B9B8-AB3B71A14731}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AnyCompany.Tests", "AnyCompany.Tests1\AnyCompany.Tests.csproj", "{F28E9C99-352F-4A74-8156-7D20B86852EA}"
+EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@@ -22,10 +26,18 @@ Global
{C7E15594-7D8F-4C18-9DD7-14F3FBB1572D}.Debug|Any CPU.Build.0 = Debug|Any CPU
{C7E15594-7D8F-4C18-9DD7-14F3FBB1572D}.Release|Any CPU.ActiveCfg = Release|Any CPU
{C7E15594-7D8F-4C18-9DD7-14F3FBB1572D}.Release|Any CPU.Build.0 = Release|Any CPU
- {CD5D577E-BDC9-4DFC-AC6A-B1DA474995F3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {CD5D577E-BDC9-4DFC-AC6A-B1DA474995F3}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {CD5D577E-BDC9-4DFC-AC6A-B1DA474995F3}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {CD5D577E-BDC9-4DFC-AC6A-B1DA474995F3}.Release|Any CPU.Build.0 = Release|Any CPU
+ {4C883089-3973-43FD-B6B0-337968CBD1EE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {4C883089-3973-43FD-B6B0-337968CBD1EE}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {4C883089-3973-43FD-B6B0-337968CBD1EE}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {4C883089-3973-43FD-B6B0-337968CBD1EE}.Release|Any CPU.Build.0 = Release|Any CPU
+ {ACF38111-C769-4BEA-B9B8-AB3B71A14731}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {ACF38111-C769-4BEA-B9B8-AB3B71A14731}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {ACF38111-C769-4BEA-B9B8-AB3B71A14731}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {ACF38111-C769-4BEA-B9B8-AB3B71A14731}.Release|Any CPU.Build.0 = Release|Any CPU
+ {F28E9C99-352F-4A74-8156-7D20B86852EA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {F28E9C99-352F-4A74-8156-7D20B86852EA}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {F28E9C99-352F-4A74-8156-7D20B86852EA}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {F28E9C99-352F-4A74-8156-7D20B86852EA}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE