public void Insert(MeetingViewModel meeting, ModelStateDictionary modelState)
        {
            if (ValidateModel(meeting, modelState))
            {
                if (meeting.Attendees == null)
                {
                    meeting.Attendees = new string[0];
                }

                if (string.IsNullOrEmpty(meeting.Title))
                {
                    meeting.Title = "";
                }

                var entity = meeting.ToEntity();
                entity.RoomID = meeting.RoomID;
                foreach (var attendeeId in meeting.Attendees)
                {
                    MeetingAttendee attendee = new MeetingAttendee();
                    attendee.MeetingID  = meeting.MeetingID;
                    attendee.AttendeeID = attendeeId;
                    db.MeetingAttendees.Add(attendee);
                }
                db.Meetings.Add(entity);
                db.SaveChanges();
                meeting.MeetingID = entity.MeetingID;
            }
        }
        public void Update(MeetingViewModel meeting, ModelStateDictionary modelState)
        {
            if (ValidateModel(meeting, modelState))
            {
                if (string.IsNullOrEmpty(meeting.Title))
                {
                    meeting.Title = "";
                }
                var entity = db.Meetings.FirstOrDefault(m => m.MeetingID == meeting.MeetingID);
                entity.Title               = meeting.Title;
                entity.Start               = meeting.Start;
                entity.End                 = meeting.End;
                entity.Description         = meeting.Description;
                entity.IsAllDay            = meeting.IsAllDay;
                entity.RoomID              = meeting.RoomID;
                entity.RecurrenceID        = meeting.RecurrenceID;
                entity.RecurrenceRule      = meeting.RecurrenceRule;
                entity.RecurrenceException = meeting.RecurrenceException;
                entity.StartTimezone       = meeting.StartTimezone;
                entity.EndTimezone         = meeting.EndTimezone;
                entity.Oplink              = meeting.OpLink;
                entity.AddAttend           = meeting.AddAttend;
                entity.FileLink            = meeting.FileLink;
                entity.Record              = meeting.Record;
                entity.Recfile             = meeting.Recfile;
                entity.InitName            = meeting.InitName;
                entity.FName               = meeting.FName;



                foreach (var meetingAttendee in entity.MeetingAttendees.ToList())
                {
                    db.MeetingAttendees.Remove(meetingAttendee);
                }

                if (meeting.Attendees != null)
                {
                    foreach (var attendeeId in meeting.Attendees)
                    {
                        var meetingAttendee = new MeetingAttendee
                        {
                            MeetingID  = meeting.MeetingID,
                            AttendeeID = attendeeId
                        };

                        db.MeetingAttendees.Add(meetingAttendee);
                    }
                }

                db.SaveChanges();
            }
        }