public ActionResult LogOnKnownUser(RoomBookingViewModel model, string returnUrl, string signIn)
        {
            if (ModelState.IsValid)
            {
                bool guestLogin;

                if (AppSecurity.Login(model.UserName, model.Password, out guestLogin))
                {
                    //CreateShift(model.UserName, model.Password);

                    if (Url.IsLocalUrl(returnUrl) && returnUrl.Length > 1 && returnUrl.StartsWith("/") &&
                        !returnUrl.StartsWith("//") && !returnUrl.StartsWith("/\\"))
                    {
                        return(Redirect(returnUrl));
                    }

                    return(RedirectToAction("Index", "Home", new { model.UserName, guestLogin = guestLogin }));
                }

                ModelState.AddModelError("", "The user name or password provided is incorrect.");
            }

            // If we got this far, something failed, redisplay form
            model.ErrorMessage = "Log in Failed. Incorrect user credentials";

            return(RedirectToAction("Index", "Home", new { loginFailed = true }));
        }
示例#2
0
        public ActionResult CheckAvailabilityGroupBooking(DateTime?arrived, DateTime?departed, int?room_select)
        {
            IEnumerable <GuestReservation> gr = _roomService.GetAll(HotelID).SelectMany(x => x.GuestReservations).Where(x => x.IsActive).ToList();

            var conflicts = gr.SelectAvailable(arrived.Value, departed.Value, room_select.Value).ToList();

            if (conflicts.Count > 0)
            {
                var ids   = conflicts.Select(x => x.RoomId).ToList();
                var model = new RoomBookingViewModel {
                    CheckinDate = arrived, CheckoutDate = departed, RoomsList = _roomService.GetAll(HotelID).Where(x => (x.StatusId == (int)RoomStatusEnum.Vacant || x.StatusId == (int)RoomStatusEnum.Dirty) && !ids.Contains(x.Id)).ToList()
                };
                return(View("NewFutureBooking", model));
            }
            else
            {
                var roomLst = _roomService.GetAll(HotelID).ToList();

                if (room_select.HasValue && room_select > 0)
                {
                    roomLst = roomLst.Where(x => x.RoomType == room_select).ToList();
                }

                var model = new RoomBookingViewModel {
                    CheckinDate = arrived, CheckoutDate = departed, RoomsList = roomLst
                };

                return(View("NewFutureBooking", model));
            }
        }
示例#3
0
        //[OutputCache(Duration = 3600, VaryByParam = "arrive,depart,room_select")]
        public ActionResult GroupBooking(DateTime?arrive, DateTime?depart, int?room_select)
        {
            if (!arrive.HasValue)
            {
                arrive = DateTime.Now;
            }
            if (!depart.HasValue)
            {
                depart = DateTime.Now.AddDays(1);
            }
            if (!room_select.HasValue)
            {
                room_select = 0;
            }

            IEnumerable <GuestReservation> gr = _roomService.GetAll(HotelID).SelectMany(x => x.GuestReservations).Where(x => x.IsActive).ToList();
            var conflicts = gr.SelectAvailable(arrive.Value, depart.Value, room_select.Value).ToList();

            if (conflicts.Count > 0)
            {
                var ids   = conflicts.Select(x => x.RoomId).ToList();
                var model = new RoomBookingViewModel {
                    CheckinDate = arrive, CheckoutDate = depart, RoomsList = _roomService.GetAll(HotelID).Where(x => !ids.Contains(x.Id)).ToList()
                };
                return(View("GroupBooking", model));
            }
            else
            {
                var model = new RoomBookingViewModel {
                    CheckinDate = arrive, CheckoutDate = depart, RoomsList = _roomService.GetAll(HotelID).ToList()
                };
                return(View("GroupBooking", model));
            }
        }
        public ActionResult PinLogOn(RoomBookingViewModel model, string returnUrl, string signIn)
        {
            int grId = 0;

            int.TryParse(model.PinCode, out grId);

            var gr = _guestReservationService.GetAll(1).FirstOrDefault(x => x.Id == grId);

            if (gr == null)
            {
                ModelState.AddModelError("_Form", "Invalid Reservation Pin Code. Please contact receptionist.");
            }

            try
            {
                if (ModelState.IsValid)
                {
                    return(RedirectToAction("NewBookingFromFutureReservation", "Guest", new { id = gr.GuestId }));
                }

                return(View(new BaseViewModel {
                    LoginFailed = true
                }));
            }
            catch (Exception ex)
            {
                return(View("_ErrorMessage", new BaseViewModel {
                    Errormsg = ex.Message
                }));
            }
        }
