public IActionResult Index(AddReviewViewModel model)
        {
            if (model == null)
            {
            }
            var reviewstar = _context.starRatings.
                             FirstOrDefault(p => p.StarRatingId == model.ReviewId);
            RoomReview review = new RoomReview()
            {
                ReviewStar = reviewstar.StarNo,
                Review     = model.Review,
                UserName   = model.UserName,
                hotelRoom  = _context.hotelRooms.FirstOrDefault(p => p.HotelRoomId
                                                                == model.RoomId)
            };

            _context.Add(review);

            if (_context.SaveChanges() > 0)
            {
                return(RedirectToAction("Index", new
                {
                    area = "User",
                    controller = "RoomReview",
                    id = model.RoomId
                }));
            }

            return(View());
        }
        public IActionResult Hotelreservtion(RoomReservationViewModel model)
        {
            int totalPaymentAmount = 0;

            if (!ModelState.IsValid)
            {
            }

            if (model.ChkIndate == null && model.ChkOutdate == null)
            {
            }

            TimeSpan difference = model.ChkOutdate.Date - model.ChkIndate.Date;

            var             room        = _context.hotelRooms.FirstOrDefault(p => p.HotelRoomId == model.RoomId);
            RoomReservation reservation = new RoomReservation()
            {
                UserName   = model.UserName,
                ChkIndate  = model.ChkIndate,
                ChkOutdate = model.ChkOutdate,
                Email      = model.Email,
                Cnic       = model.Cnic,
                PhoneNo    = model.PhoneNo,
                Address    = model.Address,
                Hotelroom  = room,
                UserCity   = model.UserCity,
                ZipCode    = model.ZipCode,
                NoOfNight  = difference.Days
            };

            _context.Add(reservation);

            if (_context.SaveChanges() > 0)
            {
                int id  = 0;
                var Res = _context.roomReservations.Include(p => p.Hotelroom)
                          .Include(p => p.Hotelroom.Hotel)
                          .FirstOrDefault(p => p.IsActive == false && p.PhoneNo == model.PhoneNo &&
                                          p.UserCity == model.UserCity && p.UserName == model.UserName &&
                                          p.Cnic == model.Cnic && p.Email == model.Email);

                //_emailSender.SendEmailAsync(Res.Email, $"Reservation",
                //   $" Your Reservation Completed Successfuly for Hotel {Res.Hotelroom.Hotel.HotelName} Room {Res.Hotelroom.RoomName} Now Contiue with Payment");

                _smsSender.SendSmsAsync(Res.PhoneNo, $"(From Hotel Network)" +
                                        $"Your Reservation Completed Successfuly for (Hotel) ::  {Res.Hotelroom.Hotel.HotelName}  (Room) :: {Res.Hotelroom.RoomName} ... Now Proccessed further with Payment");

                if (Res == null)
                {
                }
                id = Res.RoomReservationId;
                return(RedirectToAction("Payment", "HotelPayment", new { id = id }));
            }


            return(View());
        }
Exemplo n.º 3
0
        public IActionResult Index(HotelRoomListViewModel model)
        {
            if (!ModelState.IsValid)
            {
            }

            var room = _context.hotelRooms.Include(p => p.Hotel)
                       .FirstOrDefault(p => p.HotelRoomId == model.RoomId);
            var facilities = _context.RoomFacilities.Include(p => p.HotelRoom)
                             .FirstOrDefault(p => p.HotelRoom.HotelRoomId == model.RoomId);

            if (room == null)
            {
            }



            room.RoomName      = model.RoomName;
            room.RoomNo        = model.RoomNo;
            room.OcupancyLimit = model.OccupancyLimit;
            room.RsPernight    = model.PerNightPrice;

            _context.Update(room);
            _context.SaveChanges();

            if (facilities == null)
            {
                var roomfacility = new RoomFacilities()
                {
                    Internet         = model.FreeWifi,
                    AttachedWashRoom = model.AttachedWashroom,
                    Ac        = model.Ac,
                    Tv        = model.Tv,
                    HotelRoom = _context.hotelRooms.FirstOrDefault(p => p.HotelRoomId == room.HotelRoomId)
                };

                _context.Add(roomfacility);
                _context.SaveChanges();
            }
            else
            {
                facilities.Internet         = model.FreeWifi;
                facilities.Tv               = model.Tv;
                facilities.Ac               = model.Ac;
                facilities.AttachedWashRoom = model.AttachedWashroom;

                _context.Update(facilities);
                _context.SaveChanges();
            }



            return(RedirectToAction("Index", new { area = "Manager", controller = "HotelRoomProfile" }));
        }
