Add sectionIds to ConfigurationDTO
This commit is contained in:
parent
a0b2d5ba9c
commit
74101d9939
@ -21,5 +21,6 @@ namespace Manager.Interfaces.DTO
|
|||||||
/*public string latitude { get; set; } // MyVisit - latitude of visit ? (MyVisit)
|
/*public string latitude { get; set; } // MyVisit - latitude of visit ? (MyVisit)
|
||||||
public string longitude { get; set; } // MyVisit - True if for mobile (MyVisit)*/
|
public string longitude { get; set; } // MyVisit - True if for mobile (MyVisit)*/
|
||||||
public string instanceId { get; set; }
|
public string instanceId { get; set; }
|
||||||
|
public List<string> sectionIds { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -2,6 +2,7 @@
|
|||||||
using MongoDB.Bson.Serialization.Attributes;
|
using MongoDB.Bson.Serialization.Attributes;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
|
|
||||||
namespace Manager.Interfaces.Models
|
namespace Manager.Interfaces.Models
|
||||||
@ -54,7 +55,7 @@ namespace Manager.Interfaces.Models
|
|||||||
[BsonRequired]
|
[BsonRequired]
|
||||||
public string InstanceId { get; set; }
|
public string InstanceId { get; set; }
|
||||||
|
|
||||||
public ConfigurationDTO ToDTO()
|
public ConfigurationDTO ToDTO(List<string> sectionIds)
|
||||||
{
|
{
|
||||||
return new ConfigurationDTO()
|
return new ConfigurationDTO()
|
||||||
{
|
{
|
||||||
@ -71,6 +72,7 @@ namespace Manager.Interfaces.Models
|
|||||||
isTablet = IsTablet,
|
isTablet = IsTablet,
|
||||||
isOffline = IsOffline,
|
isOffline = IsOffline,
|
||||||
instanceId = InstanceId,
|
instanceId = InstanceId,
|
||||||
|
sectionIds = sectionIds
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -92,6 +94,7 @@ namespace Manager.Interfaces.Models
|
|||||||
sections = sections,
|
sections = sections,
|
||||||
resources = resources,
|
resources = resources,
|
||||||
instanceId = InstanceId,
|
instanceId = InstanceId,
|
||||||
|
sectionIds = sections.Select(s => s.id).ToList()
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -56,7 +56,16 @@ namespace ManagerService.Controllers
|
|||||||
{
|
{
|
||||||
List<Configuration> configurations = _configurationService.GetAll(instanceId);
|
List<Configuration> configurations = _configurationService.GetAll(instanceId);
|
||||||
|
|
||||||
return new OkObjectResult(configurations.Select(r => r.ToDTO()));
|
List<ConfigurationDTO> configurationDTOs = new List<ConfigurationDTO>();
|
||||||
|
|
||||||
|
foreach(var configuration in configurations)
|
||||||
|
{
|
||||||
|
List<string> sectionIds = _sectionService.GetAllIdsFromConfiguration(configuration.Id);
|
||||||
|
ConfigurationDTO configurationDTO = configuration.ToDTO(sectionIds);
|
||||||
|
configurationDTOs.Add(configurationDTO);
|
||||||
|
}
|
||||||
|
|
||||||
|
return new OkObjectResult(configurationDTOs);
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
@ -83,7 +92,9 @@ namespace ManagerService.Controllers
|
|||||||
if (configuration == null)
|
if (configuration == null)
|
||||||
throw new KeyNotFoundException("This configuration was not found");
|
throw new KeyNotFoundException("This configuration was not found");
|
||||||
|
|
||||||
return new OkObjectResult(configuration.ToDTO());
|
List<string> sectionIds = _sectionService.GetAllIdsFromConfiguration(id);
|
||||||
|
|
||||||
|
return new OkObjectResult(configuration.ToDTO(sectionIds));
|
||||||
}
|
}
|
||||||
catch (KeyNotFoundException ex)
|
catch (KeyNotFoundException ex)
|
||||||
{
|
{
|
||||||
@ -133,7 +144,7 @@ namespace ManagerService.Controllers
|
|||||||
|
|
||||||
Configuration configurationCreated = _configurationService.Create(configuration);
|
Configuration configurationCreated = _configurationService.Create(configuration);
|
||||||
|
|
||||||
return new OkObjectResult(configurationCreated.ToDTO());
|
return new OkObjectResult(configurationCreated.ToDTO(new List<string>())); // Empty list
|
||||||
}
|
}
|
||||||
catch (ArgumentNullException ex)
|
catch (ArgumentNullException ex)
|
||||||
{
|
{
|
||||||
@ -188,7 +199,9 @@ namespace ManagerService.Controllers
|
|||||||
|
|
||||||
// TODO HANDLE MqttClientService.PublishMessage($"config/{configurationModified.Id}", JsonConvert.SerializeObject(new PlayerMessageDTO() { configChanged = true }));
|
// TODO HANDLE MqttClientService.PublishMessage($"config/{configurationModified.Id}", JsonConvert.SerializeObject(new PlayerMessageDTO() { configChanged = true }));
|
||||||
|
|
||||||
return new OkObjectResult(configurationModified.ToDTO());
|
List<string> sectionIds = _sectionService.GetAllIdsFromConfiguration(configuration.Id);
|
||||||
|
|
||||||
|
return new OkObjectResult(configurationModified.ToDTO(sectionIds));
|
||||||
}
|
}
|
||||||
catch (ArgumentNullException ex)
|
catch (ArgumentNullException ex)
|
||||||
{
|
{
|
||||||
|
|||||||
@ -29,6 +29,11 @@ namespace Manager.Services
|
|||||||
return _Sections.Find(s => !s.IsSubSection && s.ConfigurationId == configurationId).ToList();
|
return _Sections.Find(s => !s.IsSubSection && s.ConfigurationId == configurationId).ToList();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public List<string> GetAllIdsFromConfiguration(string configurationId)
|
||||||
|
{
|
||||||
|
return _Sections.Find(s => !s.IsSubSection && s.ConfigurationId == configurationId).ToList().Select(s => s.Id).ToList();
|
||||||
|
}
|
||||||
|
|
||||||
public List<Section> GetAllSubSection(string parentId)
|
public List<Section> GetAllSubSection(string parentId)
|
||||||
{
|
{
|
||||||
return _Sections.Find(s => s.IsSubSection && s.ParentId == parentId).ToList();
|
return _Sections.Find(s => s.IsSubSection && s.ParentId == parentId).ToList();
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user