Skip to content

Commit

Permalink
added new newtonsoft package, finished GetCustomer api
Browse files Browse the repository at this point in the history
  • Loading branch information
Jeremy Mill committed Nov 12, 2015
1 parent 61ceaef commit bfd6223
Show file tree
Hide file tree
Showing 7 changed files with 25 additions and 9 deletions.
Binary file modified API_REF.xlsx
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
using System.Web.Http;
using TeamDBAwesome.Models;
using TeamDBAwesome.SqlService;
using Newtonsoft.Json;

namespace TeamDBAwesome.Controllers
{
Expand All @@ -19,8 +20,10 @@ public HttpResponseMessage Get(int PersonID)
MySqlService sql = new MySqlService();

Customer customer = sql.GetCustomer(PersonID);

//next I need to JSON stringify customer and return it in the message

string serialzed = JsonConvert.SerializeObject(customer);

message.Content = new StringContent(serialzed);

return message;
}
Expand Down
3 changes: 2 additions & 1 deletion TeamDBAwesome/TeamDBAwesome/Models/Customer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@ public class Customer
public string Country { get; set; }

//match a 10-15 digit long number
[RegularExpression(@"^(\d{10,15})$")]
//had to remove this because of already existing data in the DB
//[RegularExpression(@"^(\d{10,15})$")]
public string Phone { get; set; }

//match a 10-15 digit long number
Expand Down
13 changes: 12 additions & 1 deletion TeamDBAwesome/TeamDBAwesome/SqlService/MySqlService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,18 @@ public Customer GetCustomer(int PersonID)
{
customer.FName = GetDBString("FirstName", reader);
customer.LName = GetDBString("LastName", reader);
customer.CustomerID = int.Parse(GetDBString("CutomerID", reader));
customer.CustomerID = int.Parse(GetDBString("CustomerID", reader));
customer.Address = GetDBString("Address", reader);
customer.City = GetDBString("City", reader);
customer.State = GetDBString("State", reader);
customer.Post = GetDBString("PostalCode", reader);
customer.Country = GetDBString("Country", reader);
customer.Phone = GetDBString("Phone", reader);
customer.Fax = GetDBString("Fax", reader);
customer.Email = GetDBString("Email", reader);
customer.Company = GetDBString("Company", reader);
customer.SupportRepId = int.Parse(GetDBString("SupportRepId", reader));
customer.PersonID = int.Parse(GetDBString("PersonID", reader));
}


Expand Down
7 changes: 4 additions & 3 deletions TeamDBAwesome/TeamDBAwesome/TeamDBAwesome.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,10 @@
<HintPath>..\packages\MySql.Data.6.9.8\lib\net45\MySql.Data.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Newtonsoft.Json, Version=7.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<HintPath>..\packages\Newtonsoft.Json.7.0.1\lib\net45\Newtonsoft.Json.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="System" />
<Reference Include="System.Data" />
<Reference Include="System.Drawing" />
Expand All @@ -73,9 +77,6 @@
<Private>True</Private>
<HintPath>..\packages\Microsoft.Web.Infrastructure.1.0.0.0\lib\net40\Microsoft.Web.Infrastructure.dll</HintPath>
</Reference>
<Reference Include="Newtonsoft.Json">
<HintPath>..\packages\Newtonsoft.Json.6.0.4\lib\net45\Newtonsoft.Json.dll</HintPath>
</Reference>
<Reference Include="System.Net.Http">
</Reference>
<Reference Include="System.Net.Http.Formatting, Version=5.2.3.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
Expand Down
2 changes: 1 addition & 1 deletion TeamDBAwesome/TeamDBAwesome/Web.config
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="Newtonsoft.Json" culture="neutral" publicKeyToken="30ad4fe6b2a6aeed" />
<bindingRedirect oldVersion="0.0.0.0-6.0.0.0" newVersion="6.0.0.0" />
<bindingRedirect oldVersion="0.0.0.0-7.0.0.0" newVersion="7.0.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Web.Optimization" publicKeyToken="31bf3856ad364e35" />
Expand Down
2 changes: 1 addition & 1 deletion TeamDBAwesome/TeamDBAwesome/packages.config
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
<package id="Microsoft.Web.Infrastructure" version="1.0.0.0" targetFramework="net452" />
<package id="Modernizr" version="2.6.2" targetFramework="net452" />
<package id="MySql.Data" version="6.9.8" targetFramework="net452" />
<package id="Newtonsoft.Json" version="6.0.4" targetFramework="net452" />
<package id="Newtonsoft.Json" version="7.0.1" targetFramework="net452" />
<package id="Respond" version="1.2.0" targetFramework="net452" />
<package id="WebGrease" version="1.5.2" targetFramework="net452" />
</packages>

0 comments on commit bfd6223

Please sign in to comment.