示例#1
0
        public static async Task <bool> DeleteMeeting(int meetingId, FaceRollContext context = null)
        {
            bool result = false;

            await Task.Run(() =>
            {
                using (context == null ? context = new FaceRollContext() : null)
                {
                    var match = context.Meetings.FirstOrDefault(m => m.MeetingId == meetingId);

                    if (match != null)
                    {
                        // Remove attendees
                        var attendees = context.Attendees.Where(a => a.MeetingId == meetingId).ToList();
                        context.Attendees.RemoveRange(attendees);

                        // Remove meeting
                        context.Meetings.Remove(match);
                        result = true;
                    }

                    context.SaveChanges();
                }
            });

            return(result);
        }
示例#2
0
        public static async Task AddMeeting(Meeting meeting, FaceRollContext context = null)
        {
            await Task.Run(() =>
            {
                using (context == null ? context = new FaceRollContext() : null)
                {
                    context.Meetings.Add(meeting);

                    context.SaveChanges();
                }
            });
        }
示例#3
0
 public static async Task AddAttendee(int meetingId, Attendee attendee, FaceRollContext context = null)
 {
     await Task.Run(() =>
     {
         using (context == null ? context = new FaceRollContext() : null)
         {
             if (!context.Attendees.Any(a => a.MeetingId == meetingId && a.AttendeeName.Trim().ToLower() == attendee.AttendeeName.Trim().ToLower()))
             {
                 context.Attendees.Add(attendee);
                 context.SaveChanges();
             }
         }
     });
 }
示例#4
0
        public static async Task <bool> DeleteAttendee(int attendeeId, FaceRollContext context = null)
        {
            bool result = false;

            await Task.Run(() =>
            {
                using (context == null ? context = new FaceRollContext() : null)
                {
                    var match = context.Meetings.FirstOrDefault(m => m.MeetingId == attendeeId);

                    if (match != null)
                    {
                        context.Meetings.Remove(match);
                        result = true;
                    }

                    context.SaveChanges();
                }
            });

            return(result);
        }