public async Task<ActionResult> Index(int? Id, string sortOrder, string currentFilter, int? page, string error)
        {
            RoomAllocation roomAllocation = new RoomAllocation();
            SearchRoomAllocation searchroomAllocation = new SearchRoomAllocation();
            ViewBag.Error = error;
            if (Id != null)
            {
                roomAllocation =await _RoomAllocationRepository.GetById(Id.Value.ToString ());
                await GetTypes(roomAllocation.RoomTypeId, roomAllocation.WingId, roomAllocation.RoomStatusTypeId);
            }
            else
            { await GetTypes(1, 1, 1); }

            await GetSearchTypes(1, 1, 1);

            var roomallocations = getList(sortOrder, currentFilter, page, await _RoomAllocationRepository.GetAll());

            RoomAllocationViewModel model = new RoomAllocationViewModel { List = roomallocations, RoomAllocation = roomAllocation, SearchRoomAllocation = searchroomAllocation };
            return View(model);
        }
        public async Task<ActionResult>  Save(RoomAllocation roomAllocation, RoomStatus_detailViewModel m )
        {
            if (await _RoomAllocationRepository.GetRoomNumberExists(roomAllocation.RoomNumber, roomAllocation.Id))
                            ModelState.AddModelError("RoomNumber", "Please enter unique room number");

            if (ModelState.IsValid)
            {
                if (roomAllocation.Id == 0)
                {
                     roomAllocation.RoomStatusTypeId = 1;
                   await _RoomAllocationRepository.Create(roomAllocation);
                }
                else
                {
                    if (roomAllocation.RoomStatusTypeId != 1)
                    {
                        m.RoomStatus_Detail.RoomAllocationId = roomAllocation.Id;
                        m.RoomStatus_Detail.RoomStatusTypeId = roomAllocation.RoomStatusTypeId;
                        if (m.newrec)

                          await  _RoomStatus_DetailRepository.Create(m.RoomStatus_Detail);

                        else
                            _RoomStatus_DetailRepository.Update(m.RoomStatus_Detail, m.RoomStatus_Detail.Id.ToString ());
                    }

                    _RoomAllocationRepository.Update(roomAllocation, roomAllocation.Id.ToString ());
                }

            }
            else
            {
                SearchRoomAllocation searchroomAllocation = new SearchRoomAllocation();

                await GetTypes(roomAllocation.RoomTypeId, roomAllocation.WingId, roomAllocation.RoomStatusTypeId  );
                await GetSearchTypes(1, 1, 1);
                var roomallocations = getList("", "", 1, await _RoomAllocationRepository.GetAll());
                RoomAllocationViewModel model = new RoomAllocationViewModel { List = roomallocations, RoomAllocation = roomAllocation, SearchRoomAllocation = searchroomAllocation };
                 return View("Index", model);
            }
            return RedirectToAction("Index");
        }
        public async Task<ActionResult> Search(SearchRoomAllocation searchroomAllocation)
        {
            RoomAllocation roomAllocation = new RoomAllocation();
            await GetTypes(1,1,1);
           var roomallocations=await _RoomAllocationRepository.GetAll();
          roomallocations= roomallocations.Where(r => ((!string.IsNullOrEmpty(searchroomAllocation.SearchRoomNumber)) && r.RoomNumber.ToString() == searchroomAllocation.SearchRoomNumber)
                                        || ((searchroomAllocation.SearchRoomStatusTypeId != 0) && searchroomAllocation.SearchRoomStatusTypeId == r.RoomStatusTypeId)

                                        || ((searchroomAllocation.SearchWingId != 0) && searchroomAllocation.SearchWingId == r.WingId)
                                        || ((searchroomAllocation.SearchRoomTypeId != 0) && searchroomAllocation.SearchRoomTypeId == r.RoomTypeId)
                                    );

           var roomallocationslist = getList("", "", 1, roomallocations);

           await GetSearchTypes(searchroomAllocation.SearchRoomTypeId, searchroomAllocation.SearchWingId, searchroomAllocation.SearchRoomStatusTypeId);
           RoomAllocationViewModel model = new RoomAllocationViewModel { List = roomallocationslist, RoomAllocation = roomAllocation, SearchRoomAllocation = searchroomAllocation };
            return View("Index", model);

        }