Ejemplo n.º 1
0
 public void CreateUser(AccountManagement.User user)
 {
     Contract.Requires(user != null && user.Id.IsNew);
     using (var db = new THCard()) {
         using (var transaction = new TransactionScope()) {
             var dbUser = new User();
             dbUser.FirstName = user.FullName.FirstName.ToString();
             dbUser.MiddleName = user.FullName.MiddleName.ToString();
             dbUser.LastName = user.FullName.FamilyName.ToString();
             db.Users.Add(dbUser);
             db.SaveChanges();
             transaction.Complete();
             user.Id = new UserId(dbUser.UserId);
         }
     }
 }
Ejemplo n.º 2
0
 private static AccountManagement.User MapToUser(User dbUser)
 {
     var fullName = new FullName(new Name(dbUser.LastName), new GivenNames(dbUser.FirstName, dbUser.MiddleName));
     var user = new AccountManagement.User(new UserId(dbUser.UserId), fullName);
     return user;
 }