public String appointNewRepresentativeMobile(string employeeID, string departmentid) { try { int eID = Convert.ToInt16(employeeID); using (TransactionScope ts = new TransactionScope()) { var employee = from e in ctx.Employees //join r in ctx.Roles on e.RoleID equals r.RoleID where e.EmployeeID == eID select e; ADTeam4EF.Employee emp = employee.First(); emp.RoleID = 2; //ctx.SaveChanges(); ADTeam4EF.Employee previousEmp = getRepresentative(departmentid); previousEmp.RoleID = 4; ctx.SaveChanges(); ts.Complete(); return("SUCCESS"); } } catch { return("FAIL"); } }
public List <Request> populateRequestNo(string employeeName, DateTime fromDate, DateTime toDate) { try { List <Request> requestList = new List <Request>(); var employee = from emp in ctx.Employees where emp.EmployeeName == employeeName select emp; ADTeam4EF.Employee e = employee.First(); var reqno = from req in ctx.Requests where req.RequestDate >= fromDate && req.RequestDate <= toDate && req.RequestByEmployeeID == e.EmployeeID select req; List <Request> reqList = reqno.ToList <Request>(); if (reqList.Count > 0) { return(reqList); } else { return(null); } } catch (Exception e) { throw e; } }
public bool cancelAuthority() { try { var emp = from employee in ctx.Employees join rol in ctx.Roles on employee.RoleID equals rol.RoleID where rol.RoleID == 3 select employee; ADTeam4EF.Employee e = emp.First(); var delegateInfo = from del in ctx.DelicatedInfoes where del.EmployeeID == e.EmployeeID select del; ADTeam4EF.DelicatedInfo d = delegateInfo.First(); using (TransactionScope ts = new TransactionScope()) { e.RoleID = 4; //ctx.SaveChanges(); ctx.DelicatedInfoes.Remove(d); ctx.SaveChanges(); ts.Complete(); return(true); } } catch { return(false); } }
public bool appointNewRepresentative(string employeeName, string departmentid) { try { using (TransactionScope ts = new TransactionScope()) { var employee = from e in ctx.Employees join r in ctx.Roles on e.RoleID equals r.RoleID where e.EmployeeName == employeeName select e; ADTeam4EF.Employee emp = employee.First(); ADTeam4EF.Employee previousEmp = getRepresentative(departmentid); previousEmp.RoleID = 4; emp.RoleID = 2; sendmail(departmentid, previousEmp.EmployeeEmail, emp.EmployeeEmail); ctx.SaveChanges(); ts.Complete(); return(true); } } catch { return(false); } }
public bool delegateAuthorityMobile(int employeeID, DateTime fromDate, DateTime toDate) { try { var employee = from emp in ctx.Employees join r in ctx.Roles on emp.RoleID equals r.RoleID where emp.EmployeeID == employeeID select emp; ADTeam4EF.Employee e = employee.First(); using (TransactionScope ts = new TransactionScope()) { e.RoleID = 3; ctx.SaveChanges(); ADTeam4EF.DelicatedInfo delicateInfo = new ADTeam4EF.DelicatedInfo(); delicateInfo.EmployeeID = employeeID; delicateInfo.fromDate = fromDate; delicateInfo.toDate = toDate; ctx.DelicatedInfoes.Add(delicateInfo); ctx.SaveChanges(); ts.Complete(); return(true); } } catch { return(false); } }
public void updateExpiredDelegatedEmployee() { try { var emp = from e in ctx.Employees join r in ctx.Roles on e.RoleID equals r.RoleID where e.RoleID == 3 select e; ADTeam4EF.Employee employee = emp.FirstOrDefault(); if (employee != null) { var de = from del in ctx.DelicatedInfoes join e in ctx.Employees on del.EmployeeID equals e.EmployeeID where e.EmployeeID == employee.EmployeeID select del; ADTeam4EF.DelicatedInfo d = de.FirstOrDefault(); if (d != null) { if (System.DateTime.Today > d.toDate) { using (TransactionScope ts = new TransactionScope()){ employee.RoleID = 4; ctx.DelicatedInfoes.Remove(d); ctx.SaveChanges(); ts.Complete(); } } } } } catch (Exception ex) { throw ex; } }
public Employee getEmployeeInfo(string employeename) { try { var employee = from emp in ctx.Employees where emp.EmployeeName == employeename select emp; ADTeam4EF.Employee e = employee.First(); return(e); } catch { return(null); } }
public Employee getRepresentative(string departmentid) { try { var employee = from e in ctx.Employees join r in ctx.Roles on e.RoleID equals r.RoleID where e.DepartmentID == departmentid && r.RoleID == 2 select e; ADTeam4EF.Employee emp = employee.First(); return(emp); } catch (Exception ex) { throw ex; } }
public Employee getRepresentativeMobile(string departmentid) { try { var employee = from e in ctx.Employees //join r in ctx.Roles on e.RoleID equals r.RoleID where e.DepartmentID == departmentid && e.RoleID == 2 select e; ADTeam4EF.Employee emp = employee.FirstOrDefault(); return(emp); } catch { return(null); } }
public Employee GetEmployeeIDByEmployeeName(string EmployeeName) { try { var q = from emp in ctx.Employees where emp.EmployeeName == EmployeeName select emp; ADTeam4EF.Employee employee = q.First(); return(employee); } catch (Exception ex) { throw ex; } }
//public bool delegateAuthority(string employeeName, string fromDate, string toDate) //{ // try // { // var employee = from emp in ctx.Employees // join r in ctx.Roles on emp.RoleID equals r.RoleID // where emp.EmployeeName == employeeName // select emp; // ADTeam4EF.Employee e = employee.First(); // using (TransactionScope ts = new TransactionScope()) // { // e.RoleID = 3; // ctx.SaveChanges(); // ADTeam4EF.DelicatedInfo delicateInfo = new ADTeam4EF.DelicatedInfo(); // delicateInfo.EmployeeID = e.EmployeeID; // delicateInfo.fromDate = Convert.ToDateTime(fromDate.Replace("-","/")); // delicateInfo.toDate = Convert.ToDateTime(toDate.Replace("-","/")); // ctx.DelicatedInfoes.Add(delicateInfo); // ctx.SaveChanges(); // ts.Complete(); // return true; // } // } // catch(Exception ex) // { // return false; // } //} public Employee populateAuthority(string departmentid) { try { var emp = from employee in ctx.Employees join rol in ctx.Roles on employee.RoleID equals rol.RoleID where rol.RoleID == 3 select employee; ADTeam4EF.Employee empl = emp.FirstOrDefault(); if (empl != null) { return(empl); } else { return(null); } } catch (Exception ex) { throw ex; } }
public Employee authenticateUser(string email, string hashedPassword) { try { var q = from emp in ctx.Employees join r in ctx.Roles on emp.RoleID equals r.RoleID where emp.EmployeeEmail == email && emp.EmployeePassword == hashedPassword select emp; ADTeam4EF.Employee employee = q.FirstOrDefault(); if (employee != null) { return(employee); } else { return(null); } } catch (Exception ex) { throw ex; } }