private ReservationViewModel CreateSingleReservation(EventManagementSystemEntities dbEMS, DateTime startTime, DateTime endTime) { try { Reservation reservation = new Reservation { startTime = startTime, endTime = endTime, attendeeCount = attendeeCount, attendeeCountDGS = attendeeCountDGS, attendeeCountNonDGS = attendeeCountNonDGS }; if (locations != null) { foreach (var l in locations.Where(x => x.Length > 0)) { Int32 locationId = Convert.ToInt32(l); Location location = dbEMS.Locations.Where(ll => ll.locationId == locationId).FirstOrDefault(); reservation.Locations.Add(location); } } if (options != null) { foreach (var o in options.Where(x => x.Length > 0)) { Int32 optionId = Convert.ToInt32(o); Option option = dbEMS.Options.Where(oo => oo.optionId == optionId).FirstOrDefault(); reservation.Options.Add(option); } } ReservationViewModel rvm = new ReservationViewModel(); rvm.Reservation = reservation; rvm.GetConflicts(); //reservation.GetConflicts(); return rvm; } catch (Exception ex) { return null; } }
public PartialViewResult _FetchReservations(int? eventId) { if (eventId != null) { Event e = db.Events.Find(eventId); if (e != null) { List<ReservationViewModel> model = new List<ReservationViewModel>(); foreach (var reservation in e.Reservations.OrderBy(r => r.startTime)) { ReservationViewModel rvm = new ReservationViewModel(); rvm.Reservation = reservation; model.Add(rvm); } return PartialView(model); } } return null; }