/// <summary>
        /// Attachs teams
        /// </summary>
        /// <param name="pContext"></param>
        /// <param name="pTeamHistory">The object which were attachs</param>
        private static void tryAttach(synupEntities pContext, pojo.TeamHistory pTeamHistory)
        {
            var entry = pContext.Entry(pTeamHistory);

            if (entry.State == System.Data.Entity.EntityState.Detached)
            {
                pContext.TeamHistories.Attach(pTeamHistory);
            }
        }
        /// <summary>
        /// Updates a given teamHistory with the new parameters of it.
        /// </summary>
        /// <param name="pTeamHistory">Receives the teamHistory that will be updated.</param>
        /// <returns>Returns a boolean whether the teamHistory has been updated succesfully or not.</returns>
        public static bool updateTeamHistory(String pNif, String pCodeTeam /*, DateTime pEntranceDate,*/, DateTime pExitDate)
        {
            using (var context = new synupEntities())
            {
                pojo.TeamHistory modifiedTeamHistory = null;

                modifiedTeamHistory = readTeamHistory(pNif, pCodeTeam, context);


                if (modifiedTeamHistory != null)
                {
                    tryAttach(context, modifiedTeamHistory);
                    //modifiedTeamHistory.id_employee = pNif;
                    //modifiedTeamHistory.id_team = pCodeTeam;
                    //modifiedTeamHistory.entranceDay = pEntranceDate;
                    modifiedTeamHistory.exitDate = pExitDate;
                }

                return(commitChanges(context));
            }
        }
        /// <summary>
        /// Deletes a given teamHistory.
        /// </summary>
        /// <param name="t">Receives the teamHistory that is meant to be deleted.</param>
        /// <returns>Returns the teamHistory that has been deleted.</returns>
        public static pojo.TeamHistory deleteTeamHistory(String pNif, String pCode)
        {
            using (var context = new synupEntities())
            {
                pojo.TeamHistory foundTeamHistory = readTeamHistory(pNif, pCode, context); //Finds the received teamHistory in the database.

                if (foundTeamHistory != null)                                              //If the teamHistory has been found - meaning that it exists:
                {
                    tryAttach(context, foundTeamHistory);
                    //foundTeamHistory
                    //foundTeamHistory.Team = null;
                    context.TeamHistories.Remove(foundTeamHistory); //Will be deleted.
                    if (commitChanges(context))
                    {
                        return(foundTeamHistory);                        //If the changes are commited succesfully it will return the deleted TeamHistory.
                    }
                    else
                    {
                        return(null);
                    }
                }
            }
            return(null);
        }