public User CreateUser(string username, string password, string email, string passwordQuestion, string passwordAnswer, bool isApproved, object providerUserKey, out MembershipCreateStatus status)
        {
            using (ColorettaDataContext context = new ColorettaDataContext())
            {
                string em = email.Trim();
                string uname = username.Trim();
                string passwd = password.Trim();

                if (uname.Length < 3)
                {
                    status = MembershipCreateStatus.InvalidUserName;
                    return null;
                }
                if (context.Users.Where(u => u.Username.Equals(uname.ToUpper()) || u.Email.Equals(uname.ToUpper())).Any())
                {
                    status = MembershipCreateStatus.DuplicateUserName;
                    return null;
                }
                else if (context.Users.Where(u => u.Email.Equals(em.ToUpper()) || u.Email.Equals(uname.ToUpper())).Any())
                {
                    status = MembershipCreateStatus.DuplicateEmail;
                    return null;
                }

                try
                {
                    DateTime creationDate = DateTime.Now;
                    User user = new User
                            {
                                Username = username.ToUpper(),
                                Password = password,
                                Email = email,
                                Newsletter = true,
                                Created = creationDate,
                                Deleted = creationDate,
                                DisplayName = username
                            };
                    context.Users.InsertOnSubmit(user);
                    status = MembershipCreateStatus.Success;
                    context.SubmitChanges();

                    return user;
                }
                catch
                {
                    Debug.Fail("Unable to insert player into database.");
                    status = MembershipCreateStatus.UserRejected;
                    return null;
                }
            }
        }
예제 #2
0
 partial void UpdateUser(User instance);
예제 #3
0
 partial void DeleteUser(User instance);
예제 #4
0
 partial void InsertUser(User instance);