Exemplo n.º 4
0
        public IActionResult Payment(PaymentViewModel model,
                                     string stripeToken, string stripeEmail)
        {
            var reservation = _context.roomReservations.Include(p => p.Hotelroom)
                              .Include(p => p.Hotelroom.Hotel)
                              .FirstOrDefault(p => p.RoomReservationId == model.ReservationId);

            Dictionary <string, string> Metadata = new Dictionary <string, string>();

            Metadata.Add("Product", "RubberDuck");
            Metadata.Add("Quantity", "10");
            var options = new ChargeCreateOptions
            {
                Amount       = model.TotalPrice * 100,
                Currency     = "PKR",
                Description  = "room reservation",
                SourceId     = stripeToken,
                ReceiptEmail = stripeEmail,
                Metadata     = Metadata
            };
            var    service = new ChargeService();
            Charge charge  = service.Create(options);

            if (charge.Status.ToLower() == "succeeded")
            {
                reservation.IsActive             = true;
                reservation.IsPaymentSuccessfull = true;
                _context.Update(reservation);
                _context.SaveChanges();

                var payment = new Payment()
                {
                    PaymentType     = "debit card",
                    RoomReservation = reservation,
                    Amount          = model.TotalPrice * 100
                };

                _context.Add(payment);
                if (_context.SaveChanges() > 0)
                {
                    _emailSender.SendEmailAsync(reservation.Email, $"Payment Successfully Payed for Hotel  {reservation.Hotelroom.Hotel.HotelName} Room {reservation.Hotelroom.RoomName} Total Amount Payes {model.TotalPrice * 100}",
                                                $"Now Enjoy your Time In Hotel");

                    _smsSender.SendSmsAsync(reservation.PhoneNo, $"Payment Successfully Payed for Hotel {reservation.Hotelroom.Hotel.HotelName} Room {reservation.Hotelroom.RoomName} Total Amount Payes {model.TotalPrice * 100}" +
                                            "Now Enjoy your Time In Hotel");
                    return(RedirectToAction("SuccessfullpyamentMessage", new
                    {
                        area = "",
                        controller = "HotelPayment"
                    }));
                }
            }
            return(View());
        }
        public IActionResult _UploadImage(HotelRoomImagesViewModel model)
        {
            if (!ModelState.IsValid)
            {
            }
            var roomimage = new RoomsImage();

            using (var memoryStream = new MemoryStream())
            {
                model.hotelRoomimage.CopyToAsync(memoryStream);
                roomimage.images = memoryStream.ToArray();
            }

            roomimage.HotelRoom = _context.hotelRooms.FirstOrDefault(p => p.HotelRoomId == model.HotelRoomId);

            _context.Add(roomimage);
            _context.SaveChanges();

            return(RedirectToAction("Index", new { area = "Manager", controller = "HotelRoomProfile", id = model.HotelRoomId }));
        }
        public IActionResult Index(HotelListViewModel model)
        {
            bool   Status     = false;
            string Message    = string.Empty;
            var    hotel      = _repository.HotelById(model.HotelId);
            var    facilities = _context.HotelFacilities.FirstOrDefault(p =>
                                                                        p.Hotel.HotelId == hotel.HotelId);

            if (ModelState.IsValid)
            {
                hotel.HotelName   = model.HotelName;
                hotel.HotelId     = model.HotelId;
                hotel.HotelCity   = model.HotelCity;
                hotel.NoOfFloors  = model.NoOfFloors;
                hotel.NoOfRooms   = model.NoOfRooms;
                hotel.Address     = model.Address;
                hotel.Description = model.Description;



                _repository.Update(hotel);

                if (_repository.SaveChange())
                {
                    if (facilities == null)
                    {
                        var hotelfacility = new HotelFacilities()
                        {
                            FreeWifi          = model.FreeWifi,
                            Dinner            = model.Dinner,
                            CarParking        = model.CarParking,
                            AttachedWashrooms = model.AttachedWashrooms,
                            Receptionservices = model.Receptionservices,
                            Laundry           = model.Laundry,
                            Lunch             = model.Lunch,
                            BreckFast         = model.BreckFast,
                        };
                        _context.Add(hotelfacility);
                        _context.SaveChanges();
                    }
                    else
                    {
                        facilities.FreeWifi          = model.FreeWifi;
                        facilities.Dinner            = model.Dinner;
                        facilities.CarParking        = model.CarParking;
                        facilities.AttachedWashrooms = model.AttachedWashrooms;
                        facilities.Receptionservices = model.Receptionservices;
                        facilities.Laundry           = model.Laundry;
                        facilities.Lunch             = model.Lunch;
                        facilities.BreckFast         = model.BreckFast;

                        _context.Update(facilities);
                        _context.SaveChanges();
                    }


                    return(RedirectToAction("Index", new { area = "Manager", controller = "HotelProfile" }));
                }
                else
                {
                    Status  = false;
                    Message = "Error inserting /Creating Course";
                }
            }
            else
            {
                ModelState.AddModelError("", "invalid / incomplete data");
            }
            return(Json(new { status = Status, message = Message }));
        }