|
|
|
@ -59,6 +59,22 @@ namespace IoTCenter.Api.Controllers
|
|
|
|
|
[HttpPost]
|
|
|
|
|
public ActionResult GetProduct([Required(ErrorMessage = nameof(RequiredAttribute))] string number, string organNumber)
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
var model = this._productRepo.ReadOnlyTable().Where(o => o.Number == number).FirstOrDefault();
|
|
|
|
|
model.Devices = this._deviceRepo.ReadOnlyTable()
|
|
|
|
|
.Where(o => o.Product.Id == model.Id)
|
|
|
|
|
.WhereIf(!string.IsNullOrWhiteSpace(organNumber), o => o.Node.OrganNodes.Any(o => o.Organ.Number == organNumber))
|
|
|
|
|
.Include(o=>o.Node)
|
|
|
|
|
.Include(o=>o.Data)
|
|
|
|
|
.ToList();
|
|
|
|
|
return Ok(model);
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
ex.PrintStack();
|
|
|
|
|
return Problem(ex.Message);
|
|
|
|
|
}
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
var model = this._nodeRepo.ReadOnlyTable()
|
|
|
|
|