예제 #1
0
        /// <summary>
        /// Deletes a given team.
        /// </summary>
        /// <param name="pTeam">Receives the team that is meant to be deleted</param>
        /// <returns></returns>
        public static pojo.Team deleteTeam(pojo.Team pTeam)
        {
            using (var context = new synupEntities())
            {
                pojo.Team _oTeam = readTeam(pTeam.code, context); //Finds the received team in the database.

                if (_oTeam != null)                               //If the team has been found - meaning that it exists:
                {
                    if (checkTeamMembers(_oTeam))
                    {
                        //tryAttach(context, _oTeam);
                        context.Teams.Remove(_oTeam); //Will be deleted.
                        if (commitChanges(context))
                        {
                            return(_oTeam);                        //If the changes are commited succesfully it will return the deleted Team.
                        }
                        else
                        {
                            return(null);
                        }
                    }
                }
            }
            return(null);
        }
예제 #2
0
 /// <summary>
 /// Receives the team that is meant to be updated
 /// </summary>
 /// <param name="pTeam">Receives the team that will be updated</param>
 /// <returns>Returns a boolean whether the team has been updated succesfully or not.</returns>
 public static bool updateTeam(pojo.Team pTeam)
 {
     using (var context = new synupEntities())
     {
         pojo.Team _oTeam = readTeam(pTeam.code, context);
         //tryAttach(context, _oTeam);
         _oTeam.name = pTeam.name;
         return(commitChanges(context));
     }
 }
예제 #3
0
        /// <summary>
        /// Creates a given team.
        /// </summary>
        /// <param name="pTeam">Receives the object Team that will be inserted in the database.</param>
        /// <returns>Returns a boolean depending in the outcome of the insert - true if it is successfull</returns>
        public static bool createTeam(pojo.Team pTeam)
        {
            //openConnection();

            pojo.Team _oTeam = readTeam(pTeam.code); //Finds the received team in the database.

            if (_oTeam == null)                      //If the team doesn't exist already in the database, it will be inserted.
            {
                using (var context = new synupEntities())
                {
                    context.Teams.Add(pTeam);
                    return(commitChanges(context));
                }
            }

            return(false);
        }