Esempio n. 1
0
 private User TranslateUserEntityToUser(UserEntity userEntity)
 {
     User user = new User()
     {
         UserId = userEntity.UserId,
         Email = userEntity.Email,
         Name = userEntity.Name,
     };
     return user;
 }
Esempio n. 2
0
        public int CreateNewUser(User user)
        {
            using (DobbermanEntities context = new DobbermanEntities())
            {
                // find out if user already exists by its email
                UserEntity validateUser = (from p
                                             in context.Users
                                         where p.Email == user.Email
                                         select p).FirstOrDefault();
                if (!(validateUser == null)) return validateUser.UserId;

                UserEntity userEntity = new UserEntity()
                {
                    Email = user.Email,
                    Name = user.Name,
                };
                context.AddToUsers(userEntity);
                context.SaveChanges();
                return userEntity.UserId;
            }
        }