Esempio n. 1
0
            public static List <int> SaveParticipants(object[] obj, int meetingID)
            {
                using (boxEntities box = new boxEntities())
                {
                    List <int> Parties = new List <int>();
                    var        meeting = (from o in box.Meetings where o.MeetingID == meetingID select o).FirstOrDefault();
                    if (meeting != null)
                    {
                        foreach (var i in obj)
                        {
                            var item = (Dictionary <string, object>)i;
                            MeetingParticipant parti = new MeetingParticipant();

                            // get user id
                            var userid = Profile.getUserID(item["UserName"].ToString());
                            parti.UserID         = userid;
                            parti.Response       = MeetingReponse.Pending.ToString();
                            parti.Role           = item["Role"].ToString();
                            parti.Note           = item["Note"].ToString();
                            parti.InvitationDate = DateTime.Now;
                            Parties.Add(userid);

                            meeting.MeetingParticipants.Add(parti);
                            box.SaveChanges();
                            // for each agenda add agenda privacy
                            // get agneda
                            var agenda = (from o in box.Agenda
                                          where o.MeetingID == meetingID
                                          select o.AgendaID).ToList();
                            foreach (var g in agenda)
                            {
                                AgendaPrivacy p = new AgendaPrivacy();
                                p.CanSee   = false;
                                p.AgendaID = g;
                                p.PartiID  = parti.MeetingParti;
                                box.AgendaPrivacies.AddObject(p);
                            }
                        }

                        box.SaveChanges();
                        return(Parties);
                    }
                    else
                    {
                        throw new Exception("Error Saving Participants of the meeting MeetingClass.Participants.SaveParticipants");
                    }
                }
            }
Esempio n. 2
0
            public static Agendum SaveAgenda(string count, string title, string desc, int meetingID, bool published, int?subagenda)
            {
                try
                {
                    using (boxEntities box = new boxEntities())
                    {
                        Agendum ag = new Agendum();
                        ag.AgendaCount = count;
                        ag.AgendaTitle = title;
                        ag.AgendaDesc  = desc;
                        ag.MeetingID   = meetingID;
                        ag.Published   = published;
                        ag.Privacy     = AgendaStatus.Public.ToString();
                        if (subagenda != 0)
                        {
                            ag.SubAgenda = subagenda;
                        }

                        box.Agenda.AddObject(ag);
                        box.SaveChanges();

                        // get meeting participants and save them in agenda privacy
                        var parti = (from o in box.MeetingParticipants
                                     where o.MeetingID == meetingID
                                     select o).ToList();
                        foreach (var p in parti)
                        {
                            AgendaPrivacy pri = new AgendaPrivacy();
                            pri.AgendaID = ag.AgendaID;
                            pri.PartiID  = p.MeetingParti;
                            pri.CanSee   = false;
                            if (p.Role == MeetingRoles.Creator.ToString())
                            {
                                pri.CanSee = true;
                            }
                            box.AgendaPrivacies.AddObject(pri);
                        }
                        box.SaveChanges();
                        return(ag);
                    }
                }
                catch
                {
                    throw new Exception();
                }
            }