public int AdicionaMorador(moradores morador)
        {
            try
            {

                conservadoraEntities model = Conexao.getInstance();
                IQueryable<moradores> i = from p in model.moradores select p;
                IEnumerable<moradores> max = i.OrderBy(p => p.idmoradores);

                if (max.Count() > 0)
                    morador.idmoradores = max.Last().idmoradores == null ? 1 : max.Last().idmoradores + 1;
                else
                    morador.idmoradores = 1;

                model.AddTomoradores(morador);

                model.SaveChanges();

                RegisterModel rm = new RegisterModel();
                rm.UserName = morador.login;
                rm.Password = morador.cpf;
                rm.Email = morador.email;

                AccountMembershipService ac = new AccountMembershipService();
                ac.CreateUser(rm.UserName, rm.Password, rm.Email);

                return morador.idmoradores;
            }
            catch (Exception e)
            {
                return -1;
            }
        }
 public bool ClearPassword(moradores morador)
 {
     RegisterModel rm = new RegisterModel();
     rm.UserName = morador.login;
     rm.Password = morador.cpf;
     rm.Email = morador.email;
     AccountMembershipService ac = new AccountMembershipService();
     return ac.ResertarSenha(rm.UserName, rm.Password);
 }
        public bool ClearPassword(moradores morador)
        {
            RegisterModel rm = new RegisterModel();

            rm.UserName = morador.login;
            rm.Password = morador.cpf;
            rm.Email    = morador.email;
            AccountMembershipService ac = new AccountMembershipService();

            return(ac.ResertarSenha(rm.UserName, rm.Password));
        }
        public int AdicionaMorador(moradores morador)
        {
            try
            {
                conservadoraEntities    model = Conexao.getInstance();
                IQueryable <moradores>  i     = from p in model.moradores select p;
                IEnumerable <moradores> max   = i.OrderBy(p => p.idmoradores);

                if (max.Count() > 0)
                {
                    morador.idmoradores = max.Last().idmoradores == null ? 1 : max.Last().idmoradores + 1;
                }
                else
                {
                    morador.idmoradores = 1;
                }

                model.AddTomoradores(morador);

                model.SaveChanges();

                RegisterModel rm = new RegisterModel();
                rm.UserName = morador.login;
                rm.Password = morador.cpf;
                rm.Email    = morador.email;

                AccountMembershipService ac = new AccountMembershipService();
                ac.CreateUser(rm.UserName, rm.Password, rm.Email);


                return(morador.idmoradores);
            }
            catch (Exception e)
            {
                return(-1);
            }
        }