internal IResult UpdateLocation(Location location, UpdateLocationParameters parameters) { location.Description = parameters.Params.Description; location.Active = parameters.Params.Active; location.Locked = parameters.Params.Locked; return(new SuccessResult()); }
internal IResult UpdateLocation(UpdateLocationParameters parameters) { var location = _facilityUnitOfWork.LocationRepository.FindByKey(parameters.LocationKey); if (location == null) { return(new InvalidResult(string.Format(UserMessages.LocationNotFound, parameters.LocationKey))); } return(UpdateLocation(location, new UpdateLocationParameters { Params = parameters.Params, })); }
public void Updates_Location_as_expected_on_success() { //Arrange var locationKey = new LocationKey(TestHelper.CreateObjectGraphAndInsertIntoDatabase <Location>()); //Act var parameters = new UpdateLocationParameters { UserToken = TestUser.UserName, LocationKey = locationKey }; var result = Service.UpdateLocation(parameters); //Assert result.AssertSuccess(); RVCUnitOfWork.LocationRepository.FindByKey(locationKey).AssertEqual(parameters); }
private async Task <Microsoft.Azure.Management.CosmosDB.Fluent.ICosmosDBAccount> DoDatabaseUpdateCreateAsync(CancellationToken cancellationToken = default(CancellationToken)) { CosmosDBAccountImpl self = this; int currentDelayDueToMissingFailovers = 0; HasLocation locationParameters; if (IsInCreateMode) { Models.DatabaseAccountCreateUpdateParameters createUpdateParametersInner = this.CreateUpdateParametersInner(this.Inner); await this.Manager.Inner.DatabaseAccounts.CreateOrUpdateAsync( ResourceGroupName, Name, createUpdateParametersInner); locationParameters = new CreateUpdateLocationParameters(createUpdateParametersInner); } else { Models.DatabaseAccountUpdateParameters updateParametersInner = this.UpdateParametersInner(this.Inner); await this.Manager.Inner.DatabaseAccounts.UpdateAsync( ResourceGroupName, Name, updateParametersInner); locationParameters = new UpdateLocationParameters(updateParametersInner); } this.failoverPolicies.Clear(); this.hasFailoverPolicyChanges = false; bool done = false; ICosmosDBAccount databaseAccount = null; while (!done) { await SdkContext.DelayProvider.DelayAsync(5000, cancellationToken); databaseAccount = await this.Manager.CosmosDBAccounts.GetByResourceGroupAsync( ResourceGroupName, Name); if (maxDelayDueToMissingFailovers > currentDelayDueToMissingFailovers && (databaseAccount.Id == null || databaseAccount.Id.Length == 0 || locationParameters.Locations.Count > databaseAccount.Inner.FailoverPolicies.Count)) { currentDelayDueToMissingFailovers += 5000; continue; } if (this.IsProvisioningStateFinal(databaseAccount.Inner.ProvisioningState)) { done = true; foreach (Models.Location location in databaseAccount.ReadableReplications) { if (!this.IsProvisioningStateFinal(location.ProvisioningState)) { done = false; break; } } } } List <Task> childTasks = new List <Task>(); childTasks.Add(this.privateEndpointConnections.CommitAndGetAllAsync(cancellationToken)); childTasks.Add(this.sqlDatabases.CommitAndGetAllAsync(cancellationToken)); childTasks.Add(this.mongoDBs.CommitAndGetAllAsync(cancellationToken)); childTasks.Add(this.cassandraKeyspaces.CommitAndGetAllAsync(cancellationToken)); childTasks.Add(this.gremlinDatabases.CommitAndGetAllAsync(cancellationToken)); childTasks.Add(this.tables.CommitAndGetAllAsync(cancellationToken)); await Task.WhenAll(childTasks); this.SetInner(databaseAccount.Inner); this.initializeFailover(); return(databaseAccount); }