Пример #1
0
        public static User GetActiveUser(string sessionToken)
        {
            ZooTykoonDb db = new ZooTykoonDb();

            foreach (User user in db.Users.ToList())
            {
                if (sessionToken == user.SessionToken)
                {
                    return user;
                }
            }

            return null;
        }
Пример #2
0
        public List<MaintenanceTicket> GetMaintenanceTickets()
        {
            ZooTykoonDb db = new ZooTykoonDb();

            return db.MaintenanceTickets.ToList().FindAll(x => x.Zoo == this);
        }
Пример #3
0
        public List<LineItem> GetLineItems()
        {
            ZooTykoonDb db = new ZooTykoonDb();

            return db.LineItems.ToList().FindAll(x => x.Zoo == this);
        }
Пример #4
0
        public List<ScheduleEvent> GetSchedule()
        {
            ZooTykoonDb db = new ZooTykoonDb();

            return db.ScheduleEvents.ToList().FindAll(x => x.Animal == this);
        }
Пример #5
0
        public List<MedicalRecord> GetMedicalRecords()
        {
            ZooTykoonDb db = new ZooTykoonDb();

            return db.MedicalRecords.ToList().FindAll(x => x.Animal == this);
        }
Пример #6
0
        public static string Login(string username, string password)
        {
            ZooTykoonDb db = new ZooTykoonDb();

            foreach (User user in db.Users.ToList())
            {
                if (username == user.Name && HashSHA256(password) == user.Password)
                {
                    Random rnd = new Random();
                    user.SessionToken = HashSHA256(rnd.Next().ToString());
                    db.SaveChanges();
                    return user.SessionToken;
                }
            }

            return null;
        }
Пример #7
0
        public static void Logout(string sessionToken)
        {
            ZooTykoonDb db = new ZooTykoonDb();

            foreach (User user in db.Users.ToList())
            {
                if (sessionToken == user.SessionToken)
                {
                    user.SessionToken = null;
                    db.SaveChanges();
                    return;
                }
            }

            return;
        }