public static bool DoesEmailExist(string emailID) { using (TechX_SolutionsDBEntities TE = new TechX_SolutionsDBEntities()) { var email = TE.Employees.Where(e => e.Work_Email_ID == emailID).FirstOrDefault(); return(email == null ? false : true); }; }
public static bool DoesEmployeeIDExist(string EmployeeID) { using (TechX_SolutionsDBEntities TE = new TechX_SolutionsDBEntities()) { var EmpID = TE.Employees.Where(e => e.Employee_ID == EmployeeID).FirstOrDefault(); return(EmpID == null ? false : true); }; }
public static string ReturnSignupAttemptresult(Employee NewUser) { using (TechX_SolutionsDBEntities TE = new TechX_SolutionsDBEntities()) { try { TE.Employees.Add(NewUser); TE.Configuration.ValidateOnSaveEnabled = true; TE.SaveChanges(); } catch (DbEntityValidationException dbEx) { ExceptionLog.Logger(dbEx); } } return("Account created successfully. Please login to continue."); }
public static string ReturnResetPasswordAttemptResult(string id, HttpCookie aCookie) { using (TechX_SolutionsDBEntities dc = new TechX_SolutionsDBEntities()) { var user = dc.Employees.Where(a => a.ResetPasswordLink == id).FirstOrDefault(); if (user != null && aCookie.Expires < DateTime.Now) { PasswordReset model = new PasswordReset { ResetCode = id }; return("Successful"); } else { return("Invalid attempt"); } } }
public static string ReturnForgotPasswordAttemptResult(string EmailID, string EmployeeId) { using (TechX_SolutionsDBEntities TE = new TechX_SolutionsDBEntities()) { var account = TE.Employees.Where(a => a.Work_Email_ID == EmailID && a.Employee_ID == EmployeeId).FirstOrDefault(); if (account != null) { string resetCode = Guid.NewGuid().ToString(); account.ResetPasswordLink = resetCode; TE.Configuration.ValidateOnSaveEnabled = false; TE.SaveChanges(); return("Reset password link has been sent to your email id."); } else { return("Account not found"); } } }
public static string ReturnResetPasswordAttemptResult(PasswordReset model) { using (TechX_SolutionsDBEntities TE = new TechX_SolutionsDBEntities()) { var user = TE.Employees.Where(u => u.ResetPasswordLink == model.ResetCode).FirstOrDefault(); try { if (user != null) { user.Password = PasswordHash.Hasher(model.Password); user.ResetPasswordLink = ""; TE.Configuration.ValidateOnSaveEnabled = false; TE.SaveChanges(); return("Password has been updated!"); } } catch (Exception Ex) { ExceptionLog.Logger(Ex); } } return("Something went wrong while updating password!"); }
public static string ReturnLoginAttemptresult(UserLogin logger, out Employee user) { using (TechX_SolutionsDBEntities TE = new TechX_SolutionsDBEntities()) { user = TE.Employees.Where(u => u.Employee_ID == logger.EmployeeID).FirstOrDefault(); if (user != null) { if (string.Compare(PasswordHash.Hasher(logger.Password), user.Password) == 0) { return("Successful"); } else { return("Incorrect password!"); } } else { return("Invalid Credentials!"); } } }
public ActionResult ForgotPassword(string EmailID, string employeeid) { string message = ""; using (TechX_SolutionsDBEntities TE = new TechX_SolutionsDBEntities()) { var account = TE.Employees.Where(a => a.Work_Email_ID == EmailID && a.Employee_ID == employeeid).FirstOrDefault(); if (account != null) { string resetCode = Guid.NewGuid().ToString(); SendVerificationLinkEmail("*****@*****.**", resetCode, "ResetPassword"); account.ResetPasswordLink = resetCode; TE.Configuration.ValidateOnSaveEnabled = false; TE.SaveChanges(); message = "Reset password link has been sent to your email id."; } else { message = "Account not found"; } } ViewBag.Message = message; return(View()); }