Example #1
0
        // get all schedules as list and optional by user
        public ActionResult GetSchedulesAsList(string myBookings, string history = "false")
        {
            List <Schedule> scheduleList = new List <Rbm.Entities.Booking.Schedule>();

            if (bool.Parse(history) == true)
            {
                scheduleList    = GetAllScheduleFiltered(bool.Parse(myBookings)); // get full list
                ViewBag.history = "true";
            }
            else
            {
                scheduleList    = GetAllScheduleFiltered(bool.Parse(myBookings), DateTime.Now.AddDays(-1).ToString()); // get list without historical events
                ViewBag.history = "false";
            }

            List <ScheduleListModel> model = new List <ScheduleListModel>();


            using (var uow = this.GetUnitOfWork())
            {
                foreach (Schedule s in scheduleList)
                {
                    var booking   = uow.GetReadOnlyRepository <BookingEvent>().Get(s.BookingEvent.Id);
                    var resource  = uow.GetReadOnlyRepository <Resource>().Get(s.Resource.Id);
                    var forperson = uow.GetReadOnlyRepository <Person>().Get(s.ForPerson.Id);

                    // Todo: maybe their is a more performant way to get the info for the ContactName
                    var schedule = uow.GetReadOnlyRepository <Schedule>().Get(s.Id);
                    ScheduleEventModel tempSchedule = new ScheduleEventModel(schedule);

                    model.Add(new ScheduleListModel(
                                  booking.Id,
                                  booking.Name,
                                  booking.Description,
                                  resource.Name,
                                  s.StartDate,
                                  s.EndDate,
                                  "(" + s.Quantity + "/" + s.Resource.Quantity + ")",
                                  forperson,
                                  s.Activities,
                                  tempSchedule.ContactName
                                  ));
                }
            }

            return(PartialView("_listSchedules", model));
        }
Example #2
0
 /// <summary>
 /// Event to handle changing views
 /// </summary>
 /// <param name="message"></param>
 public void Handle(ScheduleEventModel message)
 {
     ActivateItem(_container.GetInstance <ScheduleViewModel>());
 }