Esempio n. 1
0
        public ActionResult _MyCalendar()
        {
            var utcOffset = TimeDateServices.GetUtcOffSet();
            var availableMeetingsPickList = MeetingsServices.GetAvailableMeetingsPickList(_context, utcOffset);
            var checkedAvailableMeetings = availableMeetingsPickList.Select(meeting => false).ToList();

            var availableMeetings = new AvailableMeetingsViewModel
            {
                Meetings = availableMeetingsPickList,
                CheckedAvailableMeetings = checkedAvailableMeetings,
                MeetingsCount = availableMeetingsPickList.Count,
                UtcOffset = utcOffset
            };
            return PartialView(availableMeetings);
        }
Esempio n. 2
0
        public ActionResult BookAvailable(AvailableMeetingsViewModel model)
        {
            var availableMeetings = MeetingsServices.GetAvailableMeetings(_context);

            //Get Booked Meetings

            var meetingsBooked = MeetingsServices.BookCheckedDates(_context, _currentUser, model, availableMeetings);


            if (meetingsBooked != null && meetingsBooked.Count > 0)
            {
                Log4NetHelper.Log("Meeting Booked - " + meetingsBooked.First().GtmUrl, LogLevel.INFO, "Meetings", meetingsBooked.First().Id, _currentUser.User.FullName, null);
            }

            return RedirectToAction("MyEnrollments", "Enrollments");
        }
Esempio n. 3
0
        public static List<Meeting> BookCheckedDates(ApplicationDbContext context, ICurrentUser student,
            AvailableMeetingsViewModel form, IEnumerable<AvailableMeeting> availableMeetings)
        {
            var bookedMeetings = form.CheckedAvailableMeetings;
            var meetingsBooked = new List<Meeting>();
            var i = 0;
            foreach (var meeting in availableMeetings)
            {
                //var meetingId = meeting.Id;
                //var xtra = meeting.IsChecked;
                //if (model.CheckedAvailableMeetings[i])
                if (meeting.IsChecked)
                {
                    var checkedMeeting = context.Meetings.Find(meeting.Id);
                    var studentName = student.User.FirstName + " " + student.User.LastName.Substring(0, 1) + ".";
                    var instructorName = checkedMeeting.Instructor.FirstName + " " +
                                         checkedMeeting.Instructor.LastName.Substring(0, 1) + ".";

                    //Create GoToMeeting
                    var meetingUrl = CreateGtmForAvailableSlot(context, checkedMeeting);

                    if (!string.IsNullOrEmpty(meetingUrl))
                    {
                        checkedMeeting.GtmUrl = meetingUrl;
                        checkedMeeting.MeetingTypeId = (int) MeetingType.PrivateMeeting;
                        checkedMeeting.StudentId = student.User.Id;

                        checkedMeeting.Title = checkedMeeting.Title + " - " + studentName;

                        checkedMeeting.Description = studentName + " has booked an online meeting with " +
                                                     instructorName + " on "
                                                     +
                                                     checkedMeeting.Start.AddMinutes(TimeDateServices.GetUtcOffSet())
                                                         .ToString("dddd MMM-d-yyyy h-mm tt");

                        context.Entry(checkedMeeting).State = EntityState.Modified;
                        meetingsBooked.Add(checkedMeeting);
                    }
                    //else
                    //{
                    //    Log4NetHelper.Log("Meeting Booking Failed", LogLevel.WARN,  "BookCheckedDates", 328, studentName, null);
                    //}
                }
                i++;
            }
            try
            {
                context.SaveChanges();
            }
            catch (Exception ex)
            {
                Log4NetHelper.Log("Failed to Book Meeting", LogLevel.ERROR, "Meetings", 150, "Tester", ex);
            }

            return meetingsBooked;
        }