Add pinCode to instance + endpoints
This commit is contained in:
parent
19d84b4417
commit
1e31ebe094
@ -22,5 +22,6 @@ namespace Manager.Interfaces.DTO
|
|||||||
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; }
|
public List<string> sectionIds { get; set; }
|
||||||
|
public int pinCode { get; set; } // 4 number
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -9,5 +9,6 @@ namespace Manager.Interfaces.DTO
|
|||||||
public string id { get; set; }
|
public string id { get; set; }
|
||||||
public string name { get; set; }
|
public string name { get; set; }
|
||||||
public DateTime dateCreation { get; set; }
|
public DateTime dateCreation { get; set; }
|
||||||
|
public int? pinCode { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -55,6 +55,9 @@ namespace Manager.Interfaces.Models
|
|||||||
[BsonRequired]
|
[BsonRequired]
|
||||||
public string InstanceId { get; set; }
|
public string InstanceId { get; set; }
|
||||||
|
|
||||||
|
[BsonElement("PinCode")]
|
||||||
|
public int PinCode { get; set; }
|
||||||
|
|
||||||
public ConfigurationDTO ToDTO(List<string> sectionIds)
|
public ConfigurationDTO ToDTO(List<string> sectionIds)
|
||||||
{
|
{
|
||||||
return new ConfigurationDTO()
|
return new ConfigurationDTO()
|
||||||
@ -72,6 +75,7 @@ namespace Manager.Interfaces.Models
|
|||||||
isTablet = IsTablet,
|
isTablet = IsTablet,
|
||||||
isOffline = IsOffline,
|
isOffline = IsOffline,
|
||||||
instanceId = InstanceId,
|
instanceId = InstanceId,
|
||||||
|
pinCode = PinCode,
|
||||||
sectionIds = sectionIds
|
sectionIds = sectionIds
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@ -94,6 +98,7 @@ namespace Manager.Interfaces.Models
|
|||||||
sections = sections,
|
sections = sections,
|
||||||
resources = resources,
|
resources = resources,
|
||||||
instanceId = InstanceId,
|
instanceId = InstanceId,
|
||||||
|
pinCode = PinCode,
|
||||||
sectionIds = sections.Select(s => s.id).ToList()
|
sectionIds = sections.Select(s => s.id).ToList()
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@ -22,13 +22,17 @@ namespace Manager.Interfaces.Models
|
|||||||
[BsonElement("DateCreation")]
|
[BsonElement("DateCreation")]
|
||||||
public DateTime DateCreation { get; set; }
|
public DateTime DateCreation { get; set; }
|
||||||
|
|
||||||
|
[BsonElement("PinCode")]
|
||||||
|
public int? PinCode { get; set; }
|
||||||
|
|
||||||
public InstanceDTO ToDTO()
|
public InstanceDTO ToDTO()
|
||||||
{
|
{
|
||||||
return new InstanceDTO()
|
return new InstanceDTO()
|
||||||
{
|
{
|
||||||
id = Id,
|
id = Id,
|
||||||
name = Name,
|
name = Name,
|
||||||
dateCreation = DateCreation
|
dateCreation = DateCreation,
|
||||||
|
pinCode = PinCode
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -24,6 +24,7 @@ namespace ManagerService.Controllers
|
|||||||
public class ConfigurationController : ControllerBase
|
public class ConfigurationController : ControllerBase
|
||||||
{
|
{
|
||||||
private ConfigurationDatabaseService _configurationService;
|
private ConfigurationDatabaseService _configurationService;
|
||||||
|
private InstanceDatabaseService _instanceService;
|
||||||
private SectionDatabaseService _sectionService;
|
private SectionDatabaseService _sectionService;
|
||||||
private ResourceDatabaseService _resourceService;
|
private ResourceDatabaseService _resourceService;
|
||||||
private ResourceDataDatabaseService _resourceDataService;
|
private ResourceDataDatabaseService _resourceDataService;
|
||||||
@ -31,11 +32,12 @@ namespace ManagerService.Controllers
|
|||||||
private readonly ILogger<ConfigurationController> _logger;
|
private readonly ILogger<ConfigurationController> _logger;
|
||||||
private readonly IConfiguration _configuration;
|
private readonly IConfiguration _configuration;
|
||||||
|
|
||||||
public ConfigurationController(IConfiguration configuration, ILogger<ConfigurationController> logger, ConfigurationDatabaseService configurationService, SectionDatabaseService sectionService, ResourceDatabaseService resourceService, ResourceDataDatabaseService resourceDataService, DeviceDatabaseService deviceService)
|
public ConfigurationController(IConfiguration configuration, ILogger<ConfigurationController> logger, ConfigurationDatabaseService configurationService, InstanceDatabaseService instanceService, SectionDatabaseService sectionService, ResourceDatabaseService resourceService, ResourceDataDatabaseService resourceDataService, DeviceDatabaseService deviceService)
|
||||||
{
|
{
|
||||||
_logger = logger;
|
_logger = logger;
|
||||||
_configuration = configuration;
|
_configuration = configuration;
|
||||||
_configurationService = configurationService;
|
_configurationService = configurationService;
|
||||||
|
_instanceService = instanceService;
|
||||||
_sectionService = sectionService;
|
_sectionService = sectionService;
|
||||||
_resourceService = resourceService;
|
_resourceService = resourceService;
|
||||||
_resourceDataService = resourceDataService;
|
_resourceDataService = resourceDataService;
|
||||||
@ -73,6 +75,39 @@ namespace ManagerService.Controllers
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Get Confuguration list by instanceId' pincode
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="pinCode">Code pin</param>
|
||||||
|
[AllowAnonymous]
|
||||||
|
[ProducesResponseType(typeof(List<ConfigurationDTO>), 200)]
|
||||||
|
[ProducesResponseType(typeof(string), 404)]
|
||||||
|
[ProducesResponseType(typeof(string), 500)]
|
||||||
|
[HttpGet("byPin")]
|
||||||
|
public ObjectResult GetConfigurationsByPinCode([FromQuery] int pinCode)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
Instance instance = _instanceService.GetByPinCode(pinCode);
|
||||||
|
|
||||||
|
if (instance == null)
|
||||||
|
throw new KeyNotFoundException("None instance is linked to this pin code");
|
||||||
|
|
||||||
|
List<Configuration> configurations = _configurationService.GetAll(instance.Id);
|
||||||
|
List<ConfigurationDTO> configurationDTOs = new List<ConfigurationDTO>();
|
||||||
|
foreach (var configuration in configurations)
|
||||||
|
{
|
||||||
|
List<string> sectionIds = _sectionService.GetAllIdsFromConfiguration(configuration.Id);
|
||||||
|
configurationDTOs.Add(configuration.ToDTO(sectionIds));
|
||||||
|
}
|
||||||
|
|
||||||
|
return new OkObjectResult(configurationDTOs);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
return new ObjectResult(ex.Message) { StatusCode = 500 };
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Get a specific display configuration
|
/// Get a specific display configuration
|
||||||
|
|||||||
@ -164,6 +164,32 @@ namespace ManagerService.Controllers
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Get Instance by pincode
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="pinCode">Code pin</param>
|
||||||
|
[AllowAnonymous]
|
||||||
|
[ProducesResponseType(typeof(InstanceDTO), 200)]
|
||||||
|
[ProducesResponseType(typeof(string), 404)]
|
||||||
|
[ProducesResponseType(typeof(string), 500)]
|
||||||
|
[HttpGet("byPin")]
|
||||||
|
public ObjectResult GetInstanceByPinCode([FromQuery] int pinCode)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
Instance instance = _instanceService.GetByPinCode(pinCode);
|
||||||
|
|
||||||
|
if (instance == null)
|
||||||
|
throw new KeyNotFoundException("Instance was not found");
|
||||||
|
|
||||||
|
return new OkObjectResult(instance.ToDTO());
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
return new ObjectResult(ex.Message) { StatusCode = 500 };
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Delete an instance
|
/// Delete an instance
|
||||||
|
|||||||
@ -33,6 +33,11 @@ namespace Manager.Services
|
|||||||
return _Instances.Find<Instance>(i => i.Id == id).FirstOrDefault();
|
return _Instances.Find<Instance>(i => i.Id == id).FirstOrDefault();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Instance GetByPinCode(int pinCode)
|
||||||
|
{
|
||||||
|
return _Instances.Find<Instance>(c => c.PinCode == pinCode).FirstOrDefault();
|
||||||
|
}
|
||||||
|
|
||||||
public bool IsExist(string id)
|
public bool IsExist(string id)
|
||||||
{
|
{
|
||||||
return _Instances.Find<Instance>(i => i.Id == id).FirstOrDefault() != null ? true : false;
|
return _Instances.Find<Instance>(i => i.Id == id).FirstOrDefault() != null ? true : false;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user