Exemple #1
0
 public void JoinGroup(StudyGroup group)
 {
     Groups.Add(group);
     //update database
 }
Exemple #2
0
 public void SendMessage(StudyGroup group, String message)
 {
     group.GroupDiscussionBoard.SendMessage(message, this);
 }
Exemple #3
0
        public async Task <StudyGroup> GetStudyGroup(string id)
        {
            DocumentReference docRef   = db.Collection(STUDY_GROUPS_PATH).Document(id);
            DocumentSnapshot  snapshot = await docRef.GetSnapshotAsync();

            if (snapshot.Exists)
            {
                Dictionary <string, object> groupDict = snapshot.ToDictionary();
                foreach (KeyValuePair <string, object> pair in groupDict)
                {
                    Console.WriteLine("{0}: {1}", pair.Key, pair.Value);
                }

                List <object> temp        = (List <object>)groupDict[SG_MEET_DAYS_KEY];
                List <Days>   meetingDays = new List <Days>();
                //for (int i = 0; i < temp.Count; i++)
                foreach (object obj in temp)
                {
                    //l.Add((Days)((long)temp[i]));
                    //Console.WriteLine(l[i]);

                    if (((string)obj).Equals("Monday"))
                    {
                        meetingDays.Add(Days.Monday);
                    }
                    else if (((string)obj).Equals("Tuesday"))
                    {
                        meetingDays.Add(Days.Tuesday);
                    }
                    else if (((string)obj).Equals("Wednesday"))
                    {
                        meetingDays.Add(Days.Wednesday);
                    }
                    else if (((string)obj).Equals("Thursday"))
                    {
                        meetingDays.Add(Days.Thursday);
                    }
                    else if (((string)obj).Equals("Friday"))
                    {
                        meetingDays.Add(Days.Friday);
                    }
                    else if (((string)obj).Equals("Saturday"))
                    {
                        meetingDays.Add(Days.Saturday);
                    }
                    else if (((string)obj).Equals("Sunday"))
                    {
                        meetingDays.Add(Days.Sunday);
                        Console.WriteLine(meetingDays[meetingDays.Count - 1]);
                    }
                }

                temp = (List <object>)groupDict[SG_MEMBER_KEY];
                List <string> members = new List <string>();
                foreach (object obj in temp)
                {
                    members.Add((string)obj);
                }

                //foreach(var element in groupDict[SG_MEET_DAYS_KEY]){ }
                StudyGroup group = new StudyGroup((string)groupDict[SG_ADMIN_KEY], (String)groupDict[SG_NAME_KEY], (String)groupDict[SG_COURSE_KEY],
                                                  Convert.ToInt32((long)groupDict[SG_TIME_HOUR_KEY]), Convert.ToInt32((long)groupDict[SG_TIME_MINUTE_KEY]), meetingDays, Convert.ToInt32((long)groupDict[SG_DURATION_KEY]),
                                                  (Semester)((long)groupDict[SG_SEMESTER_KEY])
                                                  //Semester.Winter
                                                  , Convert.ToInt32((long)groupDict[SG_YEAR_KEY]), (String)groupDict[SG_DESC_KEY], members, (String)groupDict[SG_JOIN_URL]);
                return(group);
            }
            return(null);
        }