public async Task <LicenseModel> PrepareLicenseModel(LicenseModel model, License license, bool excludeProperties = false) { if (license != null) { model = model ?? license.ToModel <LicenseModel>(); if (!excludeProperties) { model.CountDevices = (await _licenseService.GetDeviceLicenseByLicenseId(model.Id)).Count(); model.LicenseType = CommonHelper.ConvertEnum(license.LicenseType.ToString()); model.Generated = model.DownloadId > 0; } await PrepareFeatureSearchModel(model.DeviceLicenseSearchModel, license); } if (license == null) { model.Generated = false; } await PrepareLicenseType(model.AvailableLicenseType); return(model); }
private Task PrepareFeatureSearchModel(DeviceLicenseSearchModel searchModel, License license) { if (searchModel == null) { throw new ArgumentNullException(nameof(searchModel)); } if (license == null) { throw new ArgumentNullException(nameof(license)); } searchModel.LicenseId = license.Id; searchModel.SetGridPageSize(); return(Task.FromResult(searchModel)); }
public async Task <DataSourceResult> PrepareDeviceLicenseListModel(DeviceLicenseSearchModel searchModel, License license) { if (searchModel == null) { throw new ArgumentNullException(nameof(searchModel)); } if (license == null) { throw new ArgumentNullException(nameof(license)); } var deviceLicense = await _licenseService.GetDeviceLicense( licenseId : license.Id, pageIndex : searchModel.Page - 1, pageSize : searchModel.PageSize); var result = new DataSourceResult { Data = deviceLicense.Select(device => { var model = device.ToModel <DeviceLicenseModel>(); model.StoreName = device.Store != null ? device.Store.P_BranchNo + " - " + device.Store.P_Name : string.Empty; return(model); }), Total = deviceLicense.TotalCount }; return(result); }