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 InActivateDelegate(int Del_Id) { Emp_Delegation temp = db.emp_Delegations.Where(x => x.Delegate_Id == Del_Id).FirstOrDefault(); temp.Status = "INACTIVE"; db.emp_Delegations.AddOrUpdate(temp); db.SaveChanges(); return(true); }