public void updateUserPassword(tbUserPassword upPassword) { try { using (dbConsorcioEntities consorcio = new dbConsorcioEntities()) { tbUserPassword password = consorcio.tbUserPassword.Where(p => p.id_user == upPassword.id_user).FirstOrDefault(); if (password == null) { throw new Exception("Usuário sem Password definido"); } password.de_password = returnSHA512String(upPassword.de_password); password.dt_create = upPassword.dt_create; password.dt_update = DateTime.Now; password.bt_bloqueio = password.bt_bloqueio; consorcio.SaveChanges(); } } catch (Exception ex) { throw new Exception(ex.Message); } }
public bool validateUserPassword(tbUserPassword validatePassword) { try { using (dbConsorcioEntities consorcio = new dbConsorcioEntities()) { validatePassword.de_password = returnSHA512String(validatePassword.de_password); tbUserPassword password = consorcio.tbUserPassword.Where(p => p.id_user == validatePassword.id_user & p.de_password == validatePassword.de_password).FirstOrDefault(); if (password == null) { return(false); } if (password.bt_bloqueio == true) { return(false); } } } catch (Exception ex) { throw new Exception(ex.Message); } return(true); }
public void insertUserPassword(tbUserPassword newPassword) { tbUserPassword passCheck; try { using (dbConsorcioEntities consorcio = new dbConsorcioEntities()) { passCheck = consorcio.tbUserPassword.Where(p => p.id_user == newPassword.id_user).FirstOrDefault(); } if (passCheck == null) { using (dbConsorcioEntities consorcio = new dbConsorcioEntities()) { tbUserPassword password = new tbUserPassword(); password.id_user = newPassword.id_user; password.de_password = returnSHA512String(newPassword.de_password); password.dt_create = DateTime.Now; password.bt_bloqueio = false; consorcio.tbUserPassword.Add(password); consorcio.SaveChanges(); } } } catch (Exception ex) { throw new Exception(ex.Message); } }