コード例 #1
0
        public static Korisnik GetKorisnikByIme(string username)
        {
            Korisnik ret  = null;
            string   path = HostingEnvironment.MapPath("~/Files/Korisnici.txt");

            foreach (var line in File.ReadAllLines(path))
            {
                if (string.IsNullOrWhiteSpace(line) || string.IsNullOrEmpty(line))
                {
                    continue;
                }
                else
                {
                    string[] korisnik = line.Split('|');

                    if (korisnik[2] == username)
                    {
                        if (korisnik[5].ToLower() == "administrator")
                        {
                            ret = new Admin(korisnik[0], korisnik[1], korisnik[2], korisnik[3], korisnik[4]);
                        }
                        else if (korisnik[5].ToLower() == "gost")
                        {
                            ret = new Gost(korisnik[0], korisnik[1], korisnik[2], korisnik[3], korisnik[4]);
                        }
                        else
                        {
                            ret = new Domacin(korisnik[0], korisnik[1], korisnik[2], korisnik[3], korisnik[4]);
                        }
                    }
                    else
                    {
                        continue;
                    }
                }
            }
            return(ret);
        }
コード例 #2
0
        public static Korisnik GetKorisnik(string username, string password)
        {
            Korisnik ret  = null;
            string   path = HostingEnvironment.MapPath("~/Files/Korisnici.txt");

            foreach (var line in File.ReadAllLines(path))
            {
                if (string.IsNullOrWhiteSpace(line) || string.IsNullOrEmpty(line))
                {
                    continue;
                }
                else
                {
                    string[] korisnik = line.Split('|');

                    if (korisnik[2] == username && korisnik[3] == password)
                    {
                        if (korisnik[5] == "GOST")
                        {
                            ret = new Gost(korisnik[0], korisnik[1], korisnik[2], korisnik[3], korisnik[4]);
                        }
                        else if (korisnik[5] == "DOMACIN")
                        {
                            ret = new Domacin(korisnik[0], korisnik[1], korisnik[2], korisnik[3], korisnik[4]);
                        }
                        else
                        {
                            ret = new Admin(korisnik[0], korisnik[1], korisnik[2], korisnik[3], korisnik[4]);
                        }
                    }
                    else
                    {
                        continue;
                    }
                }
            }
            return(ret);
        }