public async Task <ActionResult <string> > CreateList(string title) { var taskList = new TaskList { Title = title }; var result = await _tasksCosmosStore.UpsertAsync(taskList); return(result.Entity.Id); }
public async Task StoreAsync(PersistedGrant grant) { Guard.ForNull(grant, nameof(grant)); Guard.ForNull(grant.CreationTime, nameof(grant.CreationTime)); Guard.ForNull(grant.Expiration, nameof(grant.Expiration)); Guard.ForNullOrWhitespace(grant.ClientId, nameof(grant.ClientId)); Guard.ForNullOrWhitespace(grant.SubjectId, nameof(grant.SubjectId)); Guard.ForNullOrWhitespace(grant.Data, nameof(grant.Data)); Guard.ForNullOrWhitespace(grant.Key, nameof(grant.Key)); Guard.ForNullOrWhitespace(grant.Type, nameof(grant.Type)); if (grant.Expiration <= grant.CreationTime) { throw new ArgumentOutOfRangeException(); } var entity = grant.ToEntity(); var ttl = (int)(entity.Expiration - entity.CreationTime)?.TotalSeconds; if (ttl <= 0) { ttl = -1; } entity.TTL = ttl; var response = await _persistedGrantCosmosStore.UpsertAsync(entity); if (!response.IsSuccess) { _logger.LogCritical("Could not store PersitedGrant"); } }
private async Task <MeUser> GenerateUser(Location location, UserRoles role, int index) { var id = Guid.NewGuid().ToString(); var user = new MeUser() { UserId = id, FirstName = $"{role}{index}", LastName = $"At-{location.Name}", Email = $"{id}@example.com", Permissions = new List <MEUserPermission>() { new MEUserPermission() { LocationId = location.LocationId, PermissionId = Guid.NewGuid().ToString(), UserRole = role, } } }; var result = await _userStore.UpsertAsync(user); return(result.Entity); }
private async Task <Location> GenerateLocation(Location parent, LocationType locationType, int index) { var locationId = Guid.NewGuid().ToString(); var location = new Location() { LocationId = locationId, Name = NameForLocation(locationType, parent, index), ParentId = parent?.LocationId, Type = locationType, NationalLocationId = locationType == LocationType.National ? locationId : parent?.NationalLocationId, RegionLocationId = locationType == LocationType.Region ? locationId : parent?.RegionLocationId, TrustLocationId = locationType == LocationType.Trust ? locationId : parent?.TrustLocationId, SiteLocationId = locationType == LocationType.Site ? locationId : null, }; var result = await _locationStore.UpsertAsync(location); return(result.Entity); }
public async Task <OrchestrationLog> Save(OrchestrationLog log) { log.timeStamp = DateTime.Now; var result = await _store.UpsertAsync(log); return(result.Entity); }
public async Task <MeUser> ImportUser(string userJson) { var user = JsonConvert.DeserializeObject <MeUser>(userJson); var result = await _userStore.UpsertAsync(user); return(result.Entity); }
public async Task <Location> ImportLocation(string locationJson) { var location = JsonConvert.DeserializeObject <Location>(locationJson); var result = await _locationStore.UpsertAsync(location); return(result.Entity); }
public async Task <IActionResult> Create([FromBody] CreatePersonRequest request, CancellationToken cancellationToken) { var personToCreate = new Person { Name = request.Name }; var result = await _peopleCosmosStore.UpsertAsync(personToCreate, cancellationToken : cancellationToken); var personId = result.Entity.Id; if (personId == null) { return(BadRequest()); } return(Ok(personId)); }
public async Task <IActionResult> Create( [FromBody] CreateIndexRequest request, CancellationToken cancellationToken) { var indexToCreate = new Index { Name = request.Name, Location = request.Location }; var result = await _indexCosmosStore.UpsertAsync(indexToCreate); var indexId = result.Entity.Id; if (indexId == null) { return(BadRequest()); } return(Ok(indexId)); }
public async Task StoreAsync(IdentityResource model) { Guard.ForNull(model, nameof(model)); Guard.ForNull(model.Name, nameof(model.Name)); var entity = model.ToEntity(); var response = await _identityResourceGrantCosmosStore.UpsertAsync(entity); if (!response.IsSuccess) { _logger.LogCritical("Could not store IdentityResource"); } }
protected async Task <ActionResult <T> > UpsertAsync(T entity) { entity.EnvId = _environmentId; var cosmosResponse = await _cosmosStore.UpsertAsync(entity, _requestOptions); if (cosmosResponse.IsSuccess) { return(new OkObjectResult(cosmosResponse.Entity)); } _logger.LogError(cosmosResponse.Exception, $"There was an error upserting the {nameof(T)}. The status of the operation is {cosmosResponse.CosmosOperationStatus}"); return(new StatusCodeResult(StatusCodes.Status500InternalServerError)); }
/// <summary> /// Generates the examinations. /// </summary> /// <remarks>Must be called after the location that it resides in.</remarks> /// <param name="parent">The parent.</param> /// <returns></returns> private async Task GenerateExaminations(Location parent) { var examinations = 5; for (int i = 0; i < examinations; i++) { var examination = new Examination() { MedicalExaminerOfficeResponsible = parent.LocationId, // Populate these or else nobody will be able to see them. NationalLocationId = parent.NationalLocationId, RegionLocationId = parent.RegionLocationId, TrustLocationId = parent.TrustLocationId, SiteLocationId = parent.SiteLocationId, }; await _examinationStore.UpsertAsync(examination); } }
public async Task <bool> SetAsync(string key, CacheItem item, TimeSpan expiration) { Guard.ForNullOrWhitespace(key, nameof(key)); Guard.ForNull(item, nameof(item)); Guard.ForNull(expiration, nameof(expiration)); var entity = item.ToEntity(); var ttl = (int)expiration.TotalSeconds; if (ttl <= 0) { ttl = -1; } entity.TTL = ttl; var response = await _store.UpsertAsync(entity); if (!response.IsSuccess) { _logger.LogCritical("Could not store PersitedGrant"); } return(response.IsSuccess); }
public async Task AddPlayer(Player player) { _validation.ValidatePlayer(player); var playerDoc = PlayerDocument.GenerateFromDomain(Guid.NewGuid().ToString(), player); await _cosmosStore.UpsertAsync(playerDoc); }