public async Task <int> Execute(IRegisterOdsInstanceModel instance, ApiMode mode, string userId, CloudOdsClaimSet cloudOdsClaimSet = null) { var instanceName = instance.NumericSuffix.Value.ToString(); var newInstance = new OdsInstanceRegistration { Name = instanceName, DatabaseName = _inferInstanceService.DatabaseName(instance.NumericSuffix.Value, mode), Description = instance.Description }; await _odsInstanceFirstTimeSetupService.CompleteSetup(newInstance, cloudOdsClaimSet, mode); await _identity.UserOdsInstanceRegistrations.AddAsync( new UserOdsInstanceRegistration { OdsInstanceRegistrationId = newInstance.Id, UserId = userId }); await _identity.SaveChangesAsync(); if (mode == ApiMode.YearSpecific) { _setCurrentSchoolYear.Execute(instanceName, mode, (short)instance.NumericSuffix.Value); } return(newInstance.Id); }