Ejemplo n.º 1
0
        public void Run(string connection, string param)
        {
            Dictionary <string, string> args = GetArgs(param);

            using (Context ctx = new Context(connection))
            {
                UserDataMapper       usrMapper  = new UserDataMapper(ctx);
                ConferenceDataMapper confMapper = new ConferenceDataMapper(ctx);
                User       user = null;
                Conference conf = null;
                if (args.TryGetValue("-i", out string id))
                {
                    user = usrMapper.Read(int.Parse(id));
                }
                if (args.TryGetValue("-c", out id))
                {
                    conf = confMapper.Read(int.Parse(id));
                }
                if (conf != null && user != null)
                {
                    int res = usrMapper.updateUserRole(user, conf);
                    Console.WriteLine(res == 1 ? "updated successfully!" : "couldn't give the role");
                    Console.WriteLine();
                }
            }
        }
Ejemplo n.º 2
0
        public void Run(string connection, string param)
        {
            Dictionary <string, string> dic = GetArgs(param);

            using (Context ctx = new Context(connection))
            {
                UserDataMapper       usrMapper = new UserDataMapper(ctx);
                SubmissionDataMapper subMapper = new SubmissionDataMapper(ctx);
                User       reviewer            = null;
                Submission sub = null;
                string     id;
                if (dic.TryGetValue("-ir", out id))
                {
                    reviewer = usrMapper.Read(int.Parse(id));
                }
                if (dic.TryGetValue("-is", out id))
                {
                    sub = subMapper.Read(int.Parse(id));
                }
                if (reviewer != null && sub != null)
                {
                    int res = usrMapper.assignReviewerToReview(reviewer, sub);
                    Console.WriteLine(res == 1 ? "successfully assign!" : "couldn't assign the reviewer to the review!");
                    Console.WriteLine();
                }
            }
        }
Ejemplo n.º 3
0
        internal List <User> LoadAuthors(Submission s)
        {
            List <User> lst = new List <User>();

            UserDataMapper        um         = new UserDataMapper(context);
            List <IDataParameter> parameters = new List <IDataParameter>();

            parameters.Add(new SqlParameter("@id", s.id));
            using (IDataReader rd = ExecuteReader("select idUtilizador from Autor_Submissao where idSubmissao=@id", parameters))
            {
                while (rd.Read())
                {
                    int key = rd.GetInt32(0);
                    lst.Add(um.Read(key));
                }
            }
            return(lst);
        }
Ejemplo n.º 4
0
        internal User LoadPresident(Conference c)
        {
            UserDataMapper        usrm       = new UserDataMapper(context);
            List <IDataParameter> parameters = new List <IDataParameter>
            {
                new SqlParameter("@id", c.id)
            };

            using (IDataReader reader = ExecuteReader("select idPresidente from Conferencia where id=@id", parameters))
            {
                while (reader.Read())
                {
                    int key = reader.GetInt32(0);
                    return(usrm.Read(key));
                }
            }
            return(null);
        }
Ejemplo n.º 5
0
        internal List <User> LoadAllUsers(Conference c)
        {
            List <User>       lst         = new List <User>();
            UserDataMapper    um          = new UserDataMapper(context);
            List <Submission> submissions = LoadSubmissions(c);

            submissions.ForEach(submission =>
            {
                List <IDataParameter> parameters = new List <IDataParameter>
                {
                    new SqlParameter("@id", submission.id)
                };
                using (IDataReader rd = ExecuteReader("select idUtilizador from Autor_Submissao where idSubmissao=@id", parameters))
                {
                    while (rd.Read())
                    {
                        int key = rd.GetInt32(0);
                        lst.Add(um.Read(key));
                    }
                }
            });
            return(lst);
        }
Ejemplo n.º 6
0
        internal List <User> LoadCompatibleReviewers(Submission s, Conference c)
        {
            List <User>    lst = new List <User>();
            UserDataMapper um  = new UserDataMapper(context);

            using (IDbCommand cmd = context.CreateCommand())
            {
                SqlParameter p1 = new SqlParameter("@idSubmissao", SqlDbType.Int);
                SqlParameter p2 = new SqlParameter("@idConf", SqlDbType.Int);
                p1.Value        = s.id;
                p2.Value        = c.id;
                cmd.CommandText = "select * from si2.listReviwers(@idSubmissao, @idConf)";
                cmd.CommandType = CommandType.Text;
                cmd.Parameters.Add(p1);
                cmd.Parameters.Add(p2);
                IDataReader reader = cmd.ExecuteReader();
                while (reader.Read())
                {
                    int key = reader.GetInt32(0);
                    lst.Add(um.Read(key));
                }
                return(lst);
            }
        }