public async Task <ColumnOptionsServiceModel> AddColumnOptionsAsync(ColumnOptionsServiceModel columnOptions, string userId) { ValueApiModel response = null; AuditHelper.AddAuditingData(columnOptions, userId); var value = JsonConvert.SerializeObject(columnOptions, Formatting.Indented, new JsonSerializerSettings { NullValueHandling = NullValueHandling.Ignore }); response = await this.client.CreateAsync(ColumnOptionsCollectionId, value); return(this.CreateColumnOptionsServiceModel(response)); }
public async Task <PackageServiceModel> AddPackageAsync(PackageServiceModel package, string userId, string tenantId) { bool isValidPackage = this.IsValidPackage(package); if (!isValidPackage) { var msg = "Package provided is a invalid deployment manifest " + $"for type {package.PackageType}"; msg += package.PackageType.Equals(PackageType.DeviceConfiguration) ? $"and configuration {package.ConfigType}" : string.Empty; throw new InvalidInputException(msg); } try { JsonConvert.DeserializeObject <Configuration>(package.Content); } catch (Exception) { throw new InvalidInputException("Package provided is not a valid deployment manifest"); } package.DateCreated = DateTimeOffset.UtcNow.ToString(DateFormat); AuditHelper.AddAuditingData(package, userId); var value = JsonConvert.SerializeObject( package, Formatting.Indented, new JsonSerializerSettings { NullValueHandling = NullValueHandling.Ignore, }); var response = await this.client.CreateAsync(PackagesCollectionId, value); if (!string.IsNullOrEmpty(package.ConfigType) && package.PackageType.Equals(PackageType.DeviceConfiguration)) { await this.UpdateConfigTypeAsync(package.ConfigType); } // Setting the package id before logging package.Id = response.Key; // Log a custom event to Application Insight this.packageLog.LogPackageUpload(package, tenantId, userId); return(this.CreatePackageServiceModel(response)); }
public async Task <ColumnMappingServiceModel> AddColumnMappingAsync(ColumnMappingServiceModel columnMapping, string userId) { ValueApiModel response = null; AuditHelper.AddAuditingData(columnMapping, userId); // Make ETag as empty to make sure that is inserted as new entity; columnMapping.ETag = null; if (columnMapping.IsDefault) { columnMapping.Id = columnMapping.Name; response = await this.SaveColumnMappingWithKeyAsync(columnMapping); } else { response = await this.SaveColumnMappingAsync(columnMapping); } return(this.CreateColumnMappingServiceModel(response)); }
private async Task StoreDeploymentInSecondaryStorage(DeploymentServiceModel deployment, string userId) { if (string.IsNullOrWhiteSpace(deployment.ETag)) { AuditHelper.AddAuditingData(deployment, userId); } else { AuditHelper.UpdateAuditingData(deployment, userId); } var value = JsonConvert.SerializeObject( deployment, Formatting.Indented, new JsonSerializerSettings { NullValueHandling = NullValueHandling.Ignore, }); var response = await this.client.UpdateAsync(DeploymentsCollection, deployment.Id, value, deployment.ETag); }