Exemple #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();
                }
            }
        }
Exemple #2
0
 public JsonResult Show()
 {
     try
     {
         DataSet          dsRecord    = new DataSet();
         UserDataAccessor objAccessor = new UserDataAccessor();
         dsRecord = objAccessor.GetUserData();
         List <UserModel> userList = new List <UserModel>();
         if (dsRecord != null && dsRecord.Tables.Count > 0 && dsRecord.Tables[0].Rows.Count > 0)
         {
             userList = UserDataMapper.MapUserInfo(dsRecord);
             success  = true;
         }
         return(Json(new { userList, success }, JsonRequestBehavior.AllowGet));
     }
     catch (Exception ex)
     {
         success = false;
         message = ex.Message;
         return(Json(
                    new
         {
             success,
             message
         }, JsonRequestBehavior.AllowGet));
     }
 }
Exemple #3
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();
                }
            }
        }
Exemple #4
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);
        }
Exemple #5
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);
        }
Exemple #6
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);
        }
Exemple #7
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);
            }
        }
Exemple #8
0
        public void TestMapDataToDom()
        {
            User user = new User
            {
                Name       = "test",
                LastName   = "test",
                Email      = "*****@*****.**",
                Password   = "******",
                Phone      = "1234567890",
                UserName   = "******",
                Salt       = "Salt",
                CreateDate = DateTime.Now,
                UserID     = 1
            };
            UserDataMapper mapper = new UserDataMapper(user);

            Assert.AreEqual(user.UserID, mapper.Destination.Id);
            Assert.AreEqual(user.UserName, mapper.Destination.UserName);
            Assert.AreEqual(user.Email, mapper.Destination.EMail);
            Assert.AreEqual(user.LastName, mapper.Destination.LastName);
            Assert.AreEqual(user.Name, mapper.Destination.Name);
            Assert.AreEqual(user.Phone, mapper.Destination.Phone);
            Assert.AreEqual(mapper.Destination.Password, string.Empty);
        }
 private User GetBoss()
 {
     return(UserDataMapper.Get(5));
 }
 public UserService(UserManager <User> userManager, JwtService jwtService, UserDataMapper userDataMapper)
 {
     _userManager    = userManager;
     _jwtService     = jwtService;
     _userDataMapper = userDataMapper;
 }