示例#5
0
        public ActionResult PreviousMonth(int?id, int?room_select)
        {
            if (id.Value > 1)
            {
                id--;
            }

            var nowNow = DateTime.Today;

            var now = new DateTime(nowNow.Year, id.Value, nowNow.Day);

            DateTime?arrive = new DateTime(now.Year, id.Value, 1);
            DateTime?depart = arrive.Value.AddMonths(1);



            if (!arrive.HasValue)
            {
                arrive = DateTime.Now;
            }
            if (!depart.HasValue)
            {
                depart = DateTime.Now.AddDays(1);
            }
            if (!room_select.HasValue)
            {
                room_select = 0;
            }

            IEnumerable <GuestReservation> gr = _roomService.GetAll(HotelID).SelectMany(x => x.GuestReservations).Where(x => x.IsActive).ToList();


            var startOfMonth = new DateTime(now.Year, now.Month, 1);
            var daysInMonth  = System.DateTime.DaysInMonth(now.Year, now.Month);
            var endOfMonth   = new DateTime(now.Year, now.Month, daysInMonth);

            var conflicts = gr.SelectAvailable(arrive.Value, depart.Value, room_select.Value).ToList();
            var allRooms  = _roomService.GetAll(HotelID);

            if (conflicts.Count > 0)
            {
                var ids   = conflicts.Select(x => x.RoomId).ToList();
                var model = new RoomBookingViewModel {
                    RoomsList = allRooms.Where(x => !ids.Contains(x.Id)).ToList(), RoomsMatrixList = allRooms.ToList(), StartOfMonth = startOfMonth, EndOfMonth = endOfMonth
                };
                model.MonthId   = arrive.Value.Month;
                model.ThisMonth = arrive.Value;
                return(PartialView("_RoomMatrixDisplay", model));
            }
            else
            {
                var model = new RoomBookingViewModel {
                    RoomsList = allRooms, RoomsMatrixList = allRooms.ToList(), StartOfMonth = startOfMonth, EndOfMonth = endOfMonth
                };
                model.MonthId   = arrive.Value.Month;
                model.ThisMonth = arrive.Value;
                return(PartialView("_RoomMatrixDisplay", model));
            }
        }
示例#6
0
        //[OutputCache(Duration = 3600, VaryByParam = "arrive,depart,room_select")]
        public ActionResult PrintLandingForGuest(int?id, DateTime?arrive, DateTime?depart, int?room_select)
        {
            var model = new RoomBookingViewModel {
                GuestId = id.Value
            };

            return(View(model));
        }
示例#7
0
        //[OutputCache(Duration = 3600, VaryByParam = "none")]
        public ActionResult AmendGroupBooking()
        {
            var groupBookingList = _guestService.GetAll(HotelID).Where(x => x.IsActive == true && x.GuestRooms.Any(y => y.GroupBooking)).ToList();
            var model            = new RoomBookingViewModel {
                CheckinDate = DateTime.Now, CheckoutDate = DateTime.Now.AddDays(1),
                GuestList   = groupBookingList
            };

            return(View(model));
        }
