- Timestamp:
- 01/20/12 13:24:10 (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/ClientUserManagement/HeuristicLab.Services.Access/3.3/AccessService.cs
r7368 r7380 278 278 DA.User accessUser = null; 279 279 280 using (DA.ClientManagementDataContext context = new DA.ClientManagementDataContext()) {281 var query = from u in context.UserGroupBases.OfType<DA.User>()282 where u.Id == userId283 select u;284 if (query.Count() == 1) {285 accessUser = query.First();286 } else {287 //if the user is not in the access db at it288 DA.User user = new DA.User();289 user.Id = userId;290 user.FullName = "Not set";291 context.UserGroupBases.InsertOnSubmit(user);292 context.SubmitChanges();293 accessUser = user;294 }295 }296 297 280 using (DA.ASPNETAuthenticationDataContext context = new DA.ASPNETAuthenticationDataContext()) { 298 281 var userQuery = from u in context.aspnet_Users … … 311 294 } 312 295 296 if (aspUser == null || aspMembership == null) { 297 using (DA.ClientManagementDataContext context = new DA.ClientManagementDataContext()) { 298 var query = from u in context.UserGroupBases.OfType<DA.User>() 299 where u.Id == userId 300 select u; 301 if (query.Count() == 1) { 302 accessUser = query.First(); 303 } else { 304 //if the user is not in the access db add it (this makes it easy to upgrade with an existing asp.net authentication db) 305 DA.User user = new DA.User(); 306 user.Id = userId; 307 user.FullName = "Not set"; 308 context.UserGroupBases.InsertOnSubmit(user); 309 context.SubmitChanges(); 310 accessUser = user; 311 } 312 } 313 } 314 313 315 if (aspUser == null || aspMembership == null || accessUser == null) { 314 //TODO: error handling 315 return null; 316 throw new Exception("User with id " + userId + " not found."); 316 317 } else { 317 318 return Convert.ToDto(accessUser, aspUser, aspMembership); … … 332 333 } 333 334 334 using (DA.ClientManagementDataContext context = new DA.ClientManagementDataContext()) { 335 var query = from u in context.UserGroupBases.OfType<DA.User>() 336 where u.Id == userId 337 select u; 338 if (query.Count() == 1) { 339 accessUser = query.First(); 340 } else { 341 //if the user is not in the access db at it 342 DA.User user = new DA.User(); 343 user.Id = userId; 344 user.FullName = "Not set"; 345 context.UserGroupBases.InsertOnSubmit(user); 346 context.SubmitChanges(); 347 accessUser = user; 335 if (aspUser != null) { 336 using (DA.ClientManagementDataContext context = new DA.ClientManagementDataContext()) { 337 var query = from u in context.UserGroupBases.OfType<DA.User>() 338 where u.Id == userId 339 select u; 340 if (query.Count() == 1) { 341 accessUser = query.First(); 342 } else { 343 //if the user is not in the access db add it (this makes it easy to upgrade with an existing asp.net authentication db) 344 DA.User user = new DA.User(); 345 user.Id = userId; 346 user.FullName = "Not set"; 347 context.UserGroupBases.InsertOnSubmit(user); 348 context.SubmitChanges(); 349 accessUser = user; 350 } 348 351 } 349 352 } 350 353 351 354 if (aspUser == null || accessUser == null) { 352 //TODO: error handling 353 return null; 355 throw new Exception("User with id " + userId + " not found."); 354 356 } else { 355 357 return Convert.ToDto(accessUser, aspUser); … … 365 367 List<Guid> accessUserGuids = null; 366 368 367 using (DA. ClientManagementDataContext context = new DA.ClientManagementDataContext()) {368 var query = from u in context. UserGroupBases.OfType<DA.User>()369 select u. Id;369 using (DA.ASPNETAuthenticationDataContext context = new DA.ASPNETAuthenticationDataContext()) { 370 var query = from u in context.aspnet_Users 371 select u.UserId; 370 372 accessUserGuids = query.ToList(); 371 373 } 372 373 374 return accessUserGuids.Select(x => BuildLightweightUserDto(x)); 374 375 } … … 377 378 List<Guid> accessUserGuids = null; 378 379 379 using (DA. ClientManagementDataContext context = new DA.ClientManagementDataContext()) {380 var query = from u in context. UserGroupBases.OfType<DA.User>()381 select u. Id;380 using (DA.ASPNETAuthenticationDataContext context = new DA.ASPNETAuthenticationDataContext()) { 381 var query = from u in context.aspnet_Users 382 select u.UserId; 382 383 accessUserGuids = query.ToList(); 383 384 }
Note: See TracChangeset
for help on using the changeset viewer.