Ejemplo n.º 1
0
        public IEnumerable <Planning> QueryPlanningsFromMember(int idUser, bool onlyGranted)
        {
            IList <Planning>    plannings        = new List <Planning>();
            IFactory <Planning> _planningFactory = new PlanningFactory();

            using (SqlConnection connection = Database.GetConnection())
            {
                connection.Open();
                SqlCommand command_1 = connection.CreateCommand();

                // si onlyGrated, on ne récupère que les granted users
                if (onlyGranted)
                {
                    command_1.CommandText = MemberQueries.ReqQueryPlanningsFromGrantedMember;
                }
                else
                {
                    command_1.CommandText = MemberQueries.ReqQueryPlanningsFromMember;
                }

                command_1.Parameters.AddWithValue($"@{MemberQueries.ColIdUser}", idUser);

                SqlDataReader reader_1 = command_1.ExecuteReader();

                while (reader_1.Read())
                {
                    plannings.Add(_planningFactory.CreateFromReader(reader_1));
                }

                SqlCommand command_2 = connection.CreateCommand();
                command_2.CommandText = PlanningQueries.ReqGetBySuperUser;
                command_2.Parameters.AddWithValue($"@{PlanningQueries.ColIdSuperUser}", idUser);

                reader_1.Close();

                SqlDataReader reader_2 = command_2.ExecuteReader(CommandBehavior.CloseConnection);

                if (reader_2.Read())
                {
                    plannings.Add(_planningFactory.CreateFromReader(reader_2));
                }
            }

            return(plannings);
        }
Ejemplo n.º 2
0
        public IEnumerable <Planning> QueryPlanningsOfUserRecever(int idUserRecever)
        {
            IFactory <Planning> _planningFactory = new PlanningFactory();
            IList <Planning>    invitedPlannings = new List <Planning>();

            using (var connection = Database.GetConnection())
            {
                connection.Open();
                var command = connection.CreateCommand();

                command.CommandText = InvitationQueries.ReqGetPlanningsOfUserRecever;
                command.Parameters.AddWithValue($"@{InvitationQueries.ColIdUserRecever}", idUserRecever);

                var reader = command.ExecuteReader(CommandBehavior.CloseConnection);

                while (reader.Read())
                {
                    invitedPlannings.Add(_planningFactory.CreateFromReader(reader));
                }
            }

            return(invitedPlannings);
        }