diff --git a/Application_output.png b/Application_output.png new file mode 100644 index 0000000..6ab90d8 Binary files /dev/null and b/Application_output.png differ diff --git a/Table Scripts/tables.sql b/Table Scripts/tables.sql new file mode 100644 index 0000000..8f05c53 Binary files /dev/null and b/Table Scripts/tables.sql differ diff --git a/TechTest/AnyCompany.Web/AnyCompany.Web.csproj b/TechTest/AnyCompany.Web/AnyCompany.Web.csproj new file mode 100644 index 0000000..1db166a --- /dev/null +++ b/TechTest/AnyCompany.Web/AnyCompany.Web.csproj @@ -0,0 +1,144 @@ + + + + + Debug + AnyCPU + + + 2.0 + {FD7825D0-FDC4-4099-A796-97FCC8724012} + {349c5851-65df-11da-9384-00065b846f21};{fae04ec0-301f-11d3-bf4b-00c04f79efbc} + Library + Properties + AnyCompany.Web + AnyCompany.Web + v4.6.1 + true + + + + + + + + + + + true + full + false + bin\ + DEBUG;TRACE + prompt + 4 + + + true + pdbonly + true + bin\ + TRACE + prompt + 4 + + + + + + + + + + + + + + + + + + + + + + + ..\packages\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.2.0.0\lib\net45\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.dll + + + + + + + + + + Default.aspx + ASPXCodeBehind + + + Default.aspx + + + Global.asax + + + + + + + Web.config + + + Web.config + + + + + + + + + {c7e15594-7d8f-4c18-9dd7-14f3fbb1572d} + AnyCompany + + + + 10.0 + $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) + + + + + + + + + True + True + 49987 + / + http://localhost:49980/ + 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.Web/Default.aspx b/TechTest/AnyCompany.Web/Default.aspx new file mode 100644 index 0000000..1dade3e --- /dev/null +++ b/TechTest/AnyCompany.Web/Default.aspx @@ -0,0 +1,154 @@ +<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="AnyCompany.Web.Default" %> + + + + + + + + + + + + + +
+
+
+
+
Place an order
+ +
+ + + + + + + + + + + + + + + + + + + + + +
Customer: + + + + +
Order Id: + +
Order Amount: + +
+ + +
+
  + +    +
