public static bool AddDelegation(string sessionId, string Emp_Id, DateTime start, DateTime end)
        {
            if (Emp_Id == null || Emp_Id == "")
            {
                return(false);
            }
            if (!DelegationServices.IsDateValid(start, end))
            {
                return(false);
            }

            if (!DelegationServices.CheckDelegationPossibleOrNot(sessionId, start, end))
            {
                return(false);
            }
            //if no one in the range the new Delegate can be added for that date range
            Emp_Delegation temp = new Emp_Delegation();

            //db is a DAO.
            temp.Employee   = db.employees.Where(x => x.Emp_Id == Emp_Id).FirstOrDefault();
            temp.Emp_Id     = Emp_Id;
            temp.Start_Date = start;
            temp.End_Date   = end;
            temp.Status     = "ACTIVE";
            db.emp_Delegations.AddOrUpdate(temp);
            db.SaveChanges();
            return(true);
        }
        public static bool CheckIsDelegated(string sessionId)
        {
            DelegationServices.ValidateDelegateStatus(sessionId);
            var User = LoginServices.GetUserBySessionId(sessionId);

            if (db.emp_Delegations.Any(x => x.Emp_Id == User.Emp_Id && x.Status == "ACTIVE"))
            {
                return(true);
            }
            //Not Delegated For Particular Time Period
            return(false);
        }
        public static Employee GetCurrentDelegate(string sessionId)
        {
            DelegationServices.ValidateDelegateStatus(sessionId);
            var cur  = DateTime.Now;
            var user = LoginServices.GetUserBySessionId(sessionId);
            var list = db.emp_Delegations.Where(x => cur >= x.Start_Date && cur >= x.Start_Date && cur <= x.End_Date && x.Employee.Department.Dept_id == user.Dept_Id && x.Status == "ACTIVE").FirstOrDefault();

            if (list == null)
            {
                return(null);
            }
            return(list.Employee);
        }