示例#1
0
        /// <summary>
        /// Denne testmetode kan benyttes til at gemme nye profiler til login.
        /// </summary>
        /// <returns></returns>
        public object Savelogin()
        {
            DTO_UserData user = new DTO_UserData("1", "2");
            string       path = @"C:\ST3PRJ3FIL\Users";

            using (StreamWriter file = File.AppendText(path))
            {
                JsonSerializer serializer = new JsonSerializer();
                serializer.Formatting = Formatting.Indented;
                serializer.Serialize(file, user);
                file.Close();
            }

            return(user);
        }
示例#2
0
        /// <summary>
        /// Denne metode tjekker om et givent brugernavn og password matcher med databasen.
        /// </summary>
        /// <param name="socSecNb"></param>
        /// <param name="pw"></param>
        /// <returns></returns>
        public bool isUserRegistered(String socSecNb, String pw)
        {
            string              path     = @"C:\ST3PRJ3FIL\Users";
            DTO_UserData        userdata = new DTO_UserData(socSecNb, pw);
            List <DTO_UserData> pwlogin  = new List <DTO_UserData>();

            try
            {
                using (StreamReader r = new StreamReader(path))
                {
                    string test;
                    string json = r.ReadToEnd();

                    userdata = JsonConvert.DeserializeObject <DTO_UserData>(json);

                    // foreach (var VARIABLE in userdata)
                    {
                        //pwlogin.Add(userdata.Username, userdata.Password);
                    }

                    pwlogin.Add(userdata);
                    r.Close();
                }
            }
            catch
            {
            }
            foreach (var VARIABLE in pwlogin)
            {
                var username = Convert.ToString(userdata.Username);
                var password = Convert.ToString(userdata.Password);

                if (socSecNb.ToString() == username && pw.ToString() == password)
                {
                    result = true;
                }
                else
                {
                    result = false;
                }
            }


            return(result);
        }
示例#3
0
        /// <summary>
        /// Denne metode henter et personnummer fra databasen.
        /// </summary>
        /// <param name="SocSecNB"></param>
        /// <returns></returns>
        public bool getSocSecNB(string SocSecNB)
        {
            string              path     = @"C:\ST3PRJ3FIL\Users";
            DTO_UserData        userdata = new DTO_UserData("", "");
            List <DTO_UserData> userData = new List <DTO_UserData>();

            try
            {
                using (StreamReader r = new StreamReader(path))
                {
                    string json = r.ReadToEnd();


                    userdata = JsonConvert.DeserializeObject <DTO_UserData>(json);
                    userData.Add(userdata);


                    foreach (var VARIABLE in userData)
                    {
                        var username = userdata.Username;

                        if (username.ToString() == SocSecNB)
                        {
                            result = true;
                        }
                        else
                        {
                            result = false;
                        }
                    }

                    r.Close();
                }
            }
            catch
            {
                return(false);
            }

            return(result);
        }