- Timestamp:
- 10/10/10 13:20:18 (14 years ago)
- Location:
- branches/UserManagement/HeuristicLab.Services.Authentication
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/UserManagement/HeuristicLab.Services.Authentication/AuthenticationService.cs
r4588 r4590 2 2 using System.Collections.Generic; 3 3 using System.Linq; 4 using System.Text;5 4 using System.ServiceModel; 6 5 using HeuristicLab.Services.Authentication.DataTransfer; … … 14 13 { 15 14 #region User 16 public DataTransfer.User GetUser(Guid UserId) 15 16 public DataTransfer.User GetUser(Guid id) 17 17 { 18 18 … … 22 22 23 23 var User = from item in UserTable 24 where item.UserId == UserId24 where item.UserId == id 25 25 select item; 26 26 return Convert.ToDataTransfer((aspnet_User)User); … … 48 48 return UserList; 49 49 } 50 51 public void InsertUser(User user) 50 public bool InsertUser(User user) 52 51 { 53 52 // insert user 54 53 if (user != null) 55 54 { 56 57 58 59 55 using (UserManagementDataContext db = new UserManagementDataContext()) 60 56 { 61 aspnet_User userDa = Convert.ToEntity(user); 62 db.aspnet_Users.InsertOnSubmit(userDa); 63 db.SubmitChanges(); 57 try 58 { 59 aspnet_User userDa = Convert.ToEntity(user); 60 db.aspnet_Users.InsertOnSubmit(userDa); 61 db.SubmitChanges(); 62 } 63 catch (Exception e) 64 { 65 return false; 66 } 64 67 } 68 return true; 69 } 70 return false; 71 } 72 public bool DeleteUser(Guid id) 73 { 65 74 66 } 75 return false; 76 } 77 public bool UpdateUser(User user) 78 { 79 return false; 67 80 } 68 81 69 public void DeleteUser(User user) 70 { 71 if (user != null) 72 { 82 #endregion 73 83 74 84 85 #region Role 75 86 87 public Role GetRole(Guid id) 88 { 89 Role role = new Role(); 90 // ... 91 92 return role; 93 } 94 public IEnumerable<Role> GetRoles() 95 { 96 List<Role> RoleList = new List<Role>(); 97 98 using (UserManagementDataContext db = new UserManagementDataContext()) 99 { 100 Table<aspnet_Role> RoleTable = db.GetTable<aspnet_Role>(); 101 102 var Roles = from item in RoleTable 103 select item; 104 foreach (var Role in Roles) 105 { 106 RoleList.Add(Convert.ToDataTransfer((aspnet_Role)Role)); 107 } 108 } 109 110 return RoleList; 111 } 112 public bool InsertRole(Role role) 113 { 114 if (role != null) 115 { 76 116 using (UserManagementDataContext db = new UserManagementDataContext()) 77 117 { 78 79 // membership 80 // profile 81 // users per role 82 // personalization per role 83 84 //////////////// 85 86 // servie mit id aufrufen, id mit datacontext holen und dann löschen ... 87 88 db.SubmitChanges(); 118 try 119 { 120 aspnet_Role roleDa = Convert.ToEntity(role); 121 db.aspnet_Roles.InsertOnSubmit(roleDa); 122 db.SubmitChanges(); 123 } 124 catch (Exception e) 125 { 126 return false; 127 } 89 128 } 90 129 return true; 91 130 } 131 return false; 132 } 133 public bool UpdateRole(Role role) 134 { 135 return false; 136 } 137 public bool DeleteRole(Guid id) 138 { 139 return false; 140 } 141 public bool AddRoleToUser(Guid roleId, Guid userId) 142 { 143 return false; 144 } 145 public bool RemoveRoleFromUser(Guid roleId, Guid userId) 146 { 147 return false; 148 } 149 public IEnumerable<Role> GetRolesForUser(Guid userId) 150 { 151 List<Role> roles = new List<Role>(); 152 return roles; 92 153 } 93 154 … … 95 156 } 96 157 } 158 -
branches/UserManagement/HeuristicLab.Services.Authentication/Convert.cs
r4588 r4590 1 using System; 2 using System.Collections.Generic; 3 using System.Linq; 4 using System.Text; 5 using HeuristicLab.Services.Authentication.DataAccess; 1 using HeuristicLab.Services.Authentication.DataAccess; 6 2 using HeuristicLab.Services.Authentication.DataTransfer; 7 3 … … 23 19 return new aspnet_User() 24 20 { 21 ApplicationId = source.ApplicationId, 25 22 UserId = source.UserId, 26 23 UserName = source.UserName, 27 LastActivityDate = source.LastActivityDate, 28 ApplicationId = source.ApplicationId, 24 LoweredUserName = source.LoweredUserName, 25 IsAnonymous = source.IsAnonymous, 26 LastActivityDate = source.LastActivityDate 29 27 }; 30 28 } … … 40 38 return new User() 41 39 { 42 UserName = source.UserName 40 ApplicationId = source.ApplicationId, 41 UserId = source.UserId, 42 UserName = source.UserName, 43 LoweredUserName = source.LoweredUserName, 44 IsAnonymous = source.IsAnonymous, 45 LastActivityDate = source.LastActivityDate 43 46 }; 44 47 } … … 53 56 if ((source != null) && (target != null)) 54 57 { 58 target.ApplicationId = source.ApplicationId; 59 target.UserId = source.UserId; 55 60 target.UserName = source.UserName; 56 } 57 58 } 59 60 61 #endregion 62 61 target.LoweredUserName = source.LoweredUserName; 62 target.IsAnonymous = source.IsAnonymous; 63 target.LastActivityDate = source.LastActivityDate; 64 } 65 66 } 67 68 69 #endregion 63 70 64 71 #region Application 65 72 73 /// <summary> 74 /// converts data transfer object to data access objet 75 /// </summary> 76 /// <param name="source">data transfer object</param> 77 /// <returns>data access object</returns> 78 public static aspnet_Application ToEntity(Application source) 79 { 80 if (source == null) return null; 81 return new aspnet_Application() 82 { 83 ApplicationId = source.ApplicationId, 84 ApplicationName = source.ApplicationName, 85 LoweredApplicationName = source.LoweredApplicationName, 86 Description = source.Description 87 }; 88 } 89 90 /// <summary> 91 /// converts data access object to data transfer object 92 /// </summary> 93 /// <param name="source">data access object</param> 94 /// <returns>data transfer object</returns> 95 public static Application ToDataTransfer(aspnet_Application source) 96 { 97 if (source == null) return null; 98 return new Application() 99 { 100 ApplicationId = source.ApplicationId, 101 ApplicationName = source.ApplicationName, 102 LoweredApplicationName = source.LoweredApplicationName, 103 Description = source.Description 104 }; 105 } 106 107 /// <summary> 108 /// converts data transfer object to data access object 109 /// </summary> 110 /// <param name="source">data transfer object</param> 111 /// <param name="target">data access object</param> 112 public static void ToEntity(Application source, aspnet_Application target) 113 { 114 if ((source != null) && (target != null)) 115 { 116 target.ApplicationId = source.ApplicationId; 117 target.ApplicationName = source.ApplicationName; 118 target.LoweredApplicationName = source.LoweredApplicationName; 119 target.Description = source.Description; 120 } 121 122 } 123 66 124 #endregion 67 125 68 126 #region Membership 69 127 128 /// <summary> 129 /// converts data transfer object to data access objet 130 /// </summary> 131 /// <param name="source">data transfer object</param> 132 /// <returns>data access object</returns> 133 public static aspnet_Membership ToEntity(Membership source) 134 { 135 if (source == null) return null; 136 return new aspnet_Membership() 137 { 138 ApplicationId = source.ApplicationId, 139 UserId = source.UserId, 140 Password = source.Password, 141 Email = source.Email, 142 LoweredEmail = source.LoweredEmail, 143 IsApproved = source.IsApproved, 144 IsLockedOut = source.IsLockedOut, 145 CreateDate = source.CreateDate, 146 LastLoginDate = source.LastLoginDate, 147 LastPasswordChangedDate = source.LastPasswordChangedDate, 148 LastLockoutDate = source.LastLockoutDate, 149 Comment = source.Comment 150 151 }; 152 } 153 154 /// <summary> 155 /// converts data access object to data transfer object 156 /// </summary> 157 /// <param name="source">data access object</param> 158 /// <returns>data transfer object</returns> 159 public static Membership ToDataTransfer(aspnet_Membership source) 160 { 161 if (source == null) return null; 162 return new Membership() 163 { 164 ApplicationId = source.ApplicationId, 165 UserId = source.UserId, 166 Password = source.Password, 167 Email = source.Email, 168 LoweredEmail = source.LoweredEmail, 169 IsApproved = source.IsApproved, 170 IsLockedOut = source.IsLockedOut, 171 CreateDate = source.CreateDate, 172 LastLoginDate = source.LastLoginDate, 173 LastPasswordChangedDate = source.LastPasswordChangedDate, 174 LastLockoutDate = source.LastLockoutDate, 175 Comment = source.Comment 176 }; 177 } 178 179 /// <summary> 180 /// converts data transfer object to data access object 181 /// </summary> 182 /// <param name="source">data transfer object</param> 183 /// <param name="target">data access object</param> 184 public static void ToEntity(Membership source, aspnet_Membership target) 185 { 186 if ((source != null) && (target != null)) 187 { 188 target.ApplicationId = source.ApplicationId; 189 target.UserId = source.UserId; 190 target.Password = source.Password; 191 target.Email = source.Email; 192 target.LoweredEmail = source.LoweredEmail; 193 target.IsApproved = source.IsApproved; 194 target.IsLockedOut = source.IsLockedOut; 195 target.CreateDate = source.CreateDate; 196 target.LastLoginDate = source.LastLoginDate; 197 target.LastPasswordChangedDate = source.LastPasswordChangedDate; 198 target.LastLockoutDate = source.LastLockoutDate; 199 target.Comment = source.Comment; 200 } 201 202 } 203 70 204 #endregion 71 205 72 206 #region Role 73 207 74 #endregion 75 76 #region User 208 /// <summary> 209 /// converts data transfer object to data access objet 210 /// </summary> 211 /// <param name="source">data transfer object</param> 212 /// <returns>data access object</returns> 213 public static aspnet_Role ToEntity(Role source) 214 { 215 if (source == null) return null; 216 return new aspnet_Role() 217 { 218 ApplicationId = source.ApplicationId, 219 RoleId = source.RoleId, 220 RoleName = source.RoleName, 221 LoweredRoleName = source.LoweredRoleName, 222 Description = source.Description 223 }; 224 } 225 226 /// <summary> 227 /// converts data access object to data transfer object 228 /// </summary> 229 /// <param name="source">data access object</param> 230 /// <returns>data transfer object</returns> 231 public static Role ToDataTransfer(aspnet_Role source) 232 { 233 if (source == null) return null; 234 return new Role() 235 { 236 ApplicationId = source.ApplicationId, 237 RoleId = source.RoleId, 238 RoleName = source.RoleName, 239 LoweredRoleName = source.LoweredRoleName, 240 Description = source.Description 241 }; 242 } 243 244 /// <summary> 245 /// converts data transfer object to data access object 246 /// </summary> 247 /// <param name="source">data transfer object</param> 248 /// <param name="target">data access object</param> 249 public static void ToEntity(Role source, aspnet_Role target) 250 { 251 if ((source != null) && (target != null)) 252 { 253 target.ApplicationId = source.ApplicationId; 254 target.RoleId = source.RoleId; 255 target.RoleName = source.RoleName; 256 target.LoweredRoleName = source.LoweredRoleName; 257 target.Description = source.Description; 258 } 259 260 } 77 261 78 262 #endregion -
branches/UserManagement/HeuristicLab.Services.Authentication/Interfaces/IAuthenticationService.cs
r4588 r4590 1 1 using System; 2 2 using System.Collections.Generic; 3 using System.Linq;4 using System.Text;5 3 using HeuristicLab.Services.Authentication.DataTransfer; 6 4 using System.ServiceModel; … … 13 11 { 14 12 #region User 13 15 14 [OperationContract] 16 15 User GetUser(Guid id); … … 20 19 21 20 [OperationContract] 22 void InsertUser(User user); 21 bool InsertUser(User user); 22 23 [OperationContract] 24 bool DeleteUser(Guid id); 25 26 [OperationContract] 27 bool UpdateUser(User user); 28 23 29 #endregion 24 30 31 #region Role 32 33 [OperationContract] 34 Role GetRole(Guid id); 35 36 [OperationContract] 37 IEnumerable<Role> GetRoles(); 38 39 [OperationContract] 40 bool InsertRole(Role role); 41 42 [OperationContract] 43 bool UpdateRole(Role role); 44 45 [OperationContract] 46 bool DeleteRole(Guid id); 47 48 [OperationContract] 49 bool AddRoleToUser(Guid roleId, Guid userId); 50 51 [OperationContract] 52 bool RemoveRoleFromUser(Guid roleId, Guid userId); 53 54 [OperationContract] 55 IEnumerable<Role> GetRolesForUser(Guid userId); 56 57 #endregion 25 58 } 26 59 }
Note: See TracChangeset
for help on using the changeset viewer.