diff --git a/ManagerService/Controllers/ApplicationInstanceController.cs b/ManagerService/Controllers/ApplicationInstanceController.cs
index caf825e..ca652bf 100644
--- a/ManagerService/Controllers/ApplicationInstanceController.cs
+++ b/ManagerService/Controllers/ApplicationInstanceController.cs
@@ -1,7 +1,6 @@
using System;
using System.Collections.Generic;
using System.Linq;
-using Manager.Helpers;
using Manager.Services;
using ManagerService.Data;
using ManagerService.DTOs;
@@ -244,6 +243,7 @@ namespace ManagerService.Controllers
// Todo add some verification ?
AppConfigurationLink appConfigurationLink = new AppConfigurationLink().FromDTO(appConfigurationLinkDTO);
appConfigurationLink.Id = idService.GenerateHexId();
+ appConfigurationLink.Order = _myInfoMateDbContext.AppConfigurationLinks.Count(acl => acl.ApplicationInstanceId == applicationInstanceId);
_myInfoMateDbContext.AppConfigurationLinks.Add(appConfigurationLink);
_myInfoMateDbContext.SaveChanges();
@@ -304,6 +304,49 @@ namespace ManagerService.Controllers
}
}
+ ///
+ /// Update app configuration links order
+ ///
+ /// App configuration link to update
+ [ProducesResponseType(typeof(List), 200)]
+ [ProducesResponseType(typeof(string), 400)]
+ [ProducesResponseType(typeof(string), 404)]
+ [ProducesResponseType(typeof(string), 500)]
+ [HttpPut("application-link/order")]
+ public ObjectResult UpdateApplicationLinkOrder([FromBody] List appConfigurationLinkDTOs)
+ {
+ try
+ {
+ if (appConfigurationLinkDTOs == null)
+ throw new ArgumentNullException("appConfigurationLink param is null");
+
+ List appConfigurationLinks = _myInfoMateDbContext.AppConfigurationLinks.Include(acl => acl.Configuration).Include(acl => acl.Device).Where(acl => appConfigurationLinkDTOs.Select(acld => acld.id).Contains(acl.Id)).ToList();
+
+ if (appConfigurationLinks.Count != appConfigurationLinkDTOs.Count)
+ throw new KeyNotFoundException("Length does not match");
+
+ foreach (var appConfigurationLinkDTO in appConfigurationLinkDTOs) {
+ var appConf = appConfigurationLinks.FirstOrDefault(acl => acl.Id == appConfigurationLinkDTO.id);
+ appConf.Order = appConfigurationLinkDTO.order;
+ }
+ _myInfoMateDbContext.SaveChanges();
+
+ return new OkObjectResult(appConfigurationLinks.Select(acl => acl.ToDTO()));
+ }
+ catch (ArgumentNullException ex)
+ {
+ return new BadRequestObjectResult(ex.Message) { };
+ }
+ catch (KeyNotFoundException ex)
+ {
+ return new NotFoundObjectResult(ex.Message) { };
+ }
+ catch (Exception ex)
+ {
+ return new ObjectResult(ex.Message) { StatusCode = 500 };
+ }
+ }
+
///
/// Remove configuration from instance
///
diff --git a/ManagerService/Controllers/SectionController.cs b/ManagerService/Controllers/SectionController.cs
index 57da42a..f8cf49a 100644
--- a/ManagerService/Controllers/SectionController.cs
+++ b/ManagerService/Controllers/SectionController.cs
@@ -94,6 +94,40 @@ namespace ManagerService.Controllers
}
}
+ ///
+ /// Get a list of all section (summary)
+ ///
+ /// id instance
+ [ProducesResponseType(typeof(List), 200)]
+ [ProducesResponseType(typeof(string), 500)]
+ [ProducesResponseType(typeof(string), 400)]
+ [HttpGet("detail")]
+ public ObjectResult GetAllFromType([FromQuery] string instanceId, [FromQuery] SectionType sectionType)
+ {
+ try
+ {
+ if (instanceId == null)
+ throw new ArgumentNullException("Param is null");
+
+ List sections = _myInfoMateDbContext.Sections.Where(s => s.InstanceId == instanceId && s.Type == sectionType).OrderBy(s => s.Order).ToList();
+ //List sections = _sectionService.GetAllSubSection(id);
+
+ List