public async Task<ActionResult> Index(int? Id, string sortOrder, string currentFilter, int? page)
 {SearchRoomReservation_WaitingList searchRoomReservation_WaitingList= new SearchRoomReservation_WaitingList ();
     RoomReservation_WaitingList waitingList = new RoomReservation_WaitingList();
     if (Id != null)
     {
         waitingList =await _RoomReservation_WaitingListRepository.GetById(Id.Value.ToString ());
       await   GetType(waitingList.RoomTypeId, waitingList.WaitingListStatusId);
         
     }
     else
     {
         await GetType(0, 0);
     }
     await GetSearchType(0, 0);
     var waitingLists = getList(sortOrder, currentFilter, page,await _RoomReservation_WaitingListRepository.GetAll());
     RoomReservation_WaitingListViewModel model = new RoomReservation_WaitingListViewModel { List = waitingLists, RoomReservation_WaitingList = waitingList, SearchRoomReservation_WaitingList = searchRoomReservation_WaitingList };
     return View(model);
 }
        public async Task<ActionResult> Save([Bind(Include = "Id,MemberId,Guest,FromDate,ToDate,RoomTypeId,WaitingListStatusId,EnteredDate,EnteredbyUserId,ModifyDate,ModifiedByUserId")]RoomReservation_WaitingList waitingList)
        {

            if (ModelState.IsValid)
            {
                if (waitingList.RoomTypeId == 0)
                    waitingList.RoomTypeId = null;

                if (waitingList.Id == 0)
                {
                   await _RoomReservation_WaitingListRepository.Create(waitingList);
                }
                else

                    _RoomReservation_WaitingListRepository.Update(waitingList, waitingList.Id.ToString ());

            }
            else
            {
               await GetType(waitingList.RoomTypeId , waitingList.WaitingListStatusId );
               await GetSearchType(0, 0);
                SearchRoomReservation_WaitingList searchRoomReservation_WaitingList = new SearchRoomReservation_WaitingList();
                var waitingLists = getList("", "", 1, await _RoomReservation_WaitingListRepository.GetAll());
                RoomReservation_WaitingListViewModel model = new RoomReservation_WaitingListViewModel { List = waitingLists, RoomReservation_WaitingList = waitingList, SearchRoomReservation_WaitingList = searchRoomReservation_WaitingList };
                 return View("Index", model);
            }
            return RedirectToAction("Index");
        }
        public async Task<ActionResult> Search(SearchRoomReservation_WaitingList searchRoomReservation_WaitingList)
        {
            RoomReservation_WaitingList waitingList = new RoomReservation_WaitingList();
            await GetType(0,0);
            await GetSearchType(searchRoomReservation_WaitingList.SearchRoomTypeId.Value , searchRoomReservation_WaitingList.SearchWaitingListStatusId);
            var filter_waitingLists =await _RoomReservation_WaitingListRepository.GetAll();
            filter_waitingLists = filter_waitingLists.Where(r => (( r.MemberId!= null )&& (searchRoomReservation_WaitingList.SearchMemberId.Value != 0 && r.MemberId == searchRoomReservation_WaitingList.SearchMemberId.Value))
                                           || ((searchRoomReservation_WaitingList.SearchFromDate != null && searchRoomReservation_WaitingList.SearchToDate != null) && searchRoomReservation_WaitingList.SearchFromDate >= r.FromDate && searchRoomReservation_WaitingList.SearchToDate <= r.ToDate)
                                            || ((searchRoomReservation_WaitingList.SearchRoomTypeId!= 0 ) && searchRoomReservation_WaitingList.SearchRoomTypeId == r.RoomTypeId)
                                            || ((searchRoomReservation_WaitingList.SearchRoomTypeId == 0) &&   r.RoomTypeId==null)
                                            || ((!string.IsNullOrEmpty(searchRoomReservation_WaitingList.SearchGuest)) && (!string.IsNullOrEmpty(r.Guest)) && r.Guest.Contains(searchRoomReservation_WaitingList.SearchGuest))
                                            || ((searchRoomReservation_WaitingList.SearchWaitingListStatusId != 0) && searchRoomReservation_WaitingList.SearchWaitingListStatusId == r.WaitingListStatusId)
                                       );

            var waitingLists = getList("", "", 1, filter_waitingLists);

            RoomReservation_WaitingListViewModel model = new RoomReservation_WaitingListViewModel { List = waitingLists, RoomReservation_WaitingList = waitingList, SearchRoomReservation_WaitingList = searchRoomReservation_WaitingList };
            return View("Index", model);

        }