public List<Location> getAllItems()
        {
            var connector = DbConnector.Instance;
            if (!connector.Connected()) connector.Connect();

            //Create a list to store the result
            var results = new List<Location>();

            string query = "SELECT * FROM locations";

            //Create Command
            MySqlCommand cmd = new MySqlCommand(query, connector.Connection());
            MySqlDataReader dataReader = cmd.ExecuteReader();

            //Read the data and store them in the list
            while (dataReader.Read())
            {
                var new_Location = new Location((int)dataReader["id"],
                    dataReader["name"].ToString(),
                    dataReader["description"].ToString(),
                    dataReader["gmaps_url"].ToString());
                results.Add(new_Location);
            }

            //close Data Reader
            dataReader.Close();

            //return list to be displayed
            return results;
        }
Example #2
0
 public Event()
 {
     this.id = -1;
     this.name = "";
     this.description = "";
     this.datetime = DateTime.Now;
     this.location = new Location();
     this.teachers = new List<Teacher>();
 }
 public LocationModel Create(Location l)
 {
     return new LocationModel
     {
         parent_url = GetRootUrl(),
         url = GetUrlByApi("LocationApi", l.id),
         //id = l.id,
         name = l.name,
         gmaps_url = l.gmaps_url,
         description = l.description
     };
 }
Example #4
0
 public Event(int new_id, string new_name, DateTime new_datetime, int location_id, List<int> teacher_ids, string new_description = "")
 {
     this.id = new_id;
     this.name = new_name;
     this.datetime = new_datetime;
     if ( Timetable.Instance.locations.Any() ) this.location = Timetable.Instance.locations.Find(l => l.id==location_id);
     this.description = new_description;
     if (teacher_ids != null && teacher_ids.Any())
     {
         this.teachers = Timetable.Instance.teachers.FindAll(t => teacher_ids.Contains(t.id)).ToList();
     }
     else
     {
         this.teachers = new List<Teacher>();
     }
 }
Example #5
0
 public Event(int new_id, string new_name, DateTime new_datetime, Location new_location, string new_description = "", List<Teacher> new_teachers = null)
 {
     this.id = new_id;
     this.name = new_name;
     this.datetime = new_datetime;
     this.location = new_location;
     this.description = new_description;
     if (new_teachers != null)
     {
         this.teachers = new_teachers;
     }
     else
     {
         this.teachers = new List<Teacher>();
     }
 }
 public BaseModel CreateSummary(Location l)
 {
     return new BaseModel()
     {
         parent_url = GetRootUrl(),
         url = GetUrlByApi("LocationApi", l.id),
         name = l.name
     };
 }