public LicenseTypesResponse CreateLicenseTypes(LicenseTypeCreateRequest request, string UserId, string TenantId) { LicenseTypesResponse responseModel = new LicenseTypesResponse(); LicenseTypesModel licenseTypesModel = new LicenseTypesModel(); licenseTypesModel.licenseTypeName = request.LicenseTypeName; licenseTypesModel.userId = UserId; licenseTypesModel.tenantId = TenantId; licenseTypesModel.createdBy = UserId; licenseTypesModel.createdDate = DateTime.UtcNow; licenseTypesModel.modifiedBy = UserId; licenseTypesModel.modifiedDate = DateTime.UtcNow; licenseTypesModel.isActive = true; licenseTypesModel.isDeleted = false; //// Run below line First time only //_cosmosDBOperationsRepository.CreateCollectionIfNotExistsAsync(licenseTypeCollectionId); LicenseTypesModel result = _cosmosDBOperationsRepository.AddDocumentIntoCollectionAsync(licenseTypesModel, UserId.Trim().ToString(), TenantId, licenseTypeCollectionId).Result; CommonFunctions.CopyProperties(result, responseModel); return(responseModel); }
public bool DeleteLicenseTypes(LicenseTypeDeleteRequest request, string UserId, string TenantId) { LicenseTypesResponse responseModel = new LicenseTypesResponse(); LicenseTypesModel licenseTypesModel = new LicenseTypesModel(); bool result = _cosmosDBOperationsRepository.DeleteDocumentFromCollectionAsync(request.id, TenantId, licenseTypeCollectionId).Result; return(result); }
public LicenseTypesResponse UpdateLicenseTypes(LicenseTypeUpdateRequest request, string UserId, string TenantId) { LicenseTypesResponse responseModel = new LicenseTypesResponse(); LicenseTypesModel licenseTypesModel = GetLicenseTypeById(request, TenantId, out LicenseTypesStatusModel licenseTypesStatus); if (licenseTypesStatus.IsLicenseTypesFound) { licenseTypesModel.licenseTypeName = request.LicenseTypeName; licenseTypesModel.modifiedBy = UserId; licenseTypesModel.modifiedDate = DateTime.UtcNow; LicenseTypesModel result = _cosmosDBOperationsRepository.UpdateDocumentFromCollection(licenseTypesModel.id, licenseTypesModel, TenantId, licenseTypeCollectionId).Result; CommonFunctions.CopyProperties(result, responseModel); } return(responseModel); }
public LicenseTypesModel GetLicenseTypeById(LicenseTypeUpdateRequest request, string tenantId, out LicenseTypesStatusModel licenseTypesStatus) { if (!string.IsNullOrWhiteSpace(request.id)) { request.id = request.id.ToLower(); } licenseTypesStatus = new LicenseTypesStatusModel(); string query = $" WHERE LOWER({licenseTypeCollectionId}.id) = '{request.id}'"; LicenseTypesModel result = _cosmosDBOperationsRepository.GetItemByQueryFromCollectionAsync( query, tenantId, licenseTypeCollectionId).Result; if (result == null) { licenseTypesStatus.Message = String.Format($"License type '{request.LicenseTypeName}' not found"); return(null); } licenseTypesStatus.IsLicenseTypesFound = true; return(result); }