Ejemplo n.º 1
0
        public bool UpdateGuest(Guest guest)
        {
            bool checkEmail = false;

            if (!guest.EmailDetails().Equals("") && !guest.FirstNameDetails().Equals("") && !guest.LastNameDetails().Equals("") && !guest.PassportNumberDetails().Equals(""))
            {
                try
                {
                    bool emailValid = Regex.IsMatch(guest.EmailDetails(), @"^[^@\s]+@[^@\s]+\.[^@\s]+$",
                                                    RegexOptions.IgnoreCase, TimeSpan.FromMilliseconds(250));
                    if (emailValid)
                    {
                        checkEmail = true;
                    }
                    else
                    {
                        checkEmail = false;
                    }
                }
                catch (RegexMatchTimeoutException)
                {
                }
            }
            if (checkEmail)
            {
                _guestRepository.Update(guest);
                return(true);
            }
            else
            {
                return(false);
            }
        }
        public IActionResult UpdateReservation()
        {
            int resId = Convert.ToInt32(Request.Query["resId"]);
            Dictionary <string, object> resRecord = _reservationService.SearchByReservationId(resId).GetReservation();

            Guest g = _guestService.SearchByGuestId((int)resRecord["guestID"]);

            ViewBag.resID      = resId;
            ViewBag.ResRecord  = resRecord;
            ViewBag.GuestName  = g.FirstNameDetails() + " " + g.LastNameDetails();
            ViewBag.GuestEmail = g.EmailDetails();
            return(View());
        }
Ejemplo n.º 3
0
        public IActionResult TransportReservation()
        {
            int guestId   = Convert.ToInt32(Request.Query["GuestId"]);
            int noOfGuest = Convert.ToInt32(Request.Query["NumOfGuest"]);
            int resId     = Convert.ToInt32(Request.Query["ResId"]);

            Guest g = _guestService.SearchByGuestId(guestId);

            // Return View page with resTemp data
            ViewBag.guestid   = g.GuestIdDetails();
            ViewBag.guestName = g.FirstNameDetails() + " " + g.LastNameDetails();
            ViewBag.noOfGuest = noOfGuest;
            ViewBag.resid     = resId;
            return(View());
        }
        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());
        }
Ejemplo n.º 5
0
        public bool RegisterGuest(Guest guest)
        {
            // Server side form validation
            bool formValuesIsValid   = false;
            bool isNotDuplicateGuest = false;

            if (!guest.FirstNameDetails().Equals("") && !guest.LastNameDetails().Equals("") && !guest.GuestIdDetails().Equals("") && !guest.EmailDetails().Equals("") && (!guest.PassportNumberDetails().Equals("") && guest.PassportNumberDetails().Length >= 9))
            {
                try
                {
                    bool emailFormatIsValid = Regex.IsMatch(guest.EmailDetails(), @"^[^@\s]+@[^@\s]+\.[^@\s]+$",
                                                            RegexOptions.IgnoreCase, TimeSpan.FromMilliseconds(250));
                    if (emailFormatIsValid)
                    {
                        formValuesIsValid = true;
                    }
                }
                catch (RegexMatchTimeoutException) {
                }
            }

            // Check if duplicate guest
            IEnumerable <Guest> guests = RetrieveGuests();

            foreach (Guest g in guests)
            {
                if (!g.PassportNumberDetails().Equals(guest.PassportNumberDetails()) && !g.EmailDetails().Equals(guest.EmailDetails()))
                {
                    isNotDuplicateGuest = true;
                }
            }


            if (formValuesIsValid && isNotDuplicateGuest)
            {
                _guestRepository.Insert(guest);
                return(true);
            }
            else
            {
                return(false);
            }
        }
        public FileResult Export(string ExportData)
        {
            int resId = Convert.ToInt32(Request.Query["resId"]);
            Dictionary <string, object> resRecord = _reservationService.SearchByReservationId(resId).GetReservation();

            Guest g        = _guestService.SearchByGuestId((int)resRecord["guestID"]);
            var   filename = g.FirstNameDetails() + g.LastNameDetails() + "_" + "ReservationID" + resId + ".pdf";

            using var stream = new MemoryStream();
            var reader  = new StringReader(ExportData);
            var pdfFile = new Document(PageSize.A4);
            var writer  = PdfWriter.GetInstance(pdfFile, stream);

            pdfFile.Open();
            XMLWorkerHelper.GetInstance().ParseXHtml(writer, pdfFile, reader);

            pdfFile.Close();
            return(File(stream.ToArray(), "application/pdf", filename));
        }
Ejemplo n.º 7
0
        public IActionResult CreateReservation()
        {
            // Validate if GuestId is Retrieve from Reservation Records or Guest page
            int guestId;

            if (Request.Query.Count == 0 || Request.Query.ContainsKey("GuestId"))
            {
                guestId = Convert.ToInt32(Request.Query["GuestId"]);
            }
            else
            {
                // Error: User tries to access page through url
                TempData["Message"] = "ERROR: Inappropriate access to Reservation Creation Page";
                return(RedirectToAction("ReservationView", "Reservation"));
            }

            // Initializing Variables
            Dictionary <string, int> guestDetail = new Dictionary <string, int>();

            // Retrieve guest like this only
            Guest guest = _guestService.SearchByGuestId(guestId);

            // Validate if guest Object is null - means user typed in an invalid guestId via the url
            if (guest == null)
            {
                // Error: User tries to access page through url
                TempData["Message"] = "ERROR: Guest ID " + guestId + " does not Exist!";
                return(RedirectToAction("ReservationView", "Reservation"));
            }

            // Passing data over to View Page via ViewBag "/Reservation/CreateReservation"
            ViewBag.guestid     = guest.GuestIdDetails();
            ViewBag.guestName   = guest.FirstNameDetails() + " " + guest.LastNameDetails();
            ViewBag.guestDetail = guestDetail;

            return(View());
        }
