public void ForgetPassword(string email) { var newPassword = "******" + new Random(1000).Next(); string Body = System.IO.File.ReadAllText(HostingEnvironment.MapPath("~/Template/ForgetMail.html")); Body = Body.Replace("{{SENHA}}", newPassword); using (_db = new ProvaNetEntities()) { _db.Configuration.ProxyCreationEnabled = false; var user = _db.TblUser.FirstOrDefault( x => x.Email.Equals(email)); if (user != null) { user.Senha = new Crypt().Password(newPassword); _db.Entry(user).State = EntityState.Modified; _db.SaveChanges(); new SendMailHelper().SendEmail( new string[] { email }, new string[] { email }, "Solicitação de Senha", Body, true ); } } }
public List<TblContato> GetAllUser(int id) { using (_db = new ProvaNetEntities()) { _db.Configuration.ProxyCreationEnabled = false; return _db.TblContato.Where(x => x.FK_User_From == id).ToList(); } }
public TblContato GetByUser(int id) { using (_db = new ProvaNetEntities()) { _db.Configuration.ProxyCreationEnabled = false; return _db.TblContato.Where(x => x.FK_User_To == id).FirstOrDefault(); } }
public void Update(TblUser user) { using (_db = new ProvaNetEntities()) { _db.Configuration.ProxyCreationEnabled = false; _db.Entry(user).State = EntityState.Modified; _db.SaveChanges(); } }
public void Remove(TblContato contato) { using (_db = new ProvaNetEntities()) { _db.Configuration.ProxyCreationEnabled = false; _db.Entry(contato).State = EntityState.Deleted; _db.SaveChanges(); } }
public void Insert(TblContato contato) { using (_db = new ProvaNetEntities()) { _db.Configuration.ProxyCreationEnabled = false; _db.TblContato.Add(contato); _db.SaveChanges(); } }
public TblUser GetByEmail(string email) { TblUser response = null; using (_db = new ProvaNetEntities()) { _db.Configuration.ProxyCreationEnabled = false; response = _db.TblUser.FirstOrDefault(x => x.Email == email); } return response; }
public TblUser Get(int id) { TblUser response = null; using (_db = new ProvaNetEntities()) { _db.Configuration.ProxyCreationEnabled = false; response = _db.TblUser.FirstOrDefault(x => x.PK_User == id); } return response; }
public TblUser ValidarLogin(TblUser user) { TblUser response = null; using (_db = new ProvaNetEntities()) { _db.Configuration.ProxyCreationEnabled = false; string senhaCrypt = new Crypt().Password(user.Senha); response = _db.TblUser.FirstOrDefault( x => x.Email.Equals(user.Email) && x.Senha.Equals(senhaCrypt)); } return response; }
public List<TblUser> GetAll(int id) { List<TblUser> listUser = new List<TblUser>(); using (_db = new ProvaNetEntities()) { _db.Configuration.ProxyCreationEnabled = false; List<TblContato> listContact = _db.TblContato.Where(x => x.FK_User_From == id).ToList(); foreach (var contact in listContact) { listUser.Add(new UserService().Get(contact.FK_User_To)); } } return listUser; }