diff --git a/ManagerService/Controllers/ApplicationInstanceController.cs b/ManagerService/Controllers/ApplicationInstanceController.cs
index 1547310..960d245 100644
--- a/ManagerService/Controllers/ApplicationInstanceController.cs
+++ b/ManagerService/Controllers/ApplicationInstanceController.cs
@@ -76,8 +76,7 @@ namespace ManagerService.Controllers
throw new ArgumentNullException("Application instance param is null");
// Todo add some verification ?
- ApplicationInstance applicationInstance = new ApplicationInstance();
- applicationInstance.FromDTO(newApplicationInstanceDTO);
+ ApplicationInstance applicationInstance = new ApplicationInstance().FromDTO(newApplicationInstanceDTO);
applicationInstance.Id = idService.GenerateHexId();
_myInfoMateDbContext.ApplicationInstances.Add(applicationInstance);
@@ -121,7 +120,7 @@ namespace ManagerService.Controllers
if (applicationInstance == null)
throw new KeyNotFoundException("application instance does not exist");
- applicationInstance.FromDTO(updatedApplicationInstanceDTO);
+ applicationInstance = applicationInstance.FromDTO(updatedApplicationInstanceDTO);
_myInfoMateDbContext.SaveChanges();
return new OkObjectResult(applicationInstance.ToDTO());
@@ -183,6 +182,28 @@ namespace ManagerService.Controllers
}
}
+ ///
+ /// Get all application Link
+ ///
+ /// application instance id
+ [AllowAnonymous]
+ [ProducesResponseType(typeof(List), 200)]
+ [ProducesResponseType(typeof(string), 500)]
+ [HttpGet("{applicationInstanceId}/application-link")]
+ public ObjectResult GetAllApplicationLinkFromApplicationInstance([FromQuery] string applicationInstanceId)
+ {
+ try
+ {
+ List appConfigurationLinks = _myInfoMateDbContext.AppConfigurationLinks.Where(acl => acl.ApplicationInstanceId == applicationInstanceId).ToList();
+
+ return new OkObjectResult(appConfigurationLinks.Select(acl => acl.ToDTO()).OrderBy(acl => acl.order));
+ }
+ catch (Exception ex)
+ {
+ return new ObjectResult(ex.Message) { StatusCode = 500 };
+ }
+ }
+
///
/// Create a new application Link to specified application instance
///
@@ -214,9 +235,8 @@ namespace ManagerService.Controllers
throw new KeyNotFoundException("This configuration was not found");
// Todo add some verification ?
- AppConfigurationLink appConfigurationLink = new AppConfigurationLink();
+ AppConfigurationLink appConfigurationLink = new AppConfigurationLink().FromDTO(appConfigurationLinkDTO);
appConfigurationLink.Id = idService.GenerateHexId();
- appConfigurationLink.FromDTO(appConfigurationLinkDTO);
_myInfoMateDbContext.AppConfigurationLinks.Add(appConfigurationLink);
_myInfoMateDbContext.SaveChanges();
@@ -237,6 +257,46 @@ namespace ManagerService.Controllers
}
}
+ ///
+ /// Update an app configuration link
+ ///
+ /// App configuration link to update
+ [ProducesResponseType(typeof(AppConfigurationLinkDTO), 200)]
+ [ProducesResponseType(typeof(string), 400)]
+ [ProducesResponseType(typeof(string), 404)]
+ [ProducesResponseType(typeof(string), 500)]
+ [HttpPut("application-link")]
+ public ObjectResult UpdateApplicationLink([FromBody] AppConfigurationLinkDTO appConfigurationLinkDTO)
+ {
+ try
+ {
+ if (appConfigurationLinkDTO == null)
+ throw new ArgumentNullException("appConfigurationLink param is null");
+
+ AppConfigurationLink appConfigurationLink = _myInfoMateDbContext.AppConfigurationLinks.FirstOrDefault(acl => acl.Id == appConfigurationLinkDTO.id);
+
+ if (appConfigurationLink == null)
+ throw new KeyNotFoundException("appConfigurationLink does not exist");
+
+ appConfigurationLink = appConfigurationLink.FromDTO(appConfigurationLinkDTO);
+ _myInfoMateDbContext.SaveChanges();
+
+ return new OkObjectResult(appConfigurationLink.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 c810b50..57da42a 100644
--- a/ManagerService/Controllers/SectionController.cs
+++ b/ManagerService/Controllers/SectionController.cs
@@ -1094,5 +1094,25 @@ namespace ManagerService.Controllers
{
return new ObjectResult("WeatherDTO") { StatusCode = 200 };
}
+
+ ///
+ /// Useless, just to generate dto code
+ ///
+ [ProducesResponseType(typeof(SectionEventDTO), 200)]
+ [HttpGet("SectionEventDTO")]
+ public ObjectResult GetSectionEventDTO()
+ {
+ return new ObjectResult("SectionEventDTO") { StatusCode = 200 };
+ }
+
+ ///
+ /// Useless, just to generate dto code
+ ///
+ [ProducesResponseType(typeof(GuidedPathDTO), 200)]
+ [HttpGet("GuidedPathDTO")]
+ public ObjectResult GetGuidedPathDTO()
+ {
+ return new ObjectResult("GuidedPathDTO") { StatusCode = 200 };
+ }
}
}
diff --git a/ManagerService/Controllers/SectionEventController.cs b/ManagerService/Controllers/SectionEventController.cs
index 0ff7c37..041eab3 100644
--- a/ManagerService/Controllers/SectionEventController.cs
+++ b/ManagerService/Controllers/SectionEventController.cs
@@ -42,7 +42,7 @@ namespace ManagerService.Controllers
[ProducesResponseType(typeof(List), 200)]
[ProducesResponseType(typeof(string), 404)]
[ProducesResponseType(typeof(string), 500)]
- [HttpGet("{sectionId}/programmes")]
+ [HttpGet("{sectionEventId}/programmes")]
public ObjectResult GetAllProgrammeBlockFromSection(string sectionEventId)
{
try
diff --git a/ManagerService/Data/AppConfigurationLink.cs b/ManagerService/Data/AppConfigurationLink.cs
index e540dab..901b0d0 100644
--- a/ManagerService/Data/AppConfigurationLink.cs
+++ b/ManagerService/Data/AppConfigurationLink.cs
@@ -50,15 +50,12 @@ namespace ManagerService.Data
public AppConfigurationLink FromDTO(AppConfigurationLinkDTO appConfigurationLinkDTO)
{
- return new AppConfigurationLink()
- {
- Id = appConfigurationLinkDTO.id,
- ConfigurationId = appConfigurationLinkDTO.configurationId,
- ApplicationInstanceId = appConfigurationLinkDTO.applicationInstanceId,
- Order = appConfigurationLinkDTO.order,
- IsActive = appConfigurationLinkDTO.isActive,
- WeightMasonryGrid = appConfigurationLinkDTO?.weightMasonryGrid,
- };
+ ConfigurationId = appConfigurationLinkDTO.configurationId;
+ ApplicationInstanceId = appConfigurationLinkDTO.applicationInstanceId;
+ Order = appConfigurationLinkDTO.order;
+ IsActive = appConfigurationLinkDTO.isActive;
+ WeightMasonryGrid = appConfigurationLinkDTO?.weightMasonryGrid;
+ return this;
}
}
diff --git a/ManagerService/Data/ApplicationInstance.cs b/ManagerService/Data/ApplicationInstance.cs
index fc382d5..6fedda4 100644
--- a/ManagerService/Data/ApplicationInstance.cs
+++ b/ManagerService/Data/ApplicationInstance.cs
@@ -77,27 +77,25 @@ namespace ManagerService.Data
};
}
- public ApplicationInstance FromDTO(ApplicationInstanceDTO applicationInstanceDTO)
+ public ApplicationInstance FromDTO(ApplicationInstanceDTO dto)
{
- return new ApplicationInstance()
- {
- Id = applicationInstanceDTO.id,
- InstanceId = applicationInstanceDTO.instanceId,
- AppType = applicationInstanceDTO.appType,
- MainImageId = applicationInstanceDTO.mainImageId,
- MainImageUrl = applicationInstanceDTO.mainImageUrl,
- LoaderImageId = applicationInstanceDTO.loaderImageId,
- LoaderImageUrl = applicationInstanceDTO.loaderImageUrl,
- IsDate = applicationInstanceDTO.isDate,
- IsHour = applicationInstanceDTO.isHour,
- PrimaryColor = applicationInstanceDTO.primaryColor,
- SecondaryColor = applicationInstanceDTO.secondaryColor,
- RoundedValue = applicationInstanceDTO.roundedValue,
- ScreenPercentageSectionsMainPage = applicationInstanceDTO.screenPercentageSectionsMainPage,
- IsSectionImageBackground = applicationInstanceDTO.isSectionImageBackground,
- Languages = applicationInstanceDTO.languages,
- Configurations = applicationInstanceDTO.configurations,
- };
+ InstanceId = dto.instanceId;
+ AppType = dto.appType;
+ MainImageId = dto.mainImageId;
+ MainImageUrl = dto.mainImageUrl;
+ LoaderImageId = dto.loaderImageId;
+ LoaderImageUrl = dto.loaderImageUrl;
+ IsDate = dto.isDate;
+ IsHour = dto.isHour;
+ PrimaryColor = dto.primaryColor;
+ SecondaryColor = dto.secondaryColor;
+ RoundedValue = dto.roundedValue;
+ ScreenPercentageSectionsMainPage = dto.screenPercentageSectionsMainPage;
+ IsSectionImageBackground = dto.isSectionImageBackground;
+ Languages = dto.languages;
+ Configurations = dto.configurations;
+
+ return this;
}
}
diff --git a/ManagerService/Data/Device.cs b/ManagerService/Data/Device.cs
index 3ba77b3..6236739 100644
--- a/ManagerService/Data/Device.cs
+++ b/ManagerService/Data/Device.cs
@@ -111,23 +111,20 @@ namespace ManagerService.Data
public Device FromDTO(DeviceDetailDTO deviceDetailDTO)
{
- return new Device()
- {
- Id = deviceDetailDTO.id,
- Name = deviceDetailDTO.name,
- DateCreation = deviceDetailDTO.dateCreation != null ? deviceDetailDTO.dateCreation.Value : DateTime.Now.ToUniversalTime(),
- Identifier = deviceDetailDTO.identifier,
- IpAddressWLAN = deviceDetailDTO.ipAddressWLAN,
- IpAddressETH = deviceDetailDTO.ipAddressETH,
- Connected = deviceDetailDTO.connected,
- ConfigurationId = deviceDetailDTO.configurationId,
- ConnectionLevel = deviceDetailDTO.connectionLevel,
- LastConnectionLevel = deviceDetailDTO.lastConnectionLevel,
- BatteryLevel = deviceDetailDTO.batteryLevel,
- LastBatteryLevel = deviceDetailDTO.lastBatteryLevel,
- DateUpdate = deviceDetailDTO.dateUpdate != null ? deviceDetailDTO.dateUpdate.Value : DateTime.Now.ToUniversalTime(),
- InstanceId = deviceDetailDTO.instanceId
- };
+ Name = deviceDetailDTO.name;
+ DateCreation = deviceDetailDTO.dateCreation != null ? deviceDetailDTO.dateCreation.Value : DateTime.Now.ToUniversalTime();
+ Identifier = deviceDetailDTO.identifier;
+ IpAddressWLAN = deviceDetailDTO.ipAddressWLAN;
+ IpAddressETH = deviceDetailDTO.ipAddressETH;
+ Connected = deviceDetailDTO.connected;
+ ConfigurationId = deviceDetailDTO.configurationId;
+ ConnectionLevel = deviceDetailDTO.connectionLevel;
+ LastConnectionLevel = deviceDetailDTO.lastConnectionLevel;
+ BatteryLevel = deviceDetailDTO.batteryLevel;
+ LastBatteryLevel = deviceDetailDTO.lastBatteryLevel;
+ DateUpdate = deviceDetailDTO.dateUpdate != null ? deviceDetailDTO.dateUpdate.Value : DateTime.Now.ToUniversalTime();
+ InstanceId = deviceDetailDTO.instanceId;
+ return this;
}
}
}
\ No newline at end of file
diff --git a/ManagerService/Data/Instance.cs b/ManagerService/Data/Instance.cs
index f328774..5c69869 100644
--- a/ManagerService/Data/Instance.cs
+++ b/ManagerService/Data/Instance.cs
@@ -49,18 +49,15 @@ namespace ManagerService.Data
public Instance FromDTO(InstanceDTO instanceDTO)
{
- return new Instance()
- {
- Id = instanceDTO.id,
- Name = instanceDTO.name,
- DateCreation = instanceDTO.dateCreation != null ? instanceDTO.dateCreation.Value : DateTime.Now.ToUniversalTime(),
- PinCode = instanceDTO.pinCode,
- IsPushNotification = instanceDTO.isPushNotification,
- IsStatistic = instanceDTO.isStatistic,
- IsMobile = instanceDTO.isMobile,
- IsTablet = instanceDTO.isTablet,
- IsVR = instanceDTO.isVR
- };
+ Name = instanceDTO.name;
+ DateCreation = instanceDTO.dateCreation != null ? instanceDTO.dateCreation.Value : DateTime.Now.ToUniversalTime();
+ PinCode = instanceDTO.pinCode;
+ IsPushNotification = instanceDTO.isPushNotification;
+ IsStatistic = instanceDTO.isStatistic;
+ IsMobile = instanceDTO.isMobile;
+ IsTablet = instanceDTO.isTablet;
+ IsVR = instanceDTO.isVR;
+ return this;
}
}
diff --git a/ManagerService/Data/SubSection/EventAgenda.cs b/ManagerService/Data/SubSection/EventAgenda.cs
index 1ccefed..79c94b9 100644
--- a/ManagerService/Data/SubSection/EventAgenda.cs
+++ b/ManagerService/Data/SubSection/EventAgenda.cs
@@ -96,35 +96,32 @@ namespace ManagerService.Data.SubSection
public EventAgenda FromDTO(EventAgendaDTO dto)
{
- return new EventAgenda
+ Label = dto.label;
+ Description = dto.description;
+ Type = dto.type;
+ DateAdded = dto.dateAdded;
+ DateFrom = dto.dateFrom;
+ DateTo = dto.dateTo;
+ Website = dto.website;
+ ResourceId = dto.resourceId;
+ //Resource = dto.Resource != null ? Resource.From(dto.Resource) : null,
+ Address = dto.address != null ? new EventAddress
{
- Id = dto.id,
- Label = dto.label,
- Description = dto.description,
- Type = dto.type,
- DateAdded = dto.dateAdded,
- DateFrom = dto.dateFrom,
- DateTo = dto.dateTo,
- Website = dto.website,
- ResourceId = dto.resourceId,
- //Resource = dto.Resource != null ? Resource.From(dto.Resource) : null,
- Address = dto.address != null ? new EventAddress
- {
- Address = dto.address.address,
- StreetNumber = dto.address.streetNumber,
- StreetName = dto.address.streetName,
- City = dto.address.city,
- State = dto.address.state,
- PostCode = dto.address.postCode,
- Country = dto.address.country,
- Geometry = dto.address.geometry!= null ? dto.address.geometry.FromDto() : null,
- PolyColor = dto.address.polyColor,
- Zoom = dto.address.zoom
- } : null,
- Phone = dto.phone,
- Email = dto.email,
- SectionAgendaId = dto.sectionAgendaId
- };
+ Address = dto.address.address,
+ StreetNumber = dto.address.streetNumber,
+ StreetName = dto.address.streetName,
+ City = dto.address.city,
+ State = dto.address.state,
+ PostCode = dto.address.postCode,
+ Country = dto.address.country,
+ Geometry = dto.address.geometry != null ? dto.address.geometry.FromDto() : null,
+ PolyColor = dto.address.polyColor,
+ Zoom = dto.address.zoom
+ } : null;
+ Phone = dto.phone;
+ Email = dto.email;
+ SectionAgendaId = dto.sectionAgendaId;
+ return this;
}
}
diff --git a/ManagerService/Data/SubSection/SectionEvent.cs b/ManagerService/Data/SubSection/SectionEvent.cs
index dfd1b02..17c40ba 100644
--- a/ManagerService/Data/SubSection/SectionEvent.cs
+++ b/ManagerService/Data/SubSection/SectionEvent.cs
@@ -48,15 +48,12 @@ namespace ManagerService.Data.SubSection
public ProgrammeBlock FromDTO(ProgrammeBlockDTO dto)
{
- return new ProgrammeBlock
- {
- Id = dto.id,
- Title = dto.title,
- Description = dto.description,
- StartTime = dto.startTime,
- EndTime = dto.endTime,
- //MapAnnotations = dto.MapAnnotations?.Select(ma => new MapAnnotation.FromDTO(ma)).ToList() // Other method
- };
+ Title = dto.title;
+ Description = dto.description;
+ StartTime = dto.startTime;
+ EndTime = dto.endTime;
+ //MapAnnotations = dto.MapAnnotations?.Select(ma => new MapAnnotation.FromDTO(ma)).ToList() // Other method
+ return this;
}
}
@@ -94,18 +91,15 @@ namespace ManagerService.Data.SubSection
public MapAnnotation FromDTO(MapAnnotationDTO dto)
{
- return new MapAnnotation
- {
- Id = dto.id,
- Type = dto.type,
- Label = dto.label,
- GeometryType = dto.geometryType,
- Geometry = dto.geometry.FromDto(),
- PolyColor = dto.polyColor,
- Icon = dto.icon,
- IconResourceId = dto.iconResourceId,
- //IconResource = dto.IconResource?.ToModel()
- };
+ Type = dto.type;
+ Label = dto.label;
+ GeometryType = dto.geometryType;
+ Geometry = dto.geometry.FromDto();
+ PolyColor = dto.polyColor;
+ Icon = dto.icon;
+ IconResourceId = dto.iconResourceId;
+ //IconResource = dto.IconResource?.ToModel()
+ return this;
}
}
diff --git a/ManagerService/Data/SubSection/SectionMap.cs b/ManagerService/Data/SubSection/SectionMap.cs
index 6c65c35..8f60c6c 100644
--- a/ManagerService/Data/SubSection/SectionMap.cs
+++ b/ManagerService/Data/SubSection/SectionMap.cs
@@ -6,7 +6,6 @@ using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Linq;
-using System.Net;
namespace ManagerService.Data.SubSection
{
@@ -205,20 +204,17 @@ namespace ManagerService.Data.SubSection
{
if (dto == null) return null;
- return new GuidedPath
- {
- Id = dto.id,
- InstanceId = dto.instanceId,
- Title = dto.title ?? new List(),
- Description = dto.description ?? new List(),
- SectionMapId = dto.sectionMapId,
- SectionEventId = dto.sectionEventId,
- IsLinear = dto.isLinear,
- RequireSuccessToAdvance = dto.requireSuccessToAdvance,
- HideNextStepsUntilComplete = dto.hideNextStepsUntilComplete,
- Order = dto.order,
- //Steps = dto.Steps?.Select(s => s.FromDTO()).ToList() ?? new List() // Other method
- };
+ InstanceId = dto.instanceId;
+ Title = dto.title ?? new List();
+ Description = dto.description ?? new List();
+ SectionMapId = dto.sectionMapId;
+ SectionEventId = dto.sectionEventId;
+ IsLinear = dto.isLinear;
+ RequireSuccessToAdvance = dto.requireSuccessToAdvance;
+ HideNextStepsUntilComplete = dto.hideNextStepsUntilComplete;
+ Order = dto.order;
+ //Steps = dto.Steps?.Select(s => s.FromDTO()).ToList() ?? new List() // Other method
+ return this;
}
}
@@ -299,24 +295,21 @@ namespace ManagerService.Data.SubSection
{
if (dto == null) return null;
- return new GuidedStep
- {
- Id = dto.id,
- GuidedPathId = dto.guidedPathId,
- Title = dto.title ?? new List(),
- Description = dto.description ?? new List(),
- Geometry = dto.geometry.FromDto(),
- ZoneRadiusMeters = dto.zoneRadiusMeters,
- ImageUrl = dto.imageUrl,
- TriggerGeoPointId = dto.triggerGeoPointId,
- IsHiddenInitially = dto.isHiddenInitially,
- IsStepTimer = dto.isStepTimer,
- IsStepLocked = dto.isStepLocked,
- TimerSeconds = dto.timerSeconds,
- TimerExpiredMessage = dto.timerExpiredMessage ?? new List(),
- Order = dto.order,
- QuizQuestions = dto.quizQuestions
- };
+ GuidedPathId = dto.guidedPathId;
+ Title = dto.title ?? new List();
+ Description = dto.description ?? new List();
+ Geometry = dto.geometry.FromDto();
+ ZoneRadiusMeters = dto.zoneRadiusMeters;
+ ImageUrl = dto.imageUrl;
+ TriggerGeoPointId = dto.triggerGeoPointId;
+ IsHiddenInitially = dto.isHiddenInitially;
+ IsStepTimer = dto.isStepTimer;
+ IsStepLocked = dto.isStepLocked;
+ TimerSeconds = dto.timerSeconds;
+ TimerExpiredMessage = dto.timerExpiredMessage ?? new List();
+ Order = dto.order;
+ QuizQuestions = dto.quizQuestions;
+ return this;
}
}