public static void CuctomerRole() { Console.WriteLine("Choose"); Console.WriteLine("1. Check in"); Console.WriteLine("2. Check Out"); string choice = Console.ReadLine(); //SelectRooms selectRooms = new SelectRooms(); //SelectBooking selectBooking = new SelectBooking(); switch (choice) { case "1": hotelId = SelectByCity(); var rooms = from room in linqtosqlDataContext.Rooms where room.HotelId == hotelId select room; // ArrayList rooms = selectRooms.GetRoomByHotelId(hotelId); Console.WriteLine("Rooms status"); Console.WriteLine(" RoomId HotelId RoomType AvailableRooms TotalRooms"); foreach (Room room in rooms) { Console.WriteLine(" {0} {1} {2} {3} {4}", room.RoomId, room.HotelId, room.RoomType, room.AvailableRooms, room.TotalRooms); } Console.WriteLine("Enter Room Id"); roomId = Convert.ToInt32(Console.ReadLine()); if (roomId % 2 == 1) { throw new Exception("Odd no entered"); } Console.WriteLine("Enter your Details bellow"); Console.WriteLine("Enter CustomerName"); string CustomerName = Console.ReadLine(); //Console.WriteLine("Enter LastName"); //string lastName = Console.ReadLine(); Console.WriteLine("Enter EmailId"); string emailId = Console.ReadLine(); Console.WriteLine("Enter Phone Numer"); string phoneNumber = Console.ReadLine(); // logdata.logmethod(DateTime.Now+" : customer "+ CustomerName + " checked in for RoomId "+ roomId + " in Hotel Id "+ hotelId); logger.Info("new customer is added" + CustomerName + "EmailId" + emailId); //logger.Trace("New Customer with name {0} for hotelId {1} for room type Id {2}",CustomerName,hotelId,roomId); //SelectCustomer selectCustomer = new SelectCustomer(); //custId = selectCustomer.InsertCustomerData(firstName, lastName, emailId, phoneNumber); Int64 custId = (Int64)linqtosqlDataContext.spInsertCustomer(CustomerName, emailId, phoneNumber).SingleOrDefault().Column1.Value; //Customer customer = new Customer //{ //}; //linqtosqlDataContext.Customers. Console.WriteLine("Adding Booking Details"); Int64 bookingId = (Int64)linqtosqlDataContext.spInsertBookingDetails(custId, hotelId, roomId).SingleOrDefault().Column1.Value; //long bookingId = selectBooking.InsertBookingData(custId, hotelId); // logdata.logmethod(DateTime.Now + "customers booking deatails are added"); Console.WriteLine("Booking Details are Added Id is {0}", bookingId); logger.Info("New customer booked in with Booking Id" + bookingId); //logger.Trace("New customer booked in with Booking Id {0}", bookingId); linqtosqlDataContext.spUpdateRoomsdata(roomId); //selectRooms.UpdateRoomsData(roomId); break; case "2": hotelId = SelectByCity(); //ArrayList roomtocheckout = selectRooms.GetRoomByHotelId(hotelId); //foreach (Room room in roomtocheckout) //{ // Console.WriteLine(" {0} {1} ", room.RoomId, room.HotelId); //} var bookingDetails = from bookingDetail in linqtosqlDataContext.BookingDetails where bookingDetail.HotelId == hotelId select bookingDetail; //var bookingDetails = linqtosqlDataContext.spSelectBookingDetailByHotelId(hotelId); foreach (BookingDetail bookingDetail in bookingDetails) { Console.WriteLine(" {0} {1} {2} {3} {4} {5}", bookingDetail.BookingId, bookingDetail.CustomerId, bookingDetail.HotelId, bookingDetail.RoomId, bookingDetail.CheckInDate, bookingDetail.CheckOutDate); } Console.WriteLine("Enter your Booking Id for check out"); long bookingId1 = Convert.ToInt64(Console.ReadLine()); //selectBooking.UpdateBookingData(bookingId1); linqtosqlDataContext.spUpdateBookingDetails(bookingId1); BookingDetail bd = linqtosqlDataContext.BookingDetails.SingleOrDefault(x => x.BookingId == bookingId1); //long rid = linqtosqlDataContext. logger.Info("customer checked out"); long rid = (Int64)bd.RoomId; Room rmForUpdate = linqtosqlDataContext.Rooms.SingleOrDefault(x => x.RoomId == rid); rmForUpdate.AvailableRooms = rmForUpdate.AvailableRooms + 1; // linqtosqlDataContext.SubmitChanges(); Console.WriteLine("CheckedOut Successfully"); break; } }
private void detach_BookingDetails(BookingDetail entity) { this.SendPropertyChanging(); entity.Hotel = null; }
private void attach_BookingDetails(BookingDetail entity) { this.SendPropertyChanging(); entity.Customer = this; }
partial void DeleteBookingDetail(BookingDetail instance);
partial void UpdateBookingDetail(BookingDetail instance);
partial void InsertBookingDetail(BookingDetail instance);