+
+ + +
Customer Order List
+
+ + + + + <%--Text='<%# Container.DataItemIndex + 1 %>'--%> + <%----%> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + +
+
+
+ + diff --git a/TechTest/AnyCompany.Web/Default.aspx.cs b/TechTest/AnyCompany.Web/Default.aspx.cs new file mode 100644 index 0000000..4cf8de5 --- /dev/null +++ b/TechTest/AnyCompany.Web/Default.aspx.cs @@ -0,0 +1,73 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Web; +using System.Web.UI; +using AnyCompany; + +namespace AnyCompany.Web +{ + public partial class Default : System.Web.UI.Page + { + protected void Page_Load(object sender, EventArgs e) + { + if (!IsPostBack) + { + Random r = new Random(); + lblorderid.Text = r.Next(100, 9999).ToString(); + } + + } + + protected void btnsubmit_Click(object sender, EventArgs e) + { + if (Page.IsValid) + { + try + { + + + Order objorder = new Order(); + objorder.CustomerId = Convert.ToInt32(ddlcustomer.SelectedValue); + + objorder.OrderId = Convert.ToInt32(lblorderid.Text); + objorder.Amount = Convert.ToDouble(txtorderamt.Text); + //objorder.VAT = Convert.ToDouble(txtVat.Text); + + OrderService obj = new OrderService(); + obj.PlaceOrder(objorder, Convert.ToInt32(ddlcustomer.SelectedValue)); + string message = "Order Placed Successfully."; + System.Text.StringBuilder sb = new System.Text.StringBuilder(); + sb.Append(""); + ClientScript.RegisterClientScriptBlock(this.GetType(), "alert", sb.ToString()); + Reset(); + GridView1.DataBind(); + } + catch + { + + + } + + } + + } + private void Reset() + { + Random r = new Random(); + lblorderid.Text = r.Next(100, 9999).ToString(); + txtorderamt.Text = ""; + ddlcustomer.SelectedValue="0"; + } + + protected void btnReset_Click(object sender, EventArgs e) + { + Reset(); + } + } +} \ No newline at end of file diff --git a/TechTest/AnyCompany.Web/Default.aspx.designer.cs b/TechTest/AnyCompany.Web/Default.aspx.designer.cs new file mode 100644 index 0000000..6635ff2 --- /dev/null +++ b/TechTest/AnyCompany.Web/Default.aspx.designer.cs @@ -0,0 +1,123 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace AnyCompany.Web { + + + public partial class Default { + + /// + /// form1 control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::System.Web.UI.HtmlControls.HtmlForm form1; + + /// + /// ddlcustomer control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::System.Web.UI.WebControls.DropDownList ddlcustomer; + + /// + /// reqFavoriteColor control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::System.Web.UI.WebControls.RequiredFieldValidator reqFavoriteColor; + + /// + /// SqlDataSource2 control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::System.Web.UI.WebControls.SqlDataSource SqlDataSource2; + + /// + /// lblorderid control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::System.Web.UI.WebControls.Label lblorderid; + + /// + /// txtorderamt control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::System.Web.UI.WebControls.TextBox txtorderamt; + + /// + /// RFVtxtorderamt control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::System.Web.UI.WebControls.RequiredFieldValidator RFVtxtorderamt; + + /// + /// RegularExpressionValidator6 control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::System.Web.UI.WebControls.RegularExpressionValidator RegularExpressionValidator6; + + /// + /// btnsubmit control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::System.Web.UI.WebControls.Button btnsubmit; + + /// + /// btnReset control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::System.Web.UI.WebControls.Button btnReset; + + /// + /// GridView1 control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::System.Web.UI.WebControls.GridView GridView1; + + /// + /// SqlDataSource1 control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::System.Web.UI.WebControls.SqlDataSource SqlDataSource1; + } +} diff --git a/TechTest/AnyCompany.Web/Global.asax b/TechTest/AnyCompany.Web/Global.asax new file mode 100644 index 0000000..0da54c1 --- /dev/null +++ b/TechTest/AnyCompany.Web/Global.asax @@ -0,0 +1 @@ +<%@ Application Codebehind="Global.asax.cs" Inherits="AnyCompany.Web.Global" Language="C#" %> diff --git a/TechTest/AnyCompany.Web/Global.asax.cs b/TechTest/AnyCompany.Web/Global.asax.cs new file mode 100644 index 0000000..2f36a10 --- /dev/null +++ b/TechTest/AnyCompany.Web/Global.asax.cs @@ -0,0 +1,16 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Web; +using System.Web.Security; +using System.Web.SessionState; + +namespace AnyCompany.Web +{ + public class Global : System.Web.HttpApplication + { + protected void Application_Start(object sender, EventArgs e) + { + } + } +} \ No newline at end of file diff --git a/TechTest/AnyCompany.Web/Properties/AssemblyInfo.cs b/TechTest/AnyCompany.Web/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..9e386f8 --- /dev/null +++ b/TechTest/AnyCompany.Web/Properties/AssemblyInfo.cs @@ -0,0 +1,35 @@ +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.Web")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("AnyCompany.Web")] +[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("fd7825d0-fdc4-4099-a796-97fcc8724012")] + +// 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 Revision and Build Numbers +// by using the '*' as shown below: +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/TechTest/AnyCompany.Web/Web.Debug.config b/TechTest/AnyCompany.Web/Web.Debug.config new file mode 100644 index 0000000..fae9cfe --- /dev/null +++ b/TechTest/AnyCompany.Web/Web.Debug.config @@ -0,0 +1,30 @@ + + + + + + + + + + \ No newline at end of file diff --git a/TechTest/AnyCompany.Web/Web.Release.config b/TechTest/AnyCompany.Web/Web.Release.config new file mode 100644 index 0000000..da6e960 --- /dev/null +++ b/TechTest/AnyCompany.Web/Web.Release.config @@ -0,0 +1,31 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/TechTest/AnyCompany.Web/Web.config b/TechTest/AnyCompany.Web/Web.config new file mode 100644 index 0000000..1bad954 --- /dev/null +++ b/TechTest/AnyCompany.Web/Web.config @@ -0,0 +1,31 @@ + + + + + + + + + + + + + + + + + + + + + + + diff --git a/TechTest/AnyCompany.Web/packages.config b/TechTest/AnyCompany.Web/packages.config new file mode 100644 index 0000000..aa30a70 --- /dev/null +++ b/TechTest/AnyCompany.Web/packages.config @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/TechTest/AnyCompany/AnyCompany.csproj b/TechTest/AnyCompany/AnyCompany.csproj index 5b0498d..b6edc44 100644 --- a/TechTest/AnyCompany/AnyCompany.csproj +++ b/TechTest/AnyCompany/AnyCompany.csproj @@ -31,6 +31,7 @@ + @@ -47,5 +48,13 @@ + + + Designer + + + + + \ No newline at end of file diff --git a/TechTest/AnyCompany/App.config b/TechTest/AnyCompany/App.config new file mode 100644 index 0000000..c7814e3 --- /dev/null +++ b/TechTest/AnyCompany/App.config @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/TechTest/AnyCompany/CustomerRepository.cs b/TechTest/AnyCompany/CustomerRepository.cs index e3de9b7..ffc5acc 100644 --- a/TechTest/AnyCompany/CustomerRepository.cs +++ b/TechTest/AnyCompany/CustomerRepository.cs @@ -5,7 +5,7 @@ namespace AnyCompany { public static class CustomerRepository { - private static string ConnectionString = @"Data Source=(local);Database=Customers;User Id=admin;Password=password;"; + private static string ConnectionString = @"Data Source=DESKTOP-21TVJEC;Initial Catalog=AnyCompany;Integrated Security=True;Persist Security Info=False;Enlist=False;Pooling=True;Min Pool Size=1;Max Pool Size=100;Connect Timeout=15;User Instance=False";//ConfigurationSettings.AppSettings["AnyCompany"].ToString();//@"Data Source=(local);Database=Customers;User Id=admin;Password=password;"; public static Customer Load(int customerId) { @@ -29,5 +29,6 @@ public static Customer Load(int customerId) return customer; } + } } diff --git a/TechTest/AnyCompany/Order.cs b/TechTest/AnyCompany/Order.cs index fec8e7b..32d68e1 100644 --- a/TechTest/AnyCompany/Order.cs +++ b/TechTest/AnyCompany/Order.cs @@ -3,6 +3,7 @@ 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/OrderRepository.cs b/TechTest/AnyCompany/OrderRepository.cs index 3229885..674baf9 100644 --- a/TechTest/AnyCompany/OrderRepository.cs +++ b/TechTest/AnyCompany/OrderRepository.cs @@ -2,20 +2,21 @@ namespace AnyCompany { - internal class OrderRepository + public class OrderRepository { - private static string ConnectionString = @"Data Source=(local);Database=Orders;User Id=admin;Password=password;"; + private static string ConnectionString = @"Data Source=DESKTOP-21TVJEC;Initial Catalog=AnyCompany;Integrated Security=True;Persist Security Info=False;Enlist=False;Pooling=True;Min Pool Size=1;Max Pool Size=100;Connect Timeout=15;User Instance=False";//ConfigurationSettings.AppSettings["AnyCompany"].ToString();// @"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); + SqlCommand command = new SqlCommand("INSERT INTO Orders VALUES (@OrderId, @Amount, @VAT,@CustomerId)", connection); command.Parameters.AddWithValue("@OrderId", order.OrderId); command.Parameters.AddWithValue("@Amount", order.Amount); command.Parameters.AddWithValue("@VAT", order.VAT); + command.Parameters.AddWithValue("@CustomerId", order.CustomerId); command.ExecuteNonQuery(); diff --git a/TechTest/AnyCompany/OrderService.cs b/TechTest/AnyCompany/OrderService.cs index ebfb103..b274942 100644 --- a/TechTest/AnyCompany/OrderService.cs +++ b/TechTest/AnyCompany/OrderService.cs @@ -2,7 +2,7 @@ { public class OrderService { - private readonly OrderRepository orderRepository = new OrderRepository(); + private readonly OrderRepository orderRepository1=new OrderRepository(); public bool PlaceOrder(Order order, int customerId) { @@ -16,7 +16,7 @@ public bool PlaceOrder(Order order, int customerId) else order.VAT = 0; - orderRepository.Save(order); + orderRepository1.Save(order); return true; } diff --git a/TechTest/TechTest.sln b/TechTest/TechTest.sln index 1c1c57a..167e592 100644 --- a/TechTest/TechTest.sln +++ b/TechTest/TechTest.sln @@ -12,6 +12,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Instructions.txt = Instructions.txt EndProjectSection EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AnyCompany.Web", "AnyCompany.Web\AnyCompany.Web.csproj", "{FD7825D0-FDC4-4099-A796-97FCC8724012}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -26,6 +28,10 @@ Global {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 + {FD7825D0-FDC4-4099-A796-97FCC8724012}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {FD7825D0-FDC4-4099-A796-97FCC8724012}.Debug|Any CPU.Build.0 = Debug|Any CPU + {FD7825D0-FDC4-4099-A796-97FCC8724012}.Release|Any CPU.ActiveCfg = Release|Any CPU + {FD7825D0-FDC4-4099-A796-97FCC8724012}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/azure-pipelines.yml b/azure-pipelines.yml new file mode 100644 index 0000000..6d41783 --- /dev/null +++ b/azure-pipelines.yml @@ -0,0 +1,34 @@ +# ASP.NET +# Build and test ASP.NET projects. +# Add steps that publish symbols, save build artifacts, deploy, and more: +# https://docs.microsoft.com/azure/devops/pipelines/apps/aspnet/build-aspnet-4 + +trigger: +- master + +pool: + vmImage: 'windows-latest' + +variables: + solution: '**/*.sln' + buildPlatform: 'Any CPU' + buildConfiguration: 'Release' + +steps: +- task: NuGetToolInstaller@1 + +- task: NuGetCommand@2 + inputs: + restoreSolution: '$(solution)' + +- task: VSBuild@1 + inputs: + solution: '$(solution)' + msbuildArgs: '/p:DeployOnBuild=true /p:WebPublishMethod=Package /p:PackageAsSingleFile=true /p:SkipInvalidConfigurations=true /p:PackageLocation="$(build.artifactStagingDirectory)"' + platform: '$(buildPlatform)' + configuration: '$(buildConfiguration)' + +- task: VSTest@2 + inputs: + platform: '$(buildPlatform)' + configuration: '$(buildConfiguration)'