public void Update(FacilityReservation entity) { if (entity != null) { _appContext.FacilityReservationsDb().Update(entity); _appContext.SaveChanges(); } }
public bool MakeReservation(FacilityReservation facilityReservation) { if (CheckValidReservation(facilityReservation)) { _facilityReservationRepository.Insert(facilityReservation); } return(true); }
public void Insert(FacilityReservation entity) { if (entity != null) { _appContext.FacilityReservationsDb().Add(entity); _appContext.SaveChanges(); } }
public bool DeleteReservation(FacilityReservation facilityReservation) { if (_facilityReservationRepository.GetById(facilityReservation.ReservationIdDetails()) == null) { return(false); } _facilityReservationRepository.Delete(facilityReservation); return(true); }
public bool DeleteReservation(int reservationId) { FacilityReservation reservation = _facilityReservationRepository.GetById(reservationId); if (reservation == null) { return(false); } _facilityReservationRepository.Delete(reservation); return(true); }
public bool Update([FromBody] int reservationId, [FromBody] DateTime startTime, [FromBody] DateTime endTime, [FromBody] int?pax = null) { FacilityReservation reservation = _facilityReservationService.RetrieveByReservationId(reservationId); if (reservation != null) { reservation.UpdateReservation(pax, startTime, endTime); if (_facilityReservationService.UpdateReservation(reservation)) { return(true); } } return(false); }
public ActionResult UpdateFacilityReservation(string selectedFacResId, string selectedGusResID) { // Retrieve all facility based on Mod 3 Team 06 function List <PublicAreaDTO> fullfacilityList = _publicArea.getAllFacilityResults(); // For loop to store existing facility to populate View Form DropDownList Dictionary <int, string> namefacilityList = new Dictionary <int, string>(); if (fullfacilityList.Count > 0) { foreach (PublicAreaDTO fac in fullfacilityList) { namefacilityList.Add(fac.public_area_id, fac.public_area_name); } } // This is to filter out unrelated record, only return the selected records FacilityReservation selectedID = _facilityReservationService.RetrieveByReservationId(int.Parse(selectedFacResId)); Dictionary <string, string> currentRecord = new Dictionary <string, string>(); currentRecord.Add("FacilityId", selectedID.FacilityIdDetails().ToString()); currentRecord.Add("ReservationId", selectedID.ReservationIdDetails().ToString()); currentRecord.Add("ReserveeId", selectedID.ReserveeIdDetails().ToString()); currentRecord.Add("StartTime", selectedID.StartTimeDetails().ToString("yyyy-MM-dd")); currentRecord.Add("EndTime", selectedID.EndTimeDetails().ToString("yyyy-MM-ddTHH:mm")); currentRecord.Add("Pax", selectedID.NumberOfPax().ToString()); currentRecord.Add("SGID", selectedGusResID); currentRecord.Add("SFID", selectedFacResId); // Retrieve all existing guests Guest guestList = _guestService.SearchByGuestId(int.Parse(selectedGusResID)); // For loop to store existing guest to populate View Form DropDownList Dictionary <int, string> existguestList = new Dictionary <int, string>(); existguestList.Add(guestList.GuestIdDetails(), guestList.FirstNameDetails() + " " + guestList.LastNameDetails()); // Passing data over to View Page via ViewBag ViewBag.currentRecord = currentRecord; ViewBag.existguestList = existguestList; ViewBag.namefacilityList = namefacilityList; return(View()); }
public bool CheckValidReservation(FacilityReservation facilityReservation) { int currentPax = 0; int maxPax = 0; // get max pax of facility List <PublicAreaDTO> fullfacilityList = _publicArea.getAllFacilityResults(); foreach (PublicAreaDTO fac in fullfacilityList) { if (fac.public_area_id == facilityReservation.FacilityIdDetails()) { maxPax = fac.max_pax; } } // get current number of pax of facility in timeslot IEnumerable <FacilityReservation> facilityReservations = RetrieveReservations(); foreach (FacilityReservation facilityReservationInDB in facilityReservations) { if (facilityReservationInDB.FacilityIdDetails() == facilityReservation.FacilityIdDetails()) { // check if same timeslot if ((DateTime.Compare(facilityReservation.StartTimeDetails(), facilityReservationInDB.EndTimeDetails()) <= 0) && (DateTime.Compare(facilityReservation.EndTimeDetails(), facilityReservationInDB.StartTimeDetails()) >= 0)) { currentPax += facilityReservationInDB.NumberOfPax(); } } } // sum up total pax if including new reservation int totalPax = currentPax + facilityReservation.NumberOfPax(); // check if exceed max pax if (totalPax > maxPax) { return(false); } else { return(true); } }