Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
01/20/12 13:24:10 (12 years ago)
Author:
ascheibe
Message:

#1648

  • fixed user query ws methods
  • improved user view
File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/ClientUserManagement/HeuristicLab.Services.Access/3.3/AccessService.cs

    r7368 r7380  
    278278      DA.User accessUser = null;
    279279
    280       using (DA.ClientManagementDataContext context = new DA.ClientManagementDataContext()) {
    281         var query = from u in context.UserGroupBases.OfType<DA.User>()
    282                     where u.Id == userId
    283                     select u;
    284         if (query.Count() == 1) {
    285           accessUser = query.First();
    286         } else {
    287           //if the user is not in the access db at it
    288           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 
    297280      using (DA.ASPNETAuthenticationDataContext context = new DA.ASPNETAuthenticationDataContext()) {
    298281        var userQuery = from u in context.aspnet_Users
     
    311294      }
    312295
     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
    313315      if (aspUser == null || aspMembership == null || accessUser == null) {
    314         //TODO: error handling
    315         return null;
     316        throw new Exception("User with id " + userId + " not found.");
    316317      } else {
    317318        return Convert.ToDto(accessUser, aspUser, aspMembership);
     
    332333      }
    333334
    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          }
    348351        }
    349352      }
    350353
    351354      if (aspUser == null || accessUser == null) {
    352         //TODO: error handling
    353         return null;
     355        throw new Exception("User with id " + userId + " not found.");
    354356      } else {
    355357        return Convert.ToDto(accessUser, aspUser);
     
    365367      List<Guid> accessUserGuids = null;
    366368
    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;
    370372        accessUserGuids = query.ToList();
    371373      }
    372 
    373374      return accessUserGuids.Select(x => BuildLightweightUserDto(x));
    374375    }
     
    377378      List<Guid> accessUserGuids = null;
    378379
    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;
    382383        accessUserGuids = query.ToList();
    383384      }
Note: See TracChangeset for help on using the changeset viewer.