Exemplo n.º 1
0
        //To generate new passcode
        public string generateNewPasscode(string dep)
        {
            //DepartmentRepresentative depRep = context.DepartmentRepresentatives
            //    .First(dr => dr.Employee.DepartmentID == dep);
            DepartmentRepresentative currentRepresentative = getCurrentDepartmentRepresentative(dep);
            DepartmentRepresentative depRep = context.DepartmentRepresentatives.Where(x => x.DeptRepID == currentRepresentative.DeptRepID).First();
            Random num      = new Random();
            int    passcode = num.Next(1000, 9999);

            depRep.Passcode = Convert.ToString(passcode);
            context.SaveChanges();
            return(Convert.ToString(passcode));
        }
Exemplo n.º 2
0
        public List <Employee> getEligibleDelegatedAuthority(string deptId)
        {
            List <Employee> employees           = getEmployeesOfDepartment(deptId);
            List <Employee> ineligibleEmployees = new List <Employee>();

            ineligibleEmployees.Add(context.Departments.First(d => d.DepartmentID == deptId).DepartmentHead);
            DepartmentRepresentative currentDeptRepresentative = getCurrentDepartmentRepresentative(deptId);

            if (currentDeptRepresentative != null)
            {
                ineligibleEmployees.Add(currentDeptRepresentative.Employee);
            }
            return(employees.Where(e => !ineligibleEmployees.Contains(e)).ToList());
        }
Exemplo n.º 3
0
        //update old representative enddate and add new departmentRepresentative
        public void updateDepartmentRepresentative(int currentDeptRepId, string newRepEmpId)
        {
            DepartmentRepresentative currentDeptRepresentative = context.DepartmentRepresentatives
                                                                 .Where(d => d.DeptRepID == currentDeptRepId).FirstOrDefault();

            if (currentDeptRepresentative != null)
            {
                currentDeptRepresentative.EndDate = DateTime.Today;
            }

            DepartmentRepresentative newDepRep = new DepartmentRepresentative();

            newDepRep.EmployeeID = newRepEmpId;
            String deptID = getDepartmentID(newDepRep.EmployeeID);

            newDepRep.StartDate = DateTime.Today.AddDays(1);
            newDepRep.Passcode  = generateNewPasscode(deptID);
            context.DepartmentRepresentatives.Add(newDepRep);
            context.SaveChanges();
        }
Exemplo n.º 4
0
        public bool verifyPassCode(string passcode, string dep)
        {
            DepartmentRepresentative depRep = getCurrentDepartmentRepresentative(dep);

            return(depRep.Passcode == passcode);
        }
Exemplo n.º 5
0
 public static DepartmentRepresentativePayload ConvertToDepartmentRepresentativePayload(DepartmentRepresentative d)
 {
     if (d != null)
     {
         return(new DepartmentRepresentativePayload(d));
     }
     else
     {
         return(null);
     }
 }
Exemplo n.º 6
0
 public DepartmentRepresentativePayload(DepartmentRepresentative d)
 {
     DeptRepID    = d.DeptRepID;
     EmployeeName = d.Employee.EmployeeName;
 }