public HttpResponseMessage ChangePassword(ChangePasswordModel changepassword) { HttpResponseMessage response = null; try { Employee employee = EmployeeRepo.GetEmployeeById(changepassword.employee_id); User user_instance = LeaveRepo.GetUserById(employee.user_id); if (user_instance.is_active == 1) { if (changepassword.new_password == changepassword.confirm_password) { if (changepassword.oldpassword == changepassword.new_password) { response = Request.CreateResponse(HttpStatusCode.OK, new EMSResponseMessage("EMS_515", "Current Password and New password should be different", "Current Password and New password should be different")); } else if (EncryptPassword.CalculateHash(changepassword.oldpassword) == user_instance.password) { user_instance.password = EncryptPassword.CalculateHash(changepassword.new_password); LeaveRepo.EditUserPassword(user_instance); string user_name = employee.first_name + " " + employee.last_name; MailHandler.ChangePasswordIntimation(user_name, employee.email); response = Request.CreateResponse(HttpStatusCode.OK, new EMSResponseMessage("EMS_001", "Password changed sucessfully", "Password changed sucessfully")); } else { response = Request.CreateResponse(HttpStatusCode.OK, new EMSResponseMessage("EMS_514", "Invalid Current Password", "Invalid Current Password")); } } else { response = Request.CreateResponse(HttpStatusCode.OK, new EMSResponseMessage("EMS_302", "New Password and Confirm Password should be same", "New Password and Confirm Password should be same")); } } else { response = Request.CreateResponse(HttpStatusCode.OK, new EMSResponseMessage("EMS_303", "Access Denied", "Access Denied")); } } catch (Exception exception) { Debug.WriteLine(exception.Message); Debug.WriteLine(exception.GetBaseException()); response = Request.CreateResponse(HttpStatusCode.OK, new EMSResponseMessage("EMS_101", "Application Error", exception.Message)); } return(response); }