public IActionResult UpdateInfo([FromBody] EmployeeInfoToShare updatedInfo, int id) { if (updatedInfo != null) { var newEmployeeUtils = new EmployeeUtils(); if (updatedInfo.FirstName != null) { updatedInfo.EmployeeId = id; if (newEmployeeUtils.EditEmployeeAccount(updatedInfo)) { return(NoContent()); } } return(BadRequest("Invalid Input!!!")); } else { var newEmployeeUtils = new EmployeeUtils(); var empToClean = newEmployeeUtils.GetEmployeeById(id); if (empToClean != null) { return(Ok(empToClean)); } return(NotFound($"Couldnt find an Employee with the ID: {id}")); } }
public IActionResult GetEmployeeInfoById(int id) { var newEmployeeUtils = new EmployeeUtils(); var empToClean = newEmployeeUtils.GetEmployeeById(id); if (empToClean != null) { return(Ok(empToClean)); } return(NotFound($"Couldnt find an Employee with the ID: {id}")); }
public IActionResult ResetPw([FromBody] PWResetInfo newCustInfo, int id) { if (newCustInfo.ManagerInfo.Username.ToString() == null || newCustInfo.ManagerInfo.Password == null) { return(BadRequest("Username or Password was not provided!")); } var newEmpUtil = new EmployeeUtils(); try { var newEmployee = newEmpUtil.LogIn(newCustInfo.ManagerInfo.Username, newCustInfo.ManagerInfo.Password); if (newEmployee != null) { var newEmployeeUtils = new EmployeeUtils(); var empToClean = newEmployeeUtils.GetEmployeeById(id); if (empToClean != null) { Login updatedInfo = new Login(); updatedInfo.Username = id; updatedInfo.Password = newCustInfo.NewPw; if (newEmployeeUtils.EditEmployeePW(updatedInfo)) { return(Ok()); } return(StatusCode(500, "Error, Couldnt update the User Password! ")); } } return(NotFound($"Couldn't Login Employee {newCustInfo.ManagerInfo.Username}! ")); } catch (Exception e) { return(NotFound($"You Broke something, Great Job!! " + e)); } }