public async Task<ActionResult> Index(int? Id, string sortOrder, string currentFilter, int? page,string error)
        {SearchFacility searchFacility= new SearchFacility ();
            Facility facility = new Facility();
            if (Id != null)
                facility =await _FacilityRepository.GetById(Id.Value.ToString());

            await GetRateType(facility);
            ViewBag.Error = error;
          var list =await _FacilityRepository.GetAll();

          var facilities = getList(sortOrder, currentFilter, page, list);
            FacilityViewModel model = new FacilityViewModel { List = facilities, Facility = facility, SearchFacility = searchFacility };
            return View(model);
        }
        public async Task<ActionResult> Save([Bind(Include = "Id,Name,IsFree,Enabled,Rate,RateTypeId,IsGST")]Facility facility)
        {

            if (ModelState.IsValid)
            {    if (facility.RateTypeId ==0 ) 
                   facility.RateTypeId=null;

                if (facility.Id == 0)
                {
                    _FacilityRepository.Create(facility);
                }
                else

                    _FacilityRepository.Update(facility, facility.Id.ToString ());

            }
            else
            {
               await GetRateType(facility);
               
                SearchFacility searchFacility = new SearchFacility();
                var facilities = getList("", "", 1, await _FacilityRepository.GetAll());
                FacilityViewModel model = new FacilityViewModel { List = facilities, Facility = facility, SearchFacility = searchFacility };
                 return View("Index", model);
            }
            return RedirectToAction("Index");
        }
        public async Task<ActionResult> Search(SearchFacility searchFacility)
        {
            Facility facility = new Facility();
            await GetRateType(facility);
            var filter_facilities =await _FacilityRepository.GetAll() ;
            filter_facilities = filter_facilities.Where (r => ((!string.IsNullOrEmpty(searchFacility.SearchName)) && r.Name == searchFacility.SearchName)
                                           || ( (searchFacility.SearchEnabled) &&   searchFacility.SearchEnabled ==r.Enabled )
                                            ||((searchFacility.SearchIsFree) && searchFacility.SearchIsFree  == r.IsFree )
                                            || ((searchFacility.SearchIsGST) && searchFacility.SearchIsGST  == r.IsGST )
                                       );

            var facilities = getList("", "", 1, filter_facilities);

            FacilityViewModel model = new FacilityViewModel { List = facilities, Facility = facility, SearchFacility = searchFacility };
            return View("Index", model);

        }