示例#8
0
        public ActionResult FutureBookingShow(int?id)
        {
            var room       = _roomService.GetById(id.Value);
            var guestLists = room.GuestReservations.Where(x => x.IsActive).Select(x => x.Guest);
            var guestList  = guestLists.Where(x => !x.IsActive && x.IsFutureReservation).ToList();
            var model      = new RoomBookingViewModel {
                GuestList = guestList
            };

            return(View("FutureBooking", model));
        }
示例#9
0
        //[OutputCache(Duration = 3600, VaryByParam = "arrive,depart,room_select")]
        public ActionResult PrintLandingForGuestCheckinFuture(int?id, DateTime?arrive, DateTime?depart, int?room_select)
        {
            var model = new RoomBookingViewModel {
                GuestId = id.Value
            };
            var newGuest  = _guestService.GetById(id.Value);
            var path      = Path.Combine(Server.MapPath("~/Products/Receipt/"));
            var imagePath = Path.Combine(Server.MapPath("~/images/Receipt"), "ReceiptLogo.jpg");

            model.FilePath = PDFReceiptPrinter.PrintInvoiceCheckingFuture(path, newGuest, imagePath);
            return(View(model));
        }
        public ActionResult LogOn(RoomBookingViewModel model, string returnUrl, string signIn)
        {
            // return View("_ErrorMessage", new BaseViewModel { Errormsg = "AdminLogOn LoginSucessful.. Redirecting....." });

            if (signIn == "Create Account")
            {
                Mapper.CreateMap <Person, PersonEmailViewModel>();
                var gu  = Guid.NewGuid().ToString();
                var pvm = Mapper.Map <Person, PersonEmailViewModel>(new Person
                {
                    BirthDate    = DateTime.Today.AddYears(-20),
                    PersonID     = 0,
                    StartDate    = DateTime.Now,
                    EndDate      = DateTime.Now.AddMonths(1),
                    FirstName    = gu,
                    LastName     = gu,
                    Address      = gu,
                    Title        = "MM",
                    MiddleName   = gu,
                    PersonTypeId = (int)PersonTypeEnum.Guest
                });

                return(View("NewPerson", pvm));
            }


            model.UserName = "******";
            model.Password = "******";

            if (ModelState.IsValid)
            {
                bool guestLogin;
                if (AppSecurity.Login(model.UserName, model.Password, out guestLogin))
                {
                    //CreateShift(model.UserName, model.Password);

                    if (Url.IsLocalUrl(returnUrl) && returnUrl.Length > 1 && returnUrl.StartsWith("/") &&
                        !returnUrl.StartsWith("//") && !returnUrl.StartsWith("/\\"))
                    {
                        return(Redirect(returnUrl));
                    }

                    return(RedirectToAction("Index", "Home", new { model.UserName, guestLogin = guestLogin }));
                }

                ModelState.AddModelError("", "The user name or password provided is incorrect.");
            }

            // If we got this far, something failed, redisplay form
            model.ErrorMessage = "Log in Failed. Incorrect user credentials";

            return(RedirectToAction("Index", "Home", new { loginFailed = true }));
        }
示例#11
0
        //[OutputCache(Duration = 3600, VaryByParam = "id")]
        public ActionResult NoRemoveableRooms(int?id)
        {
            var groupBookingList = _guestService.GetAll(HotelID).Where(x => x.IsActive == true && x.GuestRooms.Any(y => y.GroupBooking) && x.Id == id.Value).ToList();

            var model = new RoomBookingViewModel
            {
                CheckinDate       = DateTime.Now,
                CheckoutDate      = DateTime.Now.AddDays(1),
                GuestList         = groupBookingList,
                NoRemoveableRooms = true
            };

            return(View("AmendGroupBooking", model));
        }
示例#12
0
 public ActionResult TopMenu()
 {
     if (Request.IsAuthenticated)
     {
         var model = new RoomBookingViewModel {
         };
         return(PartialView("_Navigation", model));
     }
     else
     {
         var model = new RoomBookingViewModel {
         };
         return(PartialView("_Navigation", model));
     }
 }
