aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/Web/Tango.MachineService/Controllers
diff options
context:
space:
mode:
Diffstat (limited to 'Software/Visual_Studio/Web/Tango.MachineService/Controllers')
-rw-r--r--Software/Visual_Studio/Web/Tango.MachineService/Controllers/SynchronizationController.cs30
1 files changed, 27 insertions, 3 deletions
diff --git a/Software/Visual_Studio/Web/Tango.MachineService/Controllers/SynchronizationController.cs b/Software/Visual_Studio/Web/Tango.MachineService/Controllers/SynchronizationController.cs
index 06c1a4a23..51cf6f96b 100644
--- a/Software/Visual_Studio/Web/Tango.MachineService/Controllers/SynchronizationController.cs
+++ b/Software/Visual_Studio/Web/Tango.MachineService/Controllers/SynchronizationController.cs
@@ -1,4 +1,5 @@
using Google.Protobuf;
+using Newtonsoft.Json.Linq;
using System;
using System.Collections.Generic;
using System.Configuration;
@@ -10,10 +11,13 @@ using System.Threading.Tasks;
using System.Web.Hosting;
using System.Web.Http;
using Tango.BL;
+using Tango.BL.Builders;
+using Tango.BL.Entities;
using Tango.Core.DB;
using Tango.Core.Helpers;
using Tango.Core.IO;
using Tango.Logging;
+using Tango.MachineService.Models;
using Tango.PMR.Stubs;
using Tango.PMR.Synchronization;
using Tango.Synchronization.Local;
@@ -86,13 +90,14 @@ namespace Tango.MachineService.Controllers
String serial_number = request.SerialNumber;
var machine = db.Machines.SingleOrDefault(x => x.SerialNumber == serial_number);
- var machine_version = db.MachineVersions.SingleOrDefault(x => x.Guid == machine.MachineVersionGuid);
if (machine == null)
{
- OnError(HttpStatusCode.NotFound, "The specified serial number could not be found.");
+ ThrowError(HttpStatusCode.NotFound, "The specified serial number could not be found.");
}
+ var machine_version = db.MachineVersions.SingleOrDefault(x => x.Guid == machine.MachineVersionGuid);
+
var latest_machine_version = db.TangoVersions.Where(x => x.MachineVersionGuid == machine_version.Guid).ToList().OrderByDescending(x => Version.Parse(x.Version)).FirstOrDefault();
response.Version = latest_machine_version.Version;
@@ -125,7 +130,7 @@ namespace Tango.MachineService.Controllers
catch (Exception ex)
{
logManager.Log(ex);
- OnError(HttpStatusCode.InternalServerError, ex.Message);
+ throw;
}
return response;
@@ -274,8 +279,27 @@ namespace Tango.MachineService.Controllers
return response;
}
+ [HttpPost]
+ public Machine PersonTest(Person p)
+ {
+ using (var db = ObservablesContext.CreateDefault(GetLocalServerAddress()))
+ {
+ var machine = new MachineBuilder(db)
+ .Set(x => x.SerialNumber == "1111")
+ .WithOrganization()
+ .WithConfiguration().Build();
+
+ return machine;
+ }
+ }
+
#region Helpers
+ private void ThrowError(HttpStatusCode code, String message)
+ {
+ throw new WebApiException(code, message);
+ }
+
private void OnError(HttpStatusCode code, String message)
{
throw new HttpResponseException(Request.CreateErrorResponse(code, message));