/// <summary> /// after forgot password update employee new password /// </summary> /// <param name="getEP"></param> /// <returns> if success return true</returns> public Boolean SetEmailAndPassword(GetEmailPassword getEP) { GetEmail getEmail = new GetEmail(); getEmail.Email = getEP.EmpEmail; if (this.IsEmail(getEmail) == true) { Random rand = new Random((int)DateTime.Now.Ticks); int numIterations = rand.Next(10000, 99999); Employee employee = new Employee(); employee = _context.Employees .Where(c => c.EmpEmail == getEP.EmpEmail && c.IsActive == true).FirstOrDefault(); if (employee.RegisterCode == getEP.Code) { employee.EmpPassword = getEP.EmpPassword; employee.RegisterCode = numIterations.ToString(); _context.Entry(employee).State = Microsoft.EntityFrameworkCore.EntityState.Modified; _context.SaveChanges(); return(true); } return(false); } return(false); }
public IActionResult SetEmailAndPassword([FromBody] GetEmailPassword getEP) { if (_service.SetEmailAndPassword(getEP)) { return(Ok()); } return(BadRequest()); }
public IActionResult SetEmailAndPassword([FromBody] GetEmailPassword getEP) { Hash hash = new Hash(); getEP.EmpPassword = hash.HashPassword(getEP.EmpPassword); if (_service.SetEmailAndPassword(getEP)) { return(Ok()); } return(BadRequest()); }
public Boolean SetEmailAndPassword(GetEmailPassword getEP) { GetEmail getEmail = new GetEmail(); getEmail.Email = getEP.EmpEmail; if (this.IsEmailUnique(getEmail) == true) { Random rand = new Random((int)DateTime.Now.Ticks); int numIterations = rand.Next(10000, 99999); Employee employee = new Employee(); employee = GetEmployeeByEmail(getEP.EmpEmail); if (employee.RegisterCode == getEP.Code) { employee.EmpPassword = getEP.EmpPassword; employee.RegisterCode = numIterations.ToString(); UpdateEmployee(employee); return(true); } return(false); } return(false); }
public Boolean SetEmailAndPassword(GetEmailPassword getEP) { return(_service.SetEmailAndPassword(getEP)); }