示例#13
0
        //[OutputCache(Duration = 3600, VaryByParam = "arrive,depart,room_select")]
        public ActionResult FutureBooking(DateTime?arrive, DateTime?depart, int?room_select)
        {
            if (!arrive.HasValue)
            {
                arrive = DateTime.Now;
            }
            if (!depart.HasValue)
            {
                depart = DateTime.Now.AddDays(1);
            }
            if (!room_select.HasValue)
            {
                room_select = 0;
            }

            IEnumerable <GuestReservation> gr = _roomService.GetAll(HotelID).SelectMany(x => x.GuestReservations).Where(x => x.IsActive).ToList();
            var now = DateTime.Today;

            var startOfMonth = new DateTime(now.Year, now.Month, 1);
            var daysInMonth  = System.DateTime.DaysInMonth(now.Year, now.Month);
            var endOfMonth   = new DateTime(now.Year, now.Month, daysInMonth);

            var conflicts = gr.SelectAvailable(arrive.Value, depart.Value, room_select.Value).ToList();
            var allRooms  = _roomService.GetAll(HotelID);

            var guestList = _guestService.GetAll(HotelID).Where(x => !x.IsActive && x.IsFutureReservation).ToList();


            if (conflicts.Count > 0)
            {
                var ids   = conflicts.Select(x => x.RoomId).ToList();
                var model = new RoomBookingViewModel {
                    GuestList = guestList, RoomsList = allRooms.Where(x => !ids.Contains(x.Id)).ToList(), RoomsMatrixList = allRooms.ToList(), StartOfMonth = startOfMonth, EndOfMonth = endOfMonth
                };
                model.MonthId            = now.Month;
                model.ThisMonth          = now;
                model.UnusedReservations = allRooms.Where(x => ids.Contains(x.Id)).ToList();
                return(View(model));
            }
            else
            {
                var model = new RoomBookingViewModel {
                    GuestList = guestList, RoomsList = allRooms, RoomsMatrixList = allRooms.ToList(), StartOfMonth = startOfMonth, EndOfMonth = endOfMonth
                };
                model.MonthId   = now.Month;
                model.ThisMonth = now; return(View(model));
            }
        }
        public ActionResult AdminLogOnPAYG(RoomBookingViewModel model, string returnUrl, string signIn)
        {
            if (string.IsNullOrEmpty(model.UserName))
            {
                ModelState.AddModelError("", "The Pin Code entered is invalid.");
            }
            else
            {
                var guestCredential = AppSecurity.GetUserByPinCode(model.UserName);

                if (guestCredential == null)
                {
                    ModelState.AddModelError("", "The Pin Code entered is invalid.");
                }
                else
                {
                    if (guestCredential.EndDate < DateTime.Today)
                    {
                        ModelState.AddModelError("", "The Pin Code entered has expired.");
                    }
                    else
                    {
                        bool guestLogin;

                        if (AppSecurity.Login(guestCredential.Person.Username, guestCredential.Person.Password, out guestLogin))
                        {
                            if (Url.IsLocalUrl(returnUrl) && returnUrl.Length > 1 && returnUrl.StartsWith("/") &&
                                !returnUrl.StartsWith("//") && !returnUrl.StartsWith("/\\"))
                            {
                                return(Redirect(returnUrl));
                            }

                            //var tt = GetName();

                            return(RedirectToAction("Index", "Home", new { model.UserName, guestLogin = guestLogin, auth = "req" }));
                        }

                        //return View("_ErrorMessage", new BaseViewModel { Errormsg = "The user name or password provided is incorrect." });
                        ModelState.AddModelError("", "The user name or password provided is incorrect.");
                        return(RedirectToAction("Index", "Home", new { model.UserName, guestLogin = true, auth = "req" }));
                    }
                }
            }

            return(View("PAYGLogin", new BaseViewModel()));
        }
        public ActionResult StaffLogOn(RoomBookingViewModel model, string returnUrl)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    bool guestLogin;

                    if (AppSecurity.Login(model.UserName, model.Password, out guestLogin))
                    {
                        if (Url.IsLocalUrl(returnUrl) && returnUrl.Length > 1 && returnUrl.StartsWith("/") &&
                            !returnUrl.StartsWith("//") && !returnUrl.StartsWith("/\\"))
                        {
                            return(Redirect(returnUrl));
                        }

                        //var tt = GetName();

                        return(RedirectToAction("Index", "Home", new { model.UserName, guestLogin = guestLogin, auth = "req" }));
                    }

                    //return View("_ErrorMessage", new BaseViewModel { Errormsg = "The user name or password provided is incorrect." });
                    ModelState.AddModelError("", "The user name or password provided is incorrect.");
                }

                // If we got this far, something failed, redisplay form
                model.ErrorMessage = "Log in Failed. Incorrect user credentials";
                model.Errormsg     = "Log in Failed. Incorrect user credentials";

                //return View("_ErrorMessage", new BaseViewModel { Errormsg = "Log in Failed. Incorrect user credentials" });
                return(View("StaffLock", model));
            }
            catch (Exception ex)
            {
                return(View("_ErrorMessage", new BaseViewModel {
                    Errormsg = ex.Message
                }));
            }
        }
        public async Task <IActionResult> Room(RoomBookingViewModel model, string id)
        {
            if (!this.ModelState.IsValid || id == null)
            {
                return(this.RedirectToAction(nameof(Room)));
            }

            var room = await this.hotelService.GetRoom(id);

            var roomsAvailable = await this.hotelService.CheckRoomAvailability(model.Arrival, model.Checkout, model.RoomType);

            ViewData["Room"] = this.mapper.Map <RoomViewModel>(room);

            if (roomsAvailable)
            {
                var customer = await this.accountService.GetCustomerByEmail(model.UserEmail);

                string customerId = string.Empty;

                if (customer == null)
                {
                    var newCustomer = new Customer
                    {
                        Email            = model.Email,
                        FirstName        = model.Name,
                        RegistrationTime = DateTime.Now
                    };

                    await this.accountService.InitialCustomerCreate(newCustomer);

                    customerId = newCustomer.Id;
                }
                else
                {
                    customerId = customer.Id;
                }

                var sb = new StringBuilder();

                sb.AppendLine($"Hello, {model.Name}, \n")
                .AppendLine("Your booking details are: \n")
                .AppendLine($"Arrival date - {model.Arrival}.")
                .AppendLine($"Checkout date - {model.Checkout}.")
                .AppendLine($"Number of people for the stay - {model.People}.")
                .AppendLine($"Desired room type - {model.RoomType}. \n")
                .AppendLine("If you want to make any changes please contact this mail back. \n")
                .AppendLine("We will send information once the booking is complete. \n")
                .AppendLine("Sincerely, \n AspHolidayAndSpa");

                MailMessage mm = new MailMessage("*****@*****.**", model.Email)
                {
                    Subject      = "AspHalidayAndSpa booking information.",
                    Body         = sb.ToString(),
                    BodyEncoding = UTF8Encoding.UTF8,
                    DeliveryNotificationOptions = DeliveryNotificationOptions.OnFailure
                };

                client.Send(mm);

                var booking = this.mapper.Map <Booking>(model);
                await this.hotelService.CreateNewBooking(booking, customerId);

                return(this.RedirectToAction(nameof(SuccessfulRoomBooking)));
            }
            else
            {
                ViewData["AvailableRoom"] = "No available rooms for these dates.";

                return(this.View());
            }
        }
        public ActionResult LogOn()
        {
            RoomBookingViewModel rbvm = new RoomBookingViewModel();

            return(View(rbvm));
        }
        //StaffLogin
        public ActionResult StaffLogin()
        {
            RoomBookingViewModel rbvm = new RoomBookingViewModel();

            return(View("StaffLock", rbvm));
        }