示例#1
0
 partial void DeleteUser(User instance);
示例#2
0
 partial void InsertUser(User instance);
示例#3
0
 partial void UpdateUser(User instance);
示例#4
0
 public override MembershipUser CreateUser(string username, string password, string email, string passwordQuestion, string passwordAnswer, bool isApproved, object providerUserKey, out MembershipCreateStatus status)
 {
     using (Data.contentDataContext context = new Data.contentDataContext())
     {
         try
         {
             if (context.Users.Where(p => p.Name == username).Count() > 0)
             {
                 status = MembershipCreateStatus.DuplicateUserName;
                 return null;
             }
             Data.User user = new Data.User()
             {
                 Name = username,
                 Created = DateTime.Now,
                 LastModified = DateTime.Now,
                 Email = email,
                 Password = Hash.HashPassword(password)
             };
             //TODO: Checks before inserting
             context.Users.InsertOnSubmit(user);
             context.SubmitChanges();
             status = MembershipCreateStatus.Success;
             var cabUser = GetUser(user);
             HttpContext.Current.Cache.Add(cabUser.UserName, cabUser, null,
                 System.Web.Caching.Cache.NoAbsoluteExpiration, FormsAuthentication.Timeout,
                 System.Web.Caching.CacheItemPriority.Default, null);
             return cabUser;
         }
         catch (Exception ex)
         {
             Elmah.ErrorLog.GetDefault(null).Log(new Elmah.Error(ex));
             status = MembershipCreateStatus.ProviderError;
         }
     }
     return null;
 }