Пример #1
0
        public void GetAccountDetails()
        {
            List<Availability> availability = new List<Availability>()
            {
                new Availability(1, "Mo", "Ochtend"),
                new Availability(2, "Mo", "Avond"),
                new Availability(3, "Tu", "Avond")
            };

            List<Skill> skills = new List<Skill>()
            {
                new Skill(1, "Programming"),
                new Skill(1, "Logical thinking"),
                new Skill(1, "Working"),
                new Skill(1, "Driver experience")
            };
            Account a = new Account(
                1,
                "Biepbot",
                "*****@*****.**",
                "Rowan Dings",
                "Turfveldenstraat 12",
                "Eindhoven",
                "+31 0402920180",
                "0",
                "1",
                DateTime.Now,
                "1",
                DateTime.Now,
                "Avatar.png",
                "VOG.pdf",
                "Man",
                skills,
                availability);
            Accountdetails ad = (Accountdetails)Creation.getDetailsObject(a);
            ad.AvailabilityDetailList = availability.Select(ava => Creation.getDetailsObject(ava)).Cast<Availabilitydetails>().ToList();
            ad.SkillsDetailList = skills.Select(ski => Creation.getDetailsObject(ski)).Cast<Skilldetails>().ToList();
            for (int i = 0; i < a.Availability.Count; i++ )
            {
                if (a.Availability[i].Day != ad.AvailabilityDetailList[i].Day)
                {
                    Assert.Fail("Failed to write Rating properly");
                }
                if (a.Availability[i].Daytime != ad.AvailabilityDetailList[i].Daytime)
                {
                    Assert.Fail("Failed to write Rating properly");
                }
                if (a.Skills[i].Name != ad.SkillsDetailList[i].Name)
                {
                    Assert.Fail("Failed to write Rating properly");
                }
                if (a.Skills[i].UserID != ad.SkillsDetailList[i].UserID)
                {
                    Assert.Fail("Failed to write Rating properly");
                }
            }
        }
Пример #2
0
 //TODO
 public static void LogOut(Account acc)
 {
     //Log the given user out
 }
Пример #3
0
 /// <summary>
 /// Finds account credentials and fills in account information
 /// </summary>
 /// <param name="row">The DataRow to process</param>
 /// <returns>Returns an account</returns>
 private static Account CreateAccount(DataRow row)
 {
     int userid = Convert.ToInt32(row["ID"]);
     //Get availability and skills
     Account acc = null;
     //Create account
     acc = new Account(
         userid,
         row["Gebruikersnaam"].ToString(),
         row["Email"].ToString(),
         row["Naam"].ToString(),
         row["Adres"].ToString(),
         row["Woonplaats"].ToString(),
         row["Telefoonnummer"].ToString(),
         row["HeeftRijbewijs"].ToString(),
         row["HeeftAuto"].ToString(),
         Convert.ToDateTime(row["Uitschrijvingsdatum"]),
         row["OVMogelijk"].ToString(),
         Convert.ToDateTime(row["Geboortedatum"]),
         row["Foto"].ToString(),
         row["VOG"].ToString(),
         row["Geslacht"].ToString(),
         Skill.GetAll(userid),
         Class_Layer.Availability.GetAll(userid)
         );
     return acc;
 }
Пример #4
0
        /// <summary>
        /// Logs a user in
        /// </summary>
        /// <param name="username">The given username</param>
        /// <param name="password">The given password</param>
        /// <param name="acc">The account if it exists and matches</param>
        /// <returns>Whether it is a valid combination or not</returns>
        public static bool LogIn(string username, string password, out Account acc)
        {
            //By default, there is no user found, and no user will be given
            bool matchingaccount = false;
            acc = null;
            //Find username in database
            DataTable dt = Database_Layer.Database.RetrieveQuery("SELECT * FROM \"Acc\" WHERE \"Gebruikersnaam\" = '" + username + "'");

            //Check if there's a username with this password
            foreach (DataRow row in dt.Rows)
            {
                //If exists && matches
                if (PasswordHashing.ValidatePassword(password, (row["Wachtwoord"].ToString())))
                {
                    matchingaccount = true;
                    acc = CreateAccount(row);

                    break;
                }
            }
            return matchingaccount;
        }
Пример #5
0
 /// <summary>
 /// Initializes an instance of the account class through its ID
 /// </summary>
 /// <param name="id">The ID of the user</param>
 private static Account GetAccount(int id)
 {
     Account acc = null;
     //Fetch Account from database
     DataTable AccountTable = Database_Layer.ChatDatabase.RetrieveQuery("SELECT * FROM ACC WHERE ID = " + id);
     foreach (DataRow AccountInformation in AccountTable.Rows)
     {
         acc = new Account(
             Convert.ToInt32(AccountInformation["ID"]),
             AccountInformation["Name"].ToString(),
             Convert.ToInt32(AccountInformation["IsOnline"]),
             Convert.ToDateTime(AccountInformation["LastSeen"]));
     }
     return acc;
 }
Пример #6
0
        /// <summary>
        /// Registers a new account
        /// </summary>
        /// <param name="acc">The account details</param>
        /// <param name="message">The error message</param>
        /// <returns>Yields a true if the user could be created</returns>
        public bool Register(Accountdetails acc, string password1, string password2, out string message)
        {
            message = string.Empty;
            //Validate details
            if (!Check.CheckAccount(acc, out message))
            {
                return false;
            }
            if (password1 != password2)
            {
                message = "Wachtwoorden komen niet overeen!";
                return false;
            }
            //Register account
            MainUser = Account.Register(acc.Username, password1, acc.Email, acc.Name, acc.Address, acc.City, acc.Phonenumber,
                Convert.ToBoolean(acc.hasDriverLicense),
                Convert.ToBoolean(acc.hasVehicle),
                Convert.ToBoolean(acc.OVPossible), acc.Birthdate, acc.AvatarPath, acc.VOGPath, acc.Gender);
            //Send email
            MailMessage mail = new MailMessage();
            SmtpClient SmtpServer = new SmtpClient("smtp.gmail.com");

            mail.From = new MailAddress("*****@*****.**");
            mail.To.Add(acc.Email);
            mail.Subject = "U hebt een account geregistreerd voor ICT4Participation";
            mail.Body = "Hallo!"
                + "\nU kunt nu registreren door middel van uw account:"
                + "\n" + acc.Username
                + "\nVoor vragen en contact kunt u het volgende emailadres mailen: [email protected]"
                + "\n"
                + " \nMet vriendelijke groet,"
                + "\nHet ICT4Participation-Team";

            SmtpServer.Port = 587;
            SmtpServer.Credentials = new System.Net.NetworkCredential("*****@*****.**", "Em72@Gmai111");
            SmtpServer.EnableSsl = true;

            SmtpServer.Send(mail);

            return true;
        }
Пример #7
0
 /// <summary>
 /// Logs the last user out
 /// </summary>
 public void LogOut()
 {
     //Log user out
     Account.LogOut(MainUser);
     MainUser = null;
 }
Пример #8
0
 /// <summary>
 /// Logs the main user in
 /// </summary>
 /// <param name="userID"></param>
 public string LogIn(int userID)
 {
     //Call account to get new main user
     MainUser = Account.GetMainUser(userID);
     return MainUser.Name;
 }