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)); } } }
public IActionResult Checkin(int id, bool isEdit = true) { if (!Authentication.AuthenticateByCookie(HttpContext)) { return(Redirect("/Receptionists/Authentication/Login?are=Receptionists&ctrl=Activities&act=Checkin")); } ViewBag.isEdit = isEdit; BookingModel model = BookingDAO.GetBookingModel(id); if (StayDAO.GetALLGuestsOfBooking(id).Count == 0) { StayDAO.InsertStay(new Stay() { BookingID = model.BookingID, Status = null, FromDate = DateTime.Now, GuestID = model.Guest.GuestID, ToDate = null }); } return(View(model)); }