public List <AccessRight> GetAccessRight(int employeeID) { using (var db = new FASTDBEntities()) { return(db.AccessRights.Select(emp => new AccessRight()).Where(emp => emp.EmployeeID == employeeID).ToList()); } }
public List <AssetAssignment> GetAllAssignments() { using (var db = new FASTDBEntities()) { return(db.AssetAssignments.ToList()); } }
public LoginStatus ValidateLogin(int EmployeeID, string Password) { var hashedPassword = Encryption.MD5Hash(Password); using (var db = new FASTDBEntities()) { //This will check the Registration table if supplied EmployeeID and PassPhrase exists. bool employeeExists = db.Registrations.Where(k => k.EmployeeID == EmployeeID && k.Password == hashedPassword).Any(); if (employeeExists) { //If employee credential exists, validation will be successful. return(LoginStatus.Successful); } else { //If employee credential seems not to apear in the initial query in Registration table, //another query will be run to check if the EmployeeID exists. employeeExists = db.Registrations.Where(k => k.EmployeeID == EmployeeID).Any(); if (employeeExists) { return(LoginStatus.IncorrectPassword); //If EmployeeID exists, it is therefore validated that the supplied password is incorrect. } else { return(LoginStatus.EmployeeIDUnknown); //If EmployeeID does not exists, it is therefore validated that it is not a registered Employee. } } } }
public List <FixAsset> GetAllAssets() { using (var db = new FASTDBEntities()) { return(db.FixAssets.ToList()); } }
public int LoginUser(int employeeID, string hashedPassword) { using (var db = new FASTDBEntities()) { EmployeeProcess employeeProcess = new EmployeeProcess(); if (employeeProcess.GetEmployeeByID(employeeID) != null) { var registrations = from reg in db.Registrations where reg.EmployeeID == employeeID && reg.Password == hashedPassword select reg; if (registrations.Count() > 0) { Helpers.Logger.AddToAuditTrail(Logger.UserAction.LOGIN, employeeID, "SUCCESSFUL"); return(ReturnValues.SUCCESS); } else { Helpers.Logger.AddToAuditTrail(Logger.UserAction.LOGIN, employeeID, "FAILED"); return(ReturnValues.FAILED); } } } Helpers.Logger.AddToAuditTrail(Logger.UserAction.LOGIN, employeeID, "NOT FOUND"); return(ReturnValues.NOT_FOUND); }
public List <Employee> GetAllEmployees() { using (var db = new FASTDBEntities()) { return(db.Employees.ToList()); } }
public List <Registration> GetAllRegistration() { List <Registration> registrants = new List <Registration>(); using (var db = new FASTDBEntities()) { return(db.Registrations.ToList()); } }
internal List <AssetType> GetAssetTypes(int assetClass) { using (var db = new FASTDBEntities()) { return((from types in db.AssetTypes where types.AssetClassID == assetClass select types).ToList()); } }
//EmployeeID is the Admin Employee ID public List <vwAssetAssignmentsForCustodian> GetAdminTransactionsbyEmployeeID(int employeeID) { using (var db = new FASTDBEntities()) { List <vwAssetAssignmentsForCustodian> transactions = (from assigns in db.vwAssetAssignmentsForCustodians where assigns.AdminID == employeeID select assigns).ToList(); return(transactions); } }
//EmployeeID is the Admin Employee ID public List <vwAssetAssignmentsForManager> GetManagerTransactionsbyDepartmentID(int departmentID) { using (var db = new FASTDBEntities()) { List <vwAssetAssignmentsForManager> transactions = (from assigns in db.vwAssetAssignmentsForManagers where assigns.DepartmentID == departmentID select assigns).ToList(); return(transactions); } }
public List <vwAssetAssignment> GetAssignmentsByAssignmentID(int assignmentID) { using (var db = new FASTDBEntities()) { List <vwAssetAssignment> assignments = (from assigns in db.vwAssetAssignments where assigns.AssetAssignmentID == assignmentID select assigns).ToList(); return(assignments); } }
public List <Employee> GetEmployeeByDepartment(int departmentID) { BO.EmployeeProcess employeeProcess = new BO.EmployeeProcess(); using (var db = new FASTDBEntities()) { List <Employee> list = (from emp in db.Employees where emp.DepartmentID == departmentID select emp).ToList(); return(list); } }
//EmployeeID is the MIS Employee ID public List <vwAssetAssignmentsForMI> GetMISTransactionsbyEmployeeID(int employeeID) { using (var db = new FASTDBEntities()) { List <vwAssetAssignmentsForMI> transactions = (from assigns in db.vwAssetAssignmentsForMIS where assigns.MISEmployeeID == employeeID select assigns).ToList(); vwAssetAssignmentsForMI[] res = (from assigns in db.vwAssetAssignmentsForMIS where assigns.MISEmployeeID == employeeID select assigns).ToArray(); return(transactions); } }
public vwFixAsset GetFixAssetViewByID(int fixAssetID) { using (var db = new FASTDBEntities()) { List <vwFixAsset> assets = (from asset in db.vwFixAssets where asset.FixAssetID == fixAssetID select asset).ToList(); if (assets != null) { return(assets[0]); } } return(null); }
public int ResetPassword(int employeeID) { using (var db = new FASTDBEntities()) { EmployeeProcess employeeProcess = new EmployeeProcess(); Employee employee = employeeProcess.GetEmployeeByID(employeeID); if (employee != null) { var registrations = from reg in db.Registrations where reg.EmployeeID == employeeID select reg; if (registrations.Count() > 0) { foreach (Registration regUser in registrations) { string password; if (ConfigurationHelper.SendEmail) { password = System.Web.Security.Membership.GeneratePassword(6, 0); password = Regex.Replace(password, @"[^a-zA-Z0-9]", m => "$"); } else { //Use the current user employee ID if email is out password = employeeID.ToString(); } regUser.Password = Providers.MD5HashProvider.CreateMD5Hash(password); regUser.DateStamp = DateTime.Now; db.SaveChanges(); if (ConfigurationHelper.SendEmail) { email.SendUserRegistrationEmail(EmailProvider.EmailType.RESET_PASSWORD, employeeID, employee.FirstName + " " + employee.LastName, employee.EmailAddress, password); } Helpers.Logger.AddToAuditTrail(Logger.UserAction.RESET_PASSWORD, employeeID, "SUCCESSFUL"); return(ReturnValues.SUCCESS); } } } } Helpers.Logger.AddToAuditTrail(Logger.UserAction.RESET_PASSWORD, employeeID, "FAILED : NOT FOUND"); return(ReturnValues.NOT_FOUND); }
public HttpResponseMessage ResetPassword(ExternalResetPasswordViewModel model) { using (var db = new FASTDBEntities()) { BO.UserProcess userProcess = new BO.UserProcess(); int result = userProcess.ResetPassword(model.EmployeeID); if (result == ReturnValues.SUCCESS) { return(ReturnMessages.RESPONSE_OK()); } } return(ReturnMessages.RESPONSE_NOTSUCCESSFUL()); }
public vwEmployeeList GetEmployeeViewByID(int employeeID) { using (var db = new FASTDBEntities()) { vwEmployeeList[] employees = (from emp in db.vwEmployeeLists where emp.EmployeeID == employeeID select emp).ToArray(); if (employees.Count() > 0) { return(employees[0]); } } return(null); }
public vwFixAssetList GetAssetBySerialNumber(string serialNumber) { using (var db = new FASTDBEntities()) { vwFixAssetList[] assets = (from asset in db.vwFixAssetLists where (0 == String.Compare(serialNumber, asset.SerialNumber)) select asset).ToArray(); if (assets.Count() > 0) { return(assets[0]); } else { return(null); } } }
public vwFixAssetList GetAssetbyIssuerID(int issuerID) { using (var db = new FASTDBEntities()) { vwFixAssetList[] assets = (from asset in db.vwFixAssetLists where asset.IssuerID == issuerID select asset).ToArray(); if (assets.Count() > 0) { return(assets[0]); } else { return(null); } } }
public HttpResponseMessage Login(ExternalUserLoginViewModel model) { using (var db = new FASTDBEntities()) { BO.UserProcess userProcess = new BO.UserProcess(); int result = userProcess.LoginUser(model.EmployeeID, model.HashedPassword); if (result == ReturnValues.SUCCESS) { return(ReturnMessages.RESPONSE_OK()); } else if (result == ReturnValues.FAILED) { return(ReturnMessages.RESPONSE_NOTSUCCESSFUL()); } } return(ReturnMessages.RESPONSE_NOTFOUND()); }
public List <string> GetManagersMailList(int optionalDepartmentID = 0) { using (var db = new FASTDBEntities()) { List <string> toList = new List <string>(); if (optionalDepartmentID != 0) { toList = (from list in db.vwManagersLists where list.DepartmentID == optionalDepartmentID select list.EmailAddress).ToList(); } else { toList = (from list in db.vwManagersLists select list.EmailAddress).ToList(); } return(toList); } }
public int AddNewAsset(Models.ExternalAddAssetViewModel model) { using (var db = new FASTDBEntities()) { FixAsset newAsset = new FixAsset(); newAsset = model.GetNewFixAssetData(); db.FixAssets.Add(newAsset); int result = db.SaveChanges(); if (result > 0) { return(ReturnValues.SUCCESS); } else { return(ReturnValues.FAILED); } } }
public List <UserAccessRights> GetAccessRights(int employeeID) { List <UserAccessRights> userAccess = new List <UserAccessRights>(); using (var db = new FASTDBEntities()) { var rights = from right in db.AccessRights where ((right.EmployeeID == employeeID) && (right.Status == 1)) select right; foreach (AccessRight right in rights) { UserAccessRights access = new UserAccessRights(); access.DepartmentID = right.DepartmentID; access.AccessLevel = right.AccessLevel; userAccess.Add(access); } } return(userAccess); }
public int UpdateAssetStatus(int assetID, int newStatus) { using (var db = new FASTDBEntities()) { FixAsset[] assets = (from asset in db.FixAssets where asset.FixAssetID == assetID select asset).ToArray(); if (assets.Count() > 0) { foreach (FixAsset asset in assets) { asset.AssetStatusID = newStatus; db.SaveChanges(); } return(ReturnValues.SUCCESS); } return(ReturnValues.FAILED); } }
public int ChangePassword(int employeeID, string oldPassword, string newPassword) { using (var db = new FASTDBEntities()) { EmployeeProcess employeeProcess = new EmployeeProcess(); Employee employee = employeeProcess.GetEmployeeByID(employeeID); if (employeeProcess.GetEmployeeByID(employeeID) != null) { var registrations = from reg in db.Registrations where reg.EmployeeID == employeeID && reg.Password == oldPassword select reg; if (registrations.Count() > 0) { foreach (Registration userReg in registrations) { userReg.Password = newPassword; } db.SaveChanges(); //TODO : Email employee about the successful change if (ConfigurationHelper.SendEmail) { email.SendUserRegistrationEmail(EmailProvider.EmailType.CHANGE_PASSWORD, 0, employee.FirstName + " " + employee.LastName, employee.EmailAddress, ""); } Helpers.Logger.AddToAuditTrail(Logger.UserAction.CHANGE_PASSWORD, employeeID, "SUCCESSFUL"); return(ReturnValues.SUCCESS); } } } Helpers.Logger.AddToAuditTrail(Logger.UserAction.CHANGE_PASSWORD, employeeID, "FAILED"); return(ReturnValues.FAILED); }
public int RegisterUser(int employeeID) { using (var db = new FASTDBEntities()) { EmployeeProcess employeeProcess = new EmployeeProcess(); Registration[] registrants = (from reg in db.Registrations where reg.EmployeeID == employeeID select reg).ToArray(); Employee employee = employeeProcess.GetEmployeeByID(employeeID); if (employee != null) { if (registrants.Count() > 0) { Helpers.Logger.AddToAuditTrail(Logger.UserAction.REGISTRATION, employeeID, "FAILED : USER EXISTS"); return(ReturnValues.FAILED); } else { Registration newReg = new Registration(); newReg.EmployeeID = employeeID; string password; if (ConfigurationHelper.SendEmail) { password = System.Web.Security.Membership.GeneratePassword(8, 0); password = Regex.Replace(password, @"[^a-zA-Z0-9]", m => "$"); } else { //Use the current user employee ID if email is out password = employeeID.ToString(); } newReg.Password = Providers.MD5HashProvider.CreateMD5Hash(password); newReg.DateStamp = DateTime.Now; newReg.Status = 0; db.Registrations.Add(newReg); db.SaveChanges(); if (ConfigurationHelper.SendEmail) { email.SendUserRegistrationEmail(EmailProvider.EmailType.REGISTRATION, employeeID, employee.FirstName + " " + employee.LastName, employee.EmailAddress, password); } Helpers.Logger.AddToAuditTrail(Logger.UserAction.REGISTRATION, employeeID, "SUCCESSFUL"); return(ReturnValues.SUCCESS); } } } Helpers.Logger.AddToAuditTrail(Logger.UserAction.REGISTRATION, employeeID, "NOT FOUND"); return(ReturnValues.NOT_FOUND); }
public BaseProcess() { FastDB = new FASTDBEntities(); }