private void SetData(Guid appId) { this.application = applicationRepository.Get(appId); if (this.application == null) { throw new Exception("No application found with id " + appId); } else if (this.application.Type != ApplicationType.DataGrid) { throw new Exception($"Application {appId} is expected to be of type {ApplicationType.DataGrid.ToString()} but is instead of type {this.application.Type.ToString()}"); } this.fields = fieldRepository.GetFieldsByApplication(appId); this.database = databaseRepository.Get(this.application.IDDatabase); if (this.database == null) { throw new Exception("No database found with id " + this.application.IDDatabase); } }