public IHttpActionResult PutMeeting(int id, [FromBody] Models.MeetingM meeting)
        {
            if (!ModelState.IsValid)
            {
                return(NotFound());
            }
            try
            {
                using (var ctx = new TrainingAndMeetingDBEntities())
                {
                    Meeting      tra             = new Meeting();
                    Schedule     sch             = new Schedule();
                    RoomDetail   rm              = new RoomDetail();
                    MeetingListM mList           = new MeetingListM();                  //object of model class
                    var          data            = db.Meetings.ToList();                //all list of meetings
                    var          existingmeeting = ctx.Meetings.Where(s => s.MeetingId == id)
                                                   .FirstOrDefault <Meeting>();         //get existing meeting details
                    var existingschedule = ctx.Schedules.Where(s => s.ScheduleId == existingmeeting.ScheduleId)
                                           .FirstOrDefault <Schedule>();                // get existing schedule
                    var existingmeetingattendee = ctx.MeetingsAttendees.Where(s => s.MeetingId == existingmeeting.MeetingId)
                                                  .FirstOrDefault <MeetingsAttendee>(); //get existing meeting attendee list
                    if (existingmeeting != null)
                    {
                        existingschedule.StartTime = DateTime.ParseExact(meeting.StartTime, "yyyy-MM-dd HH:mm:ss",
                                                                         System.Globalization.CultureInfo.InvariantCulture);
                        existingschedule.EndTime = DateTime.ParseExact(meeting.EndTime, "yyyy-MM-dd HH:mm:ss",
                                                                       System.Globalization.CultureInfo.InvariantCulture);
                        existingschedule.RoomId = meeting.RoomId;
                        var obj = db.Schedules.Add(sch);
                        ctx.SaveChanges();

                        existingmeeting.MeetingName = meeting.MeetingName;    //add value in training table
                        existingmeeting.Agenda      = meeting.Agenda;
                        // existingmeetingattendee.MeetingId = meeting.MeetingId;
                        var obj1 = db.Meetings.Add(tra);
                        foreach (int userid in meeting.MeetingAttendeeId)
                        {
                            MeetingsAttendee list = new MeetingsAttendee();    //object of model class
                            list.UserId    = userid;
                            list.MeetingId = existingmeeting.MeetingId;
                            ctx.MeetingsAttendees.Add(list);
                            ctx.SaveChanges();
                        }
                        ctx.SaveChanges();
                    }
                    else
                    {
                        return(NotFound());
                    }
                }
            }
            catch (Exception e)
            {
                return(BadRequest(e.Message));
            }
            return(Ok(meeting));
        }
 [ResponseType(typeof(Meeting))]                               //post data for craete new tarining
 public IHttpActionResult PostMeeting(Models.MeetingM meeting) //bind training model
 {
     try
     {
         if (!ModelState.IsValid)
         {
             return(NotFound());
         }
         Schedule sch = new Schedule();                  //object schedule entity
         sch.StartTime = DateTime.ParseExact(meeting.StartTime, "yyyy-MM-dd HH:mm:ss",
                                             System.Globalization.CultureInfo.InvariantCulture);
         sch.EndTime = DateTime.ParseExact(meeting.EndTime, "yyyy-MM-dd HH:mm:ss",
                                           System.Globalization.CultureInfo.InvariantCulture);
         var obj = db.Schedules.Add(sch);
         sch.RoomId = meeting.RoomId;
         db.SaveChanges();                             //save data in schedule table
         Meeting met = new Meeting();                  //object of Training entity
         met.MeetingName = meeting.MeetingName;
         met.Agenda      = meeting.Agenda;
         met.ScheduleId  = obj.ScheduleId;            //getting Scheduleid from schedule table
         met.CreatedAt   = DateTime.Now;
         met.UpdatedAt   = DateTime.Now;
         met.UserId      = meeting.UserId;
         var obj1 = db.Meetings.Add(met);
         db.Meetings.Add(met);               //save data in meeting db
         db.SaveChanges();
         foreach (int userid in meeting.MeetingAttendeeId)
         {
             MeetingsAttendee mList = new MeetingsAttendee();    //object of model class
             mList.UserId    = userid;
             mList.MeetingId = obj1.MeetingId;
             db.MeetingsAttendees.Add(mList);
             db.SaveChanges();
         }
     }
     catch (Exception e)
     {
         return(BadRequest(e.Message));
     }
     return(CreatedAtRoute("DefaultApi", new { id = meeting.MeetingId }, meeting));
 }