public async Task <ActionResult> NewReservation(AdminNewReservation Data) { int result; Guest guest = new Guest { GuestCode = 0, GuestName = Data.GuestName, NationalID = Data.NationalID, Nationality = Data.Nationality, PhoneNumber = Data.PhoneNumber, Gender = Data.Gender, GuestAddress = Data.GuestAddress }; if (Data.GuestCode != 0) { guest.GuestCode = Data.GuestCode; result = await GuestStore.UpdateGuest(guest.GuestCode, guest); } else { result = await GuestStore.AddGuest(guest); } guest = GuestStore.GetGuestByNationalId(Data.NationalID); RoomReservation roomReservation = new RoomReservation { StartDate = Data.StartDate, EndDate = Data.EndDate, RoomID = Data.RoomID, GuestID = guest.GuestCode }; result = await RoomReservationstore.CreatNewReservation(roomReservation); return(Json(result, JsonRequestBehavior.AllowGet)); }
public async Task <ActionResult> NewReservation(RoomReservation Reservation) { Reservation.GuestID = 1; Guest CheckGuest = GuestStore.GetGuestById(Reservation.GuestID); if (CheckGuest != null) { int CheckReservation = await RoomReservationStore.CreatNewReservation(Reservation); if (CheckReservation != 0) { return(RedirectToAction("Index", "Home")); } } return(View()); }