Clean GetAllBeaconsForInstance accept return empty list
This commit is contained in:
parent
33f782346b
commit
f5921180cf
@ -238,16 +238,13 @@ namespace ManagerService.Controllers
|
|||||||
[ProducesResponseType(typeof(List<SectionDTO>), 200)]
|
[ProducesResponseType(typeof(List<SectionDTO>), 200)]
|
||||||
[ProducesResponseType(typeof(string), 404)]
|
[ProducesResponseType(typeof(string), 404)]
|
||||||
[ProducesResponseType(typeof(string), 500)]
|
[ProducesResponseType(typeof(string), 500)]
|
||||||
[HttpGet("beacons/{id}")]
|
[HttpGet("beacons/{instanceId}")]
|
||||||
public ObjectResult GetAllBeaconsForInstance(string instanceId)
|
public ObjectResult GetAllBeaconsForInstance(string instanceId)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
List<Section> sections = _sectionService.GetAll(instanceId);
|
List<Section> sections = _sectionService.GetAll(instanceId);
|
||||||
|
|
||||||
if (sections.Count == 0)
|
|
||||||
throw new KeyNotFoundException("No section has beacon");
|
|
||||||
|
|
||||||
sections = sections.Where(s => s.IsBeacon && s.BeaconId != null).ToList();
|
sections = sections.Where(s => s.IsBeacon && s.BeaconId != null).ToList();
|
||||||
|
|
||||||
return new OkObjectResult(sections.Select(s => s.ToDTO()));
|
return new OkObjectResult(sections.Select(s => s.ToDTO()));
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user