Exemple #1
0
        private void PopulateDB()
        {
            var firstUser = new DB.User {
                Name = "First", Email = "*****@*****.**"
            };
            var secondUser = new DB.User {
                Name = "Second", Email = "*****@*****.**"
            };

            dataContext.Users.InsertOnSubmit(firstUser);
            dataContext.Users.InsertOnSubmit(secondUser);

            var wishes = new List <DB.Wish> {
                new DB.Wish {
                    Name = "First wish", Description = "1st", Created = DateTime.Now, User = firstUser
                },
                new DB.Wish {
                    Name = "Second wish", Description = "2nd", Created = DateTime.Now, User = secondUser
                }
            };

            dataContext.Wishes.InsertAllOnSubmit(wishes);

            dataContext.SubmitChanges();
            firstUserId  = firstUser.UserId;
            secondUserId = secondUser.UserId;
        }
        private void PopulateDB()
        {
            var firstUser = new DB.User {
                Name = "First", Email = "*****@*****.**"
            };
            var secondUser = new DB.User {
                Name = "Second", Email = "*****@*****.**"
            };

            dataContext.Users.InsertOnSubmit(firstUser);
            dataContext.Users.InsertOnSubmit(secondUser);

            dataContext.SubmitChanges();
        }
Exemple #3
0
        public User CreateUser(User user)
        {
            //MembershipCreateStatus createStatus;
            //MembershipUser membershipUser = membership.CreateUser( user.Name, user.Password, user.Email, null, null, false, out createStatus );

            //if (createStatus == MembershipCreateStatus.Success)
            //{

            if (!UsernameIsUnique(user.Name))
            {
                throw new InvalidOperationException("A user with that name already exists!");
            }


            var salt         = CreateSalt(user);
            var passwordHash = GetHash(user.Password, salt);

            var newUser = new RepData.User
            {
                Name           = user.Name,
                Email          = user.Email,
                NotifyOnChange = user.NotifyOnChange,
                ApprovalTicket = Guid.NewGuid(),
                PasswordHash   = passwordHash,
                Salt           = salt
            };

            //try
            //{
            var dataContext = GetWriteDataContext();

            dataContext.Users.InsertOnSubmit(newUser);
            dataContext.SubmitChanges();


            var createdUser = user.Clone();

            createdUser.Id = newUser.UserId;
            return(createdUser);
            //}
            //    catch (Exception)
            //    {
            //        membership.DeleteUser( membershipUser.UserName );
            //        throw;
            //    }
            //}

            //throw new InvalidOperationException( "Could not register user: " + createStatus );
        }