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; }
public List<MaintenanceTicket> GetMaintenanceTickets() { ZooTykoonDb db = new ZooTykoonDb(); return db.MaintenanceTickets.ToList().FindAll(x => x.Zoo == this); }
public List<LineItem> GetLineItems() { ZooTykoonDb db = new ZooTykoonDb(); return db.LineItems.ToList().FindAll(x => x.Zoo == this); }
public List<ScheduleEvent> GetSchedule() { ZooTykoonDb db = new ZooTykoonDb(); return db.ScheduleEvents.ToList().FindAll(x => x.Animal == this); }
public List<MedicalRecord> GetMedicalRecords() { ZooTykoonDb db = new ZooTykoonDb(); return db.MedicalRecords.ToList().FindAll(x => x.Animal == this); }
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; }
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; }