Exemplo n.º 1
0
        public void TestUserWithPasswordWrongResult()
        {
            Dictionary <string, string> user = new Dictionary <string, string>();

            Lifting_Hands_Backend.Persistence.User result = Util.dict2UserWithPassword(user);
            Assert.IsTrue(result == null);
        }
Exemplo n.º 2
0
 static public Persistence.User dict2UserNoPassword(Dictionary <string, string> user)
 {
     try
     {
         Persistence.User userData = new Persistence.User();
         userData.User_CID           = Int32.Parse(user["National_ID"]);
         userData.User_Name          = user["Name"];
         userData.User_Email         = user["Email"];
         userData.User_Role_ID       = GetRoleType(user["Role"]);
         userData.User_Date_of_birth = DateTime.Parse(user["DOB"]);
         userData.User_Cellphone     = Int32.Parse(user["Phone"]);
         return(userData);
     }
     catch (Exception e)
     {
         Console.WriteLine(e.Message.ToString());
         return(null);
     }
 }
Exemplo n.º 3
0
        static void Main()
        {
            //New session
            Session session = new Session();
            bool    logged  = false;

            try
            {
                logged = session.AuthenticateUser(1, "1234", "administrator");
                //logged = proxy.session.AuthenticateUser(1, "1234", "volunteer");
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message.ToString());
            }


            //Update user if there's an open session
            if (logged)
            {
                session.user.SetPassword("1234");
                session.user.SetEmail("*****@*****.**");
                session.user.SaveChanges();

                Dictionary <string, string> student = new Dictionary <string, string>();
                student.Add("National_ID", "5");
                student.Add("Name", "Abby");
                student.Add("Role", "Student");
                student.Add("Email", "*****@*****.**");
                student.Add("DOB", "6/1/2019");
                student.Add("Phone", "1");

                session.user.AddUser(student);
                Persistence.User userData = session.user.FetchUser(Int32.Parse(student["National_ID"]), Util.GetRoleType(student["Role"]));
                session.user.RemoveUser(userData.User_ID);
            }


            //Application.EnableVisualStyles();
            //Application.SetCompatibleTextRenderingDefault(false);
            //Application.Run(new GUI.Form_Main());
        }
Exemplo n.º 4
0
 /// <summary>
 /// Modifies a person in the data base. Returns false on error or incorrect dictionary keys.
 /// </summary>
 /// <param name="id">Type int. ID of the person</param>
 /// <param name="person">Type Dictionarty <string,string>. Collection of the person's data.</param>
 /// <returns></returns>
 public override bool ModifyPerson(int id, Dictionary <string, string> person)
 {
     try
     {
         CRUD.User        CRUDPerson = new CRUD.User();
         Persistence.User personData = Util.dict2UserWithPassword(person);
         if (personData != null)
         {
             CRUDPerson.UpdateDBData(personData.User_ID, (Persistence.User)personData);
             return(true);
         }
         else
         {
             throw new ArgumentException("One or more of the required keys were not found.");
         }
     }
     catch (Exception e)
     {
         Console.WriteLine(e.Message.ToString());
         return(false);
     }
 }
Exemplo n.º 5
0
 public Administrator(Persistence.User user) : base(user)
 {
 }
Exemplo n.º 6
0
 public Person(Persistence.User user)
 {
     this.userData = user;
 }
Exemplo n.º 7
0
 public Volunteer(Persistence.User user) : base(user)
 {
 }
Exemplo n.º 8
0
 public Student(Persistence.User user) : base(user)
 {
 }