Ejemplo n.º 8
0
        public ActionResult UpdateGuest(IFormCollection form)
        {
            string guestID        = form["guestID"];
            int    guestid        = Convert.ToInt32(guestID);
            string firstName      = form["FirstName"];
            string lastName       = form["LastName"];
            string guestType      = form["GuestType"];
            string email          = form["Email"];
            string passportNumber = form["PassportNumber"];
            string secretPin      = form["secretpin"];

            if (_authenticator.AuthenticatePin(secretPin) && Update(guestid, firstName, lastName, guestType, email, passportNumber))
            {
                TempData["UpdateGuestMessage"] = "Success";
                return(Redirect("/Guest"));
            }
            else
            {
                ViewData["UpdateGuestMessage"] = "Error";
                Guest          guest          = _guestService.SearchByGuestId(guestid);
                GuestViewModel guestViewModel = (new GuestViewModel(guest.GuestIdDetails(), guest.FirstNameDetails(), guest.LastNameDetails(), guest.GuestTypeDetails(), guest.EmailDetails(), guest.PassportNumberDetails()));
                ViewBag.guest = guestViewModel;
                return(View());
            }
        }
Ejemplo n.º 9
0
        public ActionResult UpdateGuest(int guestID)
        {
            Guest          guest          = _guestService.SearchByGuestId(guestID);
            GuestViewModel guestViewModel = (new GuestViewModel(guest.GuestIdDetails(), guest.FirstNameDetails(), guest.LastNameDetails(), guest.GuestTypeDetails(), guest.EmailDetails(), guest.PassportNumberDetails()));

            ViewBag.guest = guestViewModel;
            return(View());
        }
Ejemplo n.º 10
0
        public IActionResult ReservationView()
        {
            bool hasKeys = Request.QueryString.HasValue;

            if (hasKeys)
            {
                // Initializing ArrayList to store all existing reservation data to pass to View Page
                ArrayList mainList = new ArrayList();

                // Retrieving required data for the function to work
                int   guestId = Convert.ToInt32(Request.Query["GuestId"]);
                Guest g       = _guestService.SearchByGuestId(guestId);
                IEnumerable <Reservation> individualGuestReservationList = _reservationService.SearchByGuestId(guestId);

                // For loop to create a array of reservation data from the database
                foreach (var res in individualGuestReservationList)
                {
                    // Retrieving Reservation Object Data and storing into a Dictionary<string, object>
                    Dictionary <string, object> reservation = res.GetReservation();

                    // Storing Reservation Object Data into subList String Array
                    string[] subList =
                    {
                        reservation["resID"].ToString(),
                        reservation["numOfGuest"].ToString(),
                        reservation["roomType"].ToString(),
                        reservation["start"].ToString(),
                        reservation["end"].ToString(),
                        reservation["status"].ToString()
                    };

                    // Storing subList into mainList (ArrayList)
                    mainList.Add(subList);
                }

                // List of data stored in the ViewBag to be passed to View
                ViewBag.flag          = 0;
                ViewBag.mainList      = mainList;
                ViewBag.GuestId       = guestId;
                ViewBag.GuestName     = g.FirstNameDetails() + " " + g.LastNameDetails();
                ViewBag.GuestEmail    = g.EmailDetails();
                ViewBag.GuestType     = g.GuestTypeDetails();
                ViewBag.GuestPassport = g.PassportNumberDetails();
            }
            else
            {
                // Initializing ArrayList to store all existing reservation data to pass to View Page
                ArrayList mainList = new ArrayList();

                // Retrieving all existing reservation inside the database
                IEnumerable <Reservation> reservationList = _reservationService.GetAllReservations();

                // For Loop to store all existing reservation with guest name and email into a ArrayList to pass to View page
                foreach (var res in reservationList)
                {
                    // Retrieving guest by id based on Mod 1 Team 9 function
                    Guest g = _guestService.SearchByGuestId((int)res.GetReservation()["guestID"]);

                    if (g != null)
                    {
                        Dictionary <string, object> reservation = res.GetReservation();
                        string[] subList =
                        {
                            reservation["resID"].ToString(),
                            reservation["guestID"].ToString(),
                            g.FirstNameDetails() + " " + g.LastNameDetails(),
                            g.EmailDetails(),
                            reservation["numOfGuest"].ToString(),
                            reservation["roomType"].ToString(),
                            reservation["start"].ToString(),
                            reservation["end"].ToString(),
                            reservation["status"].ToString()
                        };
                        mainList.Add(subList);
                    }
                }

                // Passing data over to View Page via ViewBag "/Reservation/ReservationView"
                ViewBag.flag     = 1;
                ViewBag.mainList = mainList;
            }
            return(View());
        }