Free cookie consent management tool by TermsFeed Policy Generator

Changeset 4995


Ignore:
Timestamp:
11/29/10 23:29:50 (13 years ago)
Author:
jwolfing
Message:

#1196 added methods in the serviceclient for Roles, Applications and Users

Location:
branches/UserManagement
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/UserManagement/HeuristicLab.Services.Authentication.ServiceClients/AuthenticationClient.cs

    r4983 r4995  
    4646        private AuthenticationClient()
    4747        {
    48             applications = CallService<Application[]>(s => s.GetApplications()).OrderBy(x => x.Name);
     48            applications = GetApplications();
    4949            users = CallService<User[]>(s => s.GetAllUsers()).OrderBy(x => x.Name);
    5050            roles = CallService<Role[]>(s => s.GetAllRoles()).OrderBy(x => x.Name);
     
    153153
    154154
    155         #region Application methods
     155      #region Application methods
    156156
    157157        public Application GetApplication(Guid applicationId)
     
    168168        }
    169169
     170
     171        public Guid AddApplication(Application application) {
     172          try {
     173            return CallService<Guid>(s => s.AddApplication(application));
     174          }
     175          catch (Exception ex) {
     176            // Todo Errorhandling
     177            return Guid.Empty;
     178          }
     179        }
     180
     181        public bool DeleteApplication(Guid id) {
     182          try {
     183            return CallService<bool>(s => s.DeleteApplication(id));
     184          }
     185          catch (Exception ex) {
     186            // Todo Errorhandling
     187            return false;
     188          }
     189        }
     190
     191        public IEnumerable<Application> GetApplications() {
     192          try {
     193            return CallService<IEnumerable<Application>>(s => s.GetApplications());
     194          }
     195          catch (Exception ex) {
     196            // Todo Errorhandling
     197            return null;
     198
     199          }
     200        }
     201
     202
     203        public bool UpdateApplication(Application application) {
     204          try {
     205            return CallService<bool>(s => s.UpdateApplication(application));
     206          }
     207          catch (Exception ex) {
     208            // Todo Errorhandling
     209            return false;
     210          }
     211        }
     212
    170213 
    171214        #endregion
    172215
    173 
    174         //public static void Main() {
     216      #region Role Methods
     217
     218      public Role GetRole (Guid Id) {
     219        try {
     220          return CallService<Role>(s => s.GetRole(Id));
     221        }
     222        catch (Exception ex) {
     223          // todo Errorhandling
     224          return null;
     225        }
     226      }
     227
     228      public IEnumerable<Role> GetAllRoles() {
     229        try {
     230          return CallService<IEnumerable<Role>>(s => s.GetAllRoles());
     231        }
     232        catch (Exception ex) {
     233          // Todo Errorhandling
     234          return null;
     235        }
     236      }
     237
     238      public IEnumerable<Role> GetRoles(Guid applicationId) {
     239        try {
     240          return CallService<IEnumerable<Role>>(s => s.GetRoles(applicationId));
     241        }
     242        catch (Exception ex) {
     243          // Todo Errorhandling
     244          return null;
     245        }
     246      }
     247
     248      public Guid AddRole(Role role) {
     249        try {
     250          return CallService<Guid>(s => s.AddRole(role));
     251        }
     252        catch (Exception ex) {
     253          // Todo Errorhandling
     254          return Guid.Empty;
     255
     256        }
     257      }
     258
     259      public bool UpdateRole(Role role) {
     260        try {
     261          return CallService<bool>(s => s.UpdateRole(role));
     262        }
     263        catch (Exception ex) {
     264          // Todo Errorhandling
     265          return false;
     266        }
     267      }
     268
     269
     270      public bool DeleteRole(Guid Id) {
     271        try {
     272          return CallService<bool>(s => s.DeleteRole(Id));
     273        }
     274        catch (Exception ex) {
     275          // Todo Errorhandling
     276          return false;
     277        }
     278      }
     279
     280
     281      #endregion
     282
     283      #region User methods
     284
     285      public User GetUser(Guid Id) {
     286        try {
     287          return CallService<User>(s => s.GetUser(Id));
     288        }
     289        catch (Exception ex) {
     290          // Todo Errorhandling
     291          return null;
     292        }
     293      }
     294
     295      public IEnumerable<User> GetAllUsers() {
     296        try {
     297          return CallService<IEnumerable<User>>(s => s.GetAllUsers());
     298        }
     299        catch (Exception ex) {
     300          // Todo Errorhandling
     301          return null;
     302        }
     303      }
     304
     305      public IEnumerable<User> GetUsers(Guid applicationId) {
     306        try {
     307          return CallService<IEnumerable<User>>(s => s.GetUsers(applicationId));
     308        }
     309        catch (Exception ex) {
     310          // Todo Errorhandling
     311          return null;
     312        }
     313      }
     314
     315      public Guid AddUser(User user) {
     316        try {
     317          return CallService<Guid>(s => s.AddUser(user));
     318        }
     319        catch (Exception ex) {
     320          // Todo Errorhandling
     321          return Guid.Empty;
     322        }
     323      }
     324
     325      public bool UpdateUser(User user) {
     326        try {
     327          return CallService<bool>(s => s.UpdateUser(user));
     328        }
     329        catch (Exception ex) {
     330          // Todo Errorhandling
     331          return false;
     332        }
     333      }
     334
     335
     336      public bool AddUserToRole(Guid roleId, Guid userId) {
     337        try {
     338          return CallService<bool>(s => s.AddUserToRole(roleId, userId);
     339        }
     340        catch (Exception ex) {
     341          // Todo Errorhandling
     342          return false;
     343        }
     344      }
     345
     346
     347      public IEnumerable<Guid> GetUsersInRole(Guid roleId) {
     348        try {
     349          return CallService<IEnumerable<Guid>>(s => s.GetUsersInRole(roleId));
     350        }
     351        catch (Exception ex) {
     352          // Todo Errorhandling
     353          return null;
     354        }
     355      }
     356
     357
     358      #endregion
     359
     360
     361
     362
     363      //public static void Main() {
    175364        //    AuthenticationServiceClient auth = new AuthenticationServiceClient();
    176365
Note: See TracChangeset for help on using the changeset viewer.