public async Task UpdateAsync(ServiceInstanceContext context, ServiceInstanceUpdateRequest request) { _logger.LogInformation("Updating instance {0} as service {1}.", context.InstanceId, request.ServiceId); var entity = await _context.ServiceInstances.FindAsync(context.InstanceId); if (entity == null) { throw new NotFoundException($"Instance '{context.InstanceId}' not found."); } if (request.ServiceId != entity.ServiceId) { throw new BadRequestException($"Cannot change service ID of instance '{context.InstanceId}' from '{entity.ServiceId}' to '{request.ServiceId}'."); } if (request.PlanId != null && request.PlanId != entity.PlanId) { var service = GetService(request.ServiceId); if (!service.PlanUpdateable) { throw new BadRequestException($"Service ID '{request.ServiceId}' does not allow changing the Plan ID."); } if (service.Plans.All(x => x.Id != request.PlanId)) { throw new BadRequestException($"Unknown plan ID '{request.PlanId}'."); } entity.PlanId = request.PlanId; } if (request.Parameters != null) { entity.Parameters = JsonConvert.SerializeObject(request.Parameters); } _context.Update(entity); await _context.SaveChangesAsync(); }
public Task UpdateAsync(ServiceInstanceContext context, ServiceInstanceUpdateRequest request) { throw new System.NotImplementedException(); }