public bool ReadById() { try { Data.USER_INFO usr = Connection.ProcessSA_DB.USER_INFO.First(user => user.ID == Id); Id = (int)usr.ID; FirstName = usr.FIRSTNAME; LastName = usr.LASTNAME; Address = usr.ADDRESS; Phone = usr.PHONE; Birthdate = usr.BIRTHDATE; Email = usr.EMAIL; Commune = usr.COMMUNE.NAME; Gender = usr.GENDER.NAME; Company = usr.COMPANY.NAME; AssignedUnit = new AssignedUnit() { Id = (int)usr.ASSIGNED_UNIT.ID }; if (AssignedUnit.ReadById() == false) { log.Error(("Error al ir a buscar la unidad asignada del usuario con Id {0} a la DB", Id)); throw new Exception(); } return(true); } catch (Exception e) { log.Error("Error al buscar usuario por Id: " + Id, e); return(false); } }
public bool IsEmailAndBirthdayCorrect() { try { Data.USER_INFO usr = Connection.ProcessSA_DB.USER_INFO.First(user => Email.ToLower() == user.EMAIL.ToLower() && EntityFunctions.TruncateTime(Birthdate) == EntityFunctions.TruncateTime(user.BIRTHDATE)); return(true); } catch (Exception e) { return(false); } }
public Dictionary <int, string> GetPermissions() { Dictionary <int, string> dictionary = new Dictionary <int, string>(); Data.USER_INFO usr = Connection.ProcessSA_DB.USER_INFO.First(user => Email.Equals(user.EMAIL, StringComparison.InvariantCultureIgnoreCase)); foreach (Data.PERMISSION permission in usr.ASSIGNED_UNIT.INTERNAL_UNIT.ROLE.PERMISSION) { dictionary.Add((int)permission.ID, permission.NAME); } return(dictionary); }
public bool Update() { try { Data.USER_INFO usr = Connection.ProcessSA_DB.USER_INFO.First(user => Email.Equals(user.EMAIL, StringComparison.InvariantCultureIgnoreCase)); usr.PHONE = Phone; Connection.ProcessSA_DB.SaveChanges(); return(true); } catch (Exception e) { log.Error("Error al actualizar el celular del usuario con email: " + Email, e); return(false); } }
public bool UpdatePassword() { try { Data.USER_INFO usr = Connection.ProcessSA_DB.USER_INFO.First(user => Email.Equals(user.EMAIL, StringComparison.InvariantCultureIgnoreCase)); usr.PASSWORD = PasswordEncryptor.Encrypt(Password); Connection.ProcessSA_DB.SaveChanges(); return(true); } catch (Exception e) { log.Error("Error al actualizar la contraseña de usuario de email " + Email, e); return(false); } }
public bool Authenticate() { try { string encryptedPassword = PasswordEncryptor.Encrypt(Password); Data.USER_INFO usr = Connection.ProcessSA_DB.USER_INFO.First(user => Email.Equals(user.EMAIL, StringComparison.InvariantCultureIgnoreCase) && encryptedPassword == user.PASSWORD); ReadByEmail(); return(true); } catch (Exception e) { log.Warn("Error al autenticar el usuario, verifique que usuario y contraseña corresponda", e); return(false); } }
public string GetInternalUnitName() { string value; try { Data.USER_INFO usr = Connection.ProcessSA_DB.USER_INFO.First(user => user.ID == Id); value = usr.ASSIGNED_UNIT.INTERNAL_UNIT.NAME; } catch (Exception e) { value = null; } return(value); }