コード例 #1
0
        public async Task <IActionResult> Create(int RoomID, DateTime CheckInDate, DateTime CheckOutDate, Guest guest, Payment payment, int Amount)
        {
            int guestid   = GuestDAO.InsertGuest(guest);
            int paymentid = PaymentDAO.InsertPayment(payment);
            int bookingid = BookingDAO.InsertBooking(new Booking()
            {
                RoomID       = RoomID,
                CheckInDate  = CheckInDate.AddHours(14),
                CheckOutDate = CheckOutDate.AddHours(12).AddMinutes(5),
                GuestID      = guestid,
                Amount       = (int)(CheckOutDate - CheckInDate).TotalDays * RoomsDAO.GetRoomModel(RoomID).RoomType.Price,
                PaymentID    = paymentid,
            });

            var    model = BookingDAO.GetBookingModel(bookingid);
            string body  = await Utlities.RenderViewToStringAsync <BookingModel>(this, "~/Areas/Guests/Views/Partial/_ConfirmEmail.cshtml", model);

            MailMessage mail = new MailMessage();

            mail.From = new MailAddress("*****@*****.**");
            mail.To.Add(guest.Email);
            mail.Subject    = "Congratulations on your successful booking";
            mail.Body       = body;
            mail.IsBodyHtml = true;

            Utlities.SendEmail(mail);

            return(View());
        }
コード例 #2
0
        public IActionResult Create(int RoomID, DateTime CheckInDate, DateTime CheckOutDate, Guest guest, Payment payment, int Amount)
        {
            int guestid   = GuestDAO.InsertGuest(guest);
            int paymentid = PaymentDAO.InsertPayment(payment);
            int bookingid = BookingDAO.InsertBooking(new Booking()
            {
                RoomID       = RoomID,
                CheckInDate  = CheckInDate.AddHours(14),
                CheckOutDate = CheckOutDate.AddHours(12).AddMinutes(5),
                GuestID      = guestid,
                Amount       = (int)(CheckOutDate - CheckInDate).TotalDays * RoomsDAO.GetRoomModel(RoomID).RoomType.Price,
                PaymentID    = paymentid,
            });

            return(View());
        }
コード例 #3
0
        public IActionResult AddGuestOnCheckin(string FullName, string Gender, string IdCard, int bookingid)
        {
            if (!GuestDAO.CheckIsExistGuestByIdCard(IdCard))
            {
                var guestid = GuestDAO.InsertGuest(new Guest()
                {
                    FullName     = FullName,
                    Gender       = Gender,
                    IDCardNumber = IdCard
                });

                var stay = StayDAO.InsertStay(new Stay()
                {
                    GuestID   = guestid,
                    BookingID = bookingid,
                    FromDate  = DateTime.Now,
                    ToDate    = null
                });

                return(Json(stay));
            }
            else
            {
                var guestid = GuestDAO.GetGuestByIdCardNumber(IdCard).GuestID;
                if (!StayDAO.CheckGuestStaying(guestid))
                {
                    var stay = StayDAO.InsertStay(new Stay()
                    {
                        GuestID   = guestid,
                        BookingID = bookingid,
                        FromDate  = DateTime.Now,
                        ToDate    = null
                    });

                    return(Json(stay));
                }
                else
                {
                    return(Json(null));
                }
            }
        }
コード例 #4
0
        public JsonResult CreateBooking(int RoomID, DateTime CheckInDate, DateTime CheckOutDate, Guest guest, Payment payment)
        {
            int guestid   = GuestDAO.InsertGuest(guest);
            int paymentid = PaymentDAO.InsertPayment(payment);

            Booking booking = new Booking();

            booking.RoomID       = RoomID;
            booking.GuestID      = guestid;
            booking.PaymentID    = paymentid;
            booking.CheckInDate  = CheckInDate;
            booking.CheckOutDate = CheckOutDate;

            int bookingid = BookingDAO.InsertBooking(booking);

            return(Json(new
            {
                data = booking
            }));
        }