[4590] | 1 | using HeuristicLab.Services.Authentication.DataAccess;
|
---|
[4584] | 2 | using HeuristicLab.Services.Authentication.DataTransfer;
|
---|
| 3 |
|
---|
| 4 | namespace HeuristicLab.Services.Authentication
|
---|
| 5 | {
|
---|
| 6 | public class Convert
|
---|
| 7 | {
|
---|
| 8 |
|
---|
| 9 | #region User
|
---|
| 10 |
|
---|
[4588] | 11 | /// <summary>
|
---|
| 12 | /// converts data transfer object to data access objet
|
---|
| 13 | /// </summary>
|
---|
| 14 | /// <param name="source">data transfer object</param>
|
---|
| 15 | /// <returns>data access object</returns>
|
---|
[4584] | 16 | public static aspnet_User ToEntity(User source)
|
---|
| 17 | {
|
---|
| 18 | if (source == null) return null;
|
---|
[4588] | 19 | return new aspnet_User()
|
---|
| 20 | {
|
---|
[4590] | 21 | ApplicationId = source.ApplicationId,
|
---|
[4740] | 22 | UserId = source.Id,
|
---|
| 23 | UserName = source.Name,
|
---|
| 24 | //LoweredUserName = source.LoweredUserName,
|
---|
| 25 | //IsAnonymous = source.IsAnonymous,
|
---|
[4590] | 26 | LastActivityDate = source.LastActivityDate
|
---|
[4588] | 27 | };
|
---|
[4584] | 28 | }
|
---|
| 29 |
|
---|
[4740] | 30 | ///// <summary>
|
---|
| 31 | ///// converts data transfer object to data access objet
|
---|
| 32 | ///// </summary>
|
---|
| 33 | ///// <param name="source">data transfer object</param>
|
---|
| 34 | ///// <returns>data access object</returns>
|
---|
| 35 | //public static aspnet_Membership ToEntity(User source) {
|
---|
| 36 | // if (source == null) return null;
|
---|
| 37 | // return new aspnet_Membership() {
|
---|
| 38 | // ApplicationId = source.ApplicationId,
|
---|
| 39 | // UserId = source.Id,
|
---|
| 40 | // Password = source.Password,
|
---|
| 41 | // PasswordFormat = 1,
|
---|
| 42 | // PasswordSalt = source.PasswordSalt,
|
---|
| 43 | // Email = source.Email,
|
---|
| 44 | // IsApproved = source.IsApproved,
|
---|
| 45 | // IsLockedOut = source.IsLookedOut,
|
---|
| 46 | // CreateDate = source.CreateDate,
|
---|
| 47 | // LastLoginDate = source.LastLoginDate,
|
---|
| 48 | // LastPasswordChangedDate = source.LastPasswordChangeDate,
|
---|
| 49 | // LastLockoutDate = source.LastLockoutDate,
|
---|
| 50 | // FailedPasswordAttemptCount = 0,
|
---|
| 51 | // FailedPasswordAttemptWindowStart = new System.DateTime(1900, 01, 01),
|
---|
| 52 | // FailedPasswordAnswerAttemptCount = 0,
|
---|
| 53 | // FailedPasswordAnswerAttemptWindowStart = new System.DateTime(1900, 01, 01),
|
---|
| 54 | // Comment = source.Comment
|
---|
| 55 | // };
|
---|
| 56 | //}
|
---|
| 57 |
|
---|
[4588] | 58 | /// <summary>
|
---|
| 59 | /// converts data access object to data transfer object
|
---|
| 60 | /// </summary>
|
---|
| 61 | /// <param name="source">data access object</param>
|
---|
| 62 | /// <returns>data transfer object</returns>
|
---|
[4740] | 63 | public static User ToDataTransfer(aspnet_User userSource, aspnet_Membership membershipSource)
|
---|
[4584] | 64 | {
|
---|
[4740] | 65 | if (userSource == null || membershipSource == null) return null;
|
---|
[4588] | 66 | return new User()
|
---|
| 67 | {
|
---|
[4740] | 68 | ApplicationId = userSource.ApplicationId,
|
---|
| 69 | Id = userSource.UserId,
|
---|
| 70 | Name = userSource.UserName,
|
---|
| 71 | //LoweredUserName = userSource.LoweredUserName,
|
---|
| 72 | //IsAnonymous = userSource.IsAnonymous,
|
---|
| 73 | LastActivityDate = userSource.LastActivityDate,
|
---|
| 74 | Password = membershipSource.Password,
|
---|
| 75 | PasswordSalt = membershipSource.PasswordSalt,
|
---|
| 76 | Email = membershipSource.Email,
|
---|
| 77 | IsApproved = membershipSource.IsApproved,
|
---|
| 78 | IsLookedOut = membershipSource.IsApproved,
|
---|
| 79 | CreateDate = membershipSource.CreateDate,
|
---|
| 80 | LastLoginDate = membershipSource.LastLoginDate,
|
---|
| 81 | LastPasswordChangeDate = membershipSource.LastPasswordChangedDate,
|
---|
| 82 | LastLockoutDate = membershipSource.LastLockoutDate,
|
---|
| 83 | Comment = membershipSource.Comment
|
---|
[4588] | 84 | };
|
---|
[4584] | 85 | }
|
---|
| 86 |
|
---|
[4588] | 87 | /// <summary>
|
---|
| 88 | /// converts data transfer object to data access object
|
---|
| 89 | /// </summary>
|
---|
| 90 | /// <param name="source">data transfer object</param>
|
---|
| 91 | /// <param name="target">data access object</param>
|
---|
[4740] | 92 | public static void ToEntity(User source, aspnet_User userTarget, aspnet_Membership membershipTarget)
|
---|
[4588] | 93 | {
|
---|
[4740] | 94 | if ((source != null) && (userTarget != null) && (membershipTarget != null))
|
---|
[4588] | 95 | {
|
---|
[4740] | 96 | userTarget.ApplicationId = source.ApplicationId;
|
---|
| 97 | membershipTarget.ApplicationId = source.ApplicationId;
|
---|
| 98 | userTarget.UserId = source.Id;
|
---|
| 99 | membershipTarget.UserId = source.Id;
|
---|
| 100 | userTarget.UserName = source.Name;
|
---|
| 101 | userTarget.LoweredUserName = source.Name;
|
---|
| 102 | userTarget.IsAnonymous = false;
|
---|
| 103 | userTarget.LastActivityDate = source.LastActivityDate;
|
---|
| 104 | membershipTarget.Password = source.Password;
|
---|
| 105 | membershipTarget.PasswordFormat = 1;
|
---|
| 106 | membershipTarget.PasswordSalt = source.PasswordSalt;
|
---|
| 107 | membershipTarget.Email = source.Email;
|
---|
| 108 | membershipTarget.IsApproved = source.IsApproved;
|
---|
| 109 | membershipTarget.IsLockedOut = source.IsLookedOut;
|
---|
| 110 | membershipTarget.CreateDate = source.CreateDate;
|
---|
| 111 | membershipTarget.LastLoginDate = source.LastLoginDate;
|
---|
| 112 | membershipTarget.LastPasswordChangedDate = source.LastPasswordChangeDate;
|
---|
| 113 | membershipTarget.LastLockoutDate = source.LastLockoutDate;
|
---|
| 114 | membershipTarget.FailedPasswordAttemptCount = 0;
|
---|
| 115 | membershipTarget.FailedPasswordAttemptWindowStart = new System.DateTime(1900, 01, 01);
|
---|
| 116 | membershipTarget.FailedPasswordAnswerAttemptCount = 0;
|
---|
| 117 | membershipTarget.FailedPasswordAnswerAttemptWindowStart = new System.DateTime(1900, 01, 01);
|
---|
| 118 | membershipTarget.Comment = source.Comment;
|
---|
| 119 |
|
---|
[4588] | 120 | }
|
---|
| 121 |
|
---|
| 122 | }
|
---|
| 123 |
|
---|
| 124 |
|
---|
[4584] | 125 | #endregion
|
---|
| 126 |
|
---|
[4588] | 127 | #region Application
|
---|
| 128 |
|
---|
[4740] | 129 | ///// <summary>
|
---|
| 130 | ///// converts data transfer object to data access objet
|
---|
| 131 | ///// </summary>
|
---|
| 132 | ///// <param name="source">data transfer object</param>
|
---|
| 133 | ///// <returns>data access object</returns>
|
---|
| 134 | //public static aspnet_Application ToEntity(Application source)
|
---|
| 135 | //{
|
---|
| 136 | // if (source == null) return null;
|
---|
| 137 | // return new aspnet_Application()
|
---|
| 138 | // {
|
---|
| 139 | // ApplicationId = source.ApplicationId,
|
---|
| 140 | // ApplicationName = source.ApplicationName,
|
---|
| 141 | // LoweredApplicationName = source.LoweredApplicationName,
|
---|
| 142 | // Description = source.Description
|
---|
| 143 | // };
|
---|
| 144 | //}
|
---|
[4590] | 145 |
|
---|
[4740] | 146 | ///// <summary>
|
---|
| 147 | ///// converts data access object to data transfer object
|
---|
| 148 | ///// </summary>
|
---|
| 149 | ///// <param name="source">data access object</param>
|
---|
| 150 | ///// <returns>data transfer object</returns>
|
---|
| 151 | //public static Application ToDataTransfer(aspnet_Application source)
|
---|
| 152 | //{
|
---|
| 153 | // if (source == null) return null;
|
---|
| 154 | // return new Application()
|
---|
| 155 | // {
|
---|
| 156 | // ApplicationId = source.ApplicationId,
|
---|
| 157 | // ApplicationName = source.ApplicationName,
|
---|
| 158 | // LoweredApplicationName = source.LoweredApplicationName,
|
---|
| 159 | // Description = source.Description
|
---|
| 160 | // };
|
---|
| 161 | //}
|
---|
[4590] | 162 |
|
---|
[4740] | 163 | ///// <summary>
|
---|
| 164 | ///// converts data transfer object to data access object
|
---|
| 165 | ///// </summary>
|
---|
| 166 | ///// <param name="source">data transfer object</param>
|
---|
| 167 | ///// <param name="target">data access object</param>
|
---|
| 168 | //public static void ToEntity(Application source, aspnet_Application target)
|
---|
| 169 | //{
|
---|
| 170 | // if ((source != null) && (target != null))
|
---|
| 171 | // {
|
---|
| 172 | // target.ApplicationId = source.ApplicationId;
|
---|
| 173 | // target.ApplicationName = source.ApplicationName;
|
---|
| 174 | // target.LoweredApplicationName = source.LoweredApplicationName;
|
---|
| 175 | // target.Description = source.Description;
|
---|
| 176 | // }
|
---|
[4590] | 177 |
|
---|
[4740] | 178 | //}
|
---|
[4590] | 179 |
|
---|
[4588] | 180 | #endregion
|
---|
| 181 |
|
---|
| 182 | #region Membership
|
---|
| 183 |
|
---|
[4740] | 184 | ///// <summary>
|
---|
| 185 | ///// converts data transfer object to data access objet
|
---|
| 186 | ///// </summary>
|
---|
| 187 | ///// <param name="source">data transfer object</param>
|
---|
| 188 | ///// <returns>data access object</returns>
|
---|
| 189 | //public static aspnet_Membership ToEntity(Membership source)
|
---|
| 190 | //{
|
---|
| 191 | // if (source == null) return null;
|
---|
| 192 | // return new aspnet_Membership()
|
---|
| 193 | // {
|
---|
| 194 | // ApplicationId = source.ApplicationId,
|
---|
| 195 | // UserId = source.UserId,
|
---|
| 196 | // Password = source.Password,
|
---|
| 197 | // PasswordAnswer = source.PasswordAnswer,
|
---|
| 198 | // PasswordSalt = source.PasswordSalt,
|
---|
| 199 | // PasswordQuestion = source.PasswordQuestion,
|
---|
[4647] | 200 |
|
---|
[4740] | 201 | // Email = source.Email,
|
---|
| 202 | // LoweredEmail = source.LoweredEmail,
|
---|
| 203 | // IsApproved = source.IsApproved,
|
---|
| 204 | // IsLockedOut = source.IsLockedOut,
|
---|
| 205 | // CreateDate = source.CreateDate,
|
---|
| 206 | // LastLoginDate = source.LastLoginDate,
|
---|
| 207 | // LastPasswordChangedDate = source.LastPasswordChangedDate,
|
---|
| 208 | // LastLockoutDate = source.LastLockoutDate,
|
---|
| 209 | // Comment = source.Comment
|
---|
[4590] | 210 |
|
---|
[4647] | 211 |
|
---|
[4740] | 212 | // };
|
---|
| 213 | //}
|
---|
[4590] | 214 |
|
---|
[4740] | 215 | ///// <summary>
|
---|
| 216 | ///// converts data access object to data transfer object
|
---|
| 217 | ///// </summary>
|
---|
| 218 | ///// <param name="source">data access object</param>
|
---|
| 219 | ///// <returns>data transfer object</returns>
|
---|
| 220 | //public static Membership ToDataTransfer(aspnet_Membership source)
|
---|
| 221 | //{
|
---|
| 222 | // if (source == null) return null;
|
---|
| 223 | // return new Membership()
|
---|
| 224 | // {
|
---|
| 225 | // ApplicationId = source.ApplicationId,
|
---|
| 226 | // UserId = source.UserId,
|
---|
| 227 | // Password = source.Password,
|
---|
| 228 | // PasswordAnswer = source.PasswordAnswer,
|
---|
| 229 | // PasswordSalt = source.PasswordSalt,
|
---|
| 230 | // PasswordQuestion = source.PasswordQuestion,
|
---|
[4647] | 231 |
|
---|
[4740] | 232 | // Email = source.Email,
|
---|
| 233 | // LoweredEmail = source.LoweredEmail,
|
---|
| 234 | // IsApproved = source.IsApproved,
|
---|
| 235 | // IsLockedOut = source.IsLockedOut,
|
---|
| 236 | // CreateDate = source.CreateDate,
|
---|
| 237 | // LastLoginDate = source.LastLoginDate,
|
---|
| 238 | // LastPasswordChangedDate = source.LastPasswordChangedDate,
|
---|
| 239 | // LastLockoutDate = source.LastLockoutDate,
|
---|
| 240 | // Comment = source.Comment
|
---|
| 241 | // };
|
---|
| 242 | //}
|
---|
[4590] | 243 |
|
---|
[4740] | 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(Membership source, aspnet_Membership target)
|
---|
| 250 | //{
|
---|
| 251 | // if ((source != null) && (target != null))
|
---|
| 252 | // {
|
---|
| 253 | // target.ApplicationId = source.ApplicationId;
|
---|
| 254 | // target.UserId = source.UserId;
|
---|
| 255 | // target.Password = source.Password;
|
---|
| 256 | // target.PasswordAnswer = source.PasswordAnswer;
|
---|
| 257 | // target.PasswordSalt = source.PasswordSalt;
|
---|
| 258 | // target.PasswordQuestion = source.PasswordQuestion;
|
---|
[4647] | 259 |
|
---|
[4740] | 260 | // target.Email = source.Email;
|
---|
| 261 | // target.LoweredEmail = source.LoweredEmail;
|
---|
| 262 | // target.IsApproved = source.IsApproved;
|
---|
| 263 | // target.IsLockedOut = source.IsLockedOut;
|
---|
| 264 | // target.CreateDate = source.CreateDate;
|
---|
| 265 | // target.LastLoginDate = source.LastLoginDate;
|
---|
| 266 | // target.LastPasswordChangedDate = source.LastPasswordChangedDate;
|
---|
| 267 | // target.LastLockoutDate = source.LastLockoutDate;
|
---|
| 268 | // target.Comment = source.Comment;
|
---|
| 269 | // }
|
---|
[4590] | 270 |
|
---|
[4740] | 271 | //}
|
---|
[4590] | 272 |
|
---|
[4588] | 273 | #endregion
|
---|
| 274 |
|
---|
| 275 | #region Role
|
---|
| 276 |
|
---|
[4740] | 277 | ///// <summary>
|
---|
| 278 | ///// converts data transfer object to data access objet
|
---|
| 279 | ///// </summary>
|
---|
| 280 | ///// <param name="source">data transfer object</param>
|
---|
| 281 | ///// <returns>data access object</returns>
|
---|
| 282 | //public static aspnet_Role ToEntity(Role source)
|
---|
| 283 | //{
|
---|
| 284 | // if (source == null) return null;
|
---|
| 285 | // return new aspnet_Role()
|
---|
| 286 | // {
|
---|
| 287 | // ApplicationId = source.ApplicationId,
|
---|
| 288 | // RoleId = source.RoleId,
|
---|
| 289 | // RoleName = source.RoleName,
|
---|
| 290 | // LoweredRoleName = source.LoweredRoleName,
|
---|
| 291 | // Description = source.Description
|
---|
| 292 | // };
|
---|
| 293 | //}
|
---|
[4588] | 294 |
|
---|
[4740] | 295 | ///// <summary>
|
---|
| 296 | ///// converts data access object to data transfer object
|
---|
| 297 | ///// </summary>
|
---|
| 298 | ///// <param name="source">data access object</param>
|
---|
| 299 | ///// <returns>data transfer object</returns>
|
---|
| 300 | //public static Role ToDataTransfer(aspnet_Role source)
|
---|
| 301 | //{
|
---|
| 302 | // if (source == null) return null;
|
---|
| 303 | // return new Role()
|
---|
| 304 | // {
|
---|
| 305 | // ApplicationId = source.ApplicationId,
|
---|
| 306 | // RoleId = source.RoleId,
|
---|
| 307 | // RoleName = source.RoleName,
|
---|
| 308 | // LoweredRoleName = source.LoweredRoleName,
|
---|
| 309 | // Description = source.Description
|
---|
| 310 | // };
|
---|
| 311 | //}
|
---|
[4588] | 312 |
|
---|
[4740] | 313 | ///// <summary>
|
---|
| 314 | ///// converts data transfer object to data access object
|
---|
| 315 | ///// </summary>
|
---|
| 316 | ///// <param name="source">data transfer object</param>
|
---|
| 317 | ///// <param name="target">data access object</param>
|
---|
| 318 | //public static void ToEntity(Role source, aspnet_Role target)
|
---|
| 319 | //{
|
---|
| 320 | // if ((source != null) && (target != null))
|
---|
| 321 | // {
|
---|
| 322 | // target.ApplicationId = source.ApplicationId;
|
---|
| 323 | // target.RoleId = source.RoleId;
|
---|
| 324 | // target.RoleName = source.RoleName;
|
---|
| 325 | // target.LoweredRoleName = source.LoweredRoleName;
|
---|
| 326 | // target.Description = source.Description;
|
---|
| 327 | // }
|
---|
[4590] | 328 |
|
---|
[4740] | 329 | //}
|
---|
[4590] | 330 |
|
---|
[4588] | 331 | #endregion
|
---|
| 332 |
|
---|
[4584] | 333 | }
|
---|
| 334 | }
|
---|