public virtual async Task <Status> ListLicenses(IIdentityAccessService idAccessSvc, string entLookup, string username, string licenseType) { var licenseAccess = await idAccessSvc.ListLicensesByUsername(entLookup, username, new List <string>() { licenseType }); State.ExistingLicenseTypes = licenseAccess.Model; return((licenseAccess != null) ? Status.Success : Status.Unauthorized.Clone($"No licenses found for user {username}")); }
public virtual async Task LoadChildEnterprises(IEnterprisesManagementService entMgr, string parentEntLookup, IApplicationsIoTService appIoTArch, IIdentityAccessService idMgr) { var childEntsResp = await entMgr.ListChildEnterprises(parentEntLookup); State.EnterpriseConfig.TotalChildEnterprisesCount = childEntsResp.Model?.Count; var pagedChildEnts = childEntsResp.Model?.Page(State.EnterpriseConfig.Page, State.EnterpriseConfig.PageSize); var iotChildEnts = new List <IoTEnsembleChildEnterprise>(); await pagedChildEnts.Items.Each(async childEnt => { var devicesResp = await appIoTArch.ListEnrolledDevices(childEnt.Lookup); var licenses = await idMgr.ListLicensesByUsername(parentEntLookup, childEnt.Name, new List <string>() { "iot" }); DateTime?StartDate = null; foreach (License token in licenses.Model) { if (token.AccessStartDate != null) { StartDate = token.AccessStartDate.UtcDateTime; } } var iotChildEnt = new IoTEnsembleChildEnterprise() { Name = childEnt.Name, Lookup = childEnt.Lookup, DeviceCount = devicesResp.Model?.TotalRecords ?? 0, SignUpDate = StartDate }; iotChildEnt.Devices = devicesResp.Model?.Items?.Select(device => { var devInfo = device.JSONConvert <IoTEnsembleDeviceInfo>(); devInfo.DeviceName = devInfo.DeviceID.Replace($"{childEnt.Lookup}-", String.Empty); return(devInfo); }).ToList(); iotChildEnts.Add(iotChildEnt); }); State.EnterpriseConfig.ChildEnterprises = iotChildEnts; }