public bool ChangeEmployeePassword(string username, string oldPassword, string newPassword) { Log.Debug("Enter ChangeEmployeePassword method."); using (var access = new AccessDB()) { //access.Actions.FirstOrDefault(f => f.Username.Equals(username) && f.Password.Equals(oldPassword)).Password = newPassword; Employee em = access.Actions.FirstOrDefault(f => f.Username.Equals(username) && f.Password.Equals(oldPassword)); if (em != null) { em.Password = newPassword; em.PasswordUpadateDate = DateTime.Now; access.Entry(em).State = System.Data.Entity.EntityState.Modified; int i = access.SaveChanges(); if (i > 0) { Log.Info("Successfully updated DB"); return(true); } Log.Warn("Failed to update DB"); return(false); } else { Log.Warn("Employee with that username does not exist. Failed chainging password."); return(false); } } }
public bool EmployeeLogOut(string username) { Log.Debug("Enter EmployeeLogOut method."); using (var access = new AccessDB()) { Employee emp = access.Actions.FirstOrDefault(f => f.Username.Equals(username)); if (emp != null) { //access.Actions.FirstOrDefault(f => f.Username.Equals(username)).Login = false; emp.Login = false; access.Entry(emp).State = System.Data.Entity.EntityState.Modified; int i = access.SaveChanges(); if (i > 0) { Log.Info("Successfully updated DB"); return(true); } Log.Warn("Failed to update DB"); return(false); } else { Log.Warn("Employee with that username does not exist. Failed to logout."); return(false); } } }
public bool ChangeEmployeePosition(string username, string position) { Log.Debug("Enter ChangeEmployeePosition method."); using (var access = new AccessDB()) { Employee em = access.Actions.FirstOrDefault(f => f.Username.Equals(username)); if (em != null) { //access.Actions.FirstOrDefault(f => f.Username == username).Position = position.ToString(); em.Position = position.ToString(); access.Entry(em).State = System.Data.Entity.EntityState.Modified; int i = access.SaveChanges(); if (i > 0) { Log.Info("Successfully updated DB"); return(true); } Log.Warn("Failed to update DB"); return(false); } else { Log.Warn("Employee with that username does not exist. Failed chainging position."); return(false); } } }