public void AdicionaUsuario(Usuario usuario) { using (var transacao = _sessao.BeginTransaction()) { _sessao.SaveOrUpdate(usuario); transacao.Commit(); } }
public override MembershipUser CreateUser(string username, string password, string email, string passwordQuestion, string passwordAnswer, bool isApproved, object providerUserKey, out MembershipCreateStatus status) { var args = new ValidatePasswordEventArgs(username, password, true); OnValidatingPassword(args); if (args.Cancel) { status = MembershipCreateStatus.InvalidPassword; return null; } if (RequiresUniqueEmail && GetUserNameByEmail(email) != string.Empty) { status = MembershipCreateStatus.DuplicateEmail; return null; } var user = GetUser(username, true); if (user == null) { var userObj = new Usuario { Nome = username, Login = username, Senha = GetMd5Hash(password), Email = email, Ativo = true }; //using (var usersContext = new UsersContext()) //{ _usuarioContexto.AdicionaUsuario(userObj); //} status = MembershipCreateStatus.Success; return GetUser(username, true); } status = MembershipCreateStatus.DuplicateUserName; return null; }