/**this function resturn number of doctors cards that match search page items
  * this type of search is advanced search based on more categorization*/
 public ActionResult search(searchItems searchObject)
 {
     try
     {
         //this page need some data before displaying it
         //this data include cities,destricts,and so on...
         var data = new Tuple <List <specialityData>, List <cityData> >
                        (db.specialities.getSpecialityDataList().ToList(),
                        db.cities.getCityDataList().ToList());
         //page data to viewData
         ViewBag.neededData = data;
         //if no parameters in request ,then return empty html view without any data
         if (Request.QueryString.Count == 0)
         {
             return(View());
         }
         //get list of doctors that matched search items
         var matchedDoctors = (string.IsNullOrEmpty(searchObject.q))
         ? db.specialities.searchForDoctors(searchObject).ToList()
         : generalSearch(searchObject.q).ToList();
         //total number of matched search data
         var totalMatchedSearch = matchedDoctors.Count;
         //get cards data that will be displayed on doctors cards
         List <doctorCard> cards = matchedDoctors
                                   .getDoctorCards(currentLanguage)
                                   .OrderByDescending(c => c.rate)//order by rate
                                   .Skip((searchObject.pageNumber - 1) * maxNumberOfCardsForEachpage)
                                   .Take(maxNumberOfCardsForEachpage).ToList();
         //configure the pagination of search
         paginationInfo paging = new paginationInfo();
         paging.currentPage  = searchObject.pageNumber;
         paging.itemsPerPage = maxNumberOfCardsForEachpage;
         paging.totalItems   = totalMatchedSearch;
         return(View(new Tuple <paginationInfo, List <doctorCard> >(paging, cards)));
     }
     catch (Exception)
     {
         return(View());
     }
 }
Beispiel #2
0
 //return specialities of particular doctors
 public ActionResult getSpecialityDoctors(string name, int pageNumber = 1)
 {
     try
     {
         var speciality = db.specialities.FirstOrDefault(s => s.nameEng == name || s.nameAr == name);
         specialityDescription spData = new specialityDescription();
         if (currentLanguage == "en")
         {
             spData.id          = speciality.id;
             spData.image       = speciality.img;
             spData.name        = speciality.nameEng;
             spData.description = speciality.descriptionEng;
         }
         else
         {
             spData.id          = speciality.id;
             spData.image       = speciality.img;
             spData.name        = speciality.nameAr;
             spData.description = speciality.descriptionAr;
         }
         //get list of doctor card with defined languages for this speciality
         var matchedDoctors = speciality.allDoctors().activatedDoctors();
         spData.totalSpecializedDoctors = matchedDoctors.Count();
         List <doctorCard> doctorCards = matchedDoctors
                                         .getDoctorCards(currentLanguage)
                                         .OrderByDescending(c => c.rate)//order by rate
                                         .Skip((pageNumber - 1) * maxNumberOfCardsForEachpage)
                                         .Take(maxNumberOfCardsForEachpage).ToList();
         paginationInfo paging = new paginationInfo();
         paging.currentPage  = pageNumber;
         paging.itemsPerPage = maxNumberOfCardsForEachpage;
         paging.totalItems   = matchedDoctors.Count();
         return(View(new Tuple <specialityDescription, List <doctorCard>, paginationInfo>(spData, doctorCards, paging)));
     }
     catch (Exception)
     {
         return(Redirect("/" + defaultPathSpecialityPart));
     }
 }