public Response<SearchResponseTutorsModel> GetTutorsList(TutorSearchModel objReq) { Response<SearchResponseTutorsModel> response = new Response<SearchResponseTutorsModel>(); List<SearchResponseTutorsModel> objResp = new List<SearchResponseTutorsModel>(); try { if (ModelState.IsValid) { objDbMethodV2 = new wizz.Dal.DbMethodsV2(); if (CheckRequestIsvalidornot(this.Request)) { objResp.Add(objDbMethodV2.GetTutorsList(objReq)); if (objResp.Count > 0) response.Create(true, "Tutor List", Messages.AppVersion, objResp); } else { response.Create(false, Messages.FormatMessage("Sorry no tutor found !!"), Messages.AppVersion, objResp); } } else response.Create(false, ModelState.Values.FirstOrDefault().Errors.FirstOrDefault().ErrorMessage, Messages.AppVersion, objResp); } catch (Exception ex) { object session = new JavaScriptSerializer().Serialize(objReq); LogManager.Error("Error occured while Processing Webservice request :{0}", ex, session, ex.Message); response.Create(false, Messages.FormatMessage(Messages.ErrorOccure), Messages.AppVersion, objResp); } return response; }
internal List<SearchResponseTutorsModel> GetTutorsList(TutorSearchModel objReq) { using (var db = new WizzDataContext()) { List<SearchResponseTutorsModel> tutorList = new List<SearchResponseTutorsModel>(); var userInfo = db.tblStudentRequests.Where(x => x.fkUserId == Convert.ToInt64(objReq.userId)).FirstOrDefault(); tutorList = (from c in db.usp_P2GetTutorsList(userInfo.fkSubjectId.ToString(), Convert.ToDecimal(userInfo.lat), Convert.ToDecimal(userInfo.longi), userInfo.location, Convert.ToInt32(objReq.distance)) select new SearchResponseTutorsModel { aboutTutor = c.About, tutorName = c.userName, tutorProfilePic = c.profilePic, tutorLocation = c.location, tutorId = Convert.ToString(c.fkUserId), passingYear = Convert.ToString(c.passingYear), tutorRating = Convert.ToString(c.avgRatingTutor), tutorSubjects = db.usp_P2GetSubjectsForTutor(c.fkUserId).Select(x => x.subjectName).ToList(), perHourFees = c.feesPerHour }).ToList(); return tutorList; } }
internal SearchResponseTutorsModel GetTutorsList(TutorSearchModel objReq) { using (var db = new WizzDataContext()) { SearchResponseTutorsModel objResponse = new SearchResponseTutorsModel(); List<TutorSearchResponseModel> tutorList = new List<TutorSearchResponseModel>(); var userInfo = db.tblStudentRequests.Where(x => x.uniqueStudentRequestId == objReq.uniqueRequestId).FirstOrDefault(); tutorList = (from c in db.usp_P2GetTutorsList(Convert.ToInt32(objReq.userId),userInfo.fkSubjectId.ToString(), Convert.ToDecimal(userInfo.lat), Convert.ToDecimal(userInfo.longi), userInfo.location, Convert.ToInt32(objReq.distance)) select new TutorSearchResponseModel { aboutTutor = c.About, tutorName = c.userName, tutorProfilePic = c.profilePic, tutorLocation = c.location, tutorId = Convert.ToString(c.fkUserId), passingYear = Convert.ToString(c.passingYear), tutorRating = Convert.ToString(c.avgRatingTutor), tutorSubjects = db.usp_P2GetSubjectsForTutor(c.fkUserId).Select(x => x.subjectName).ToList(), perHourFees = c.feesPerHour, reviews = (from r in db.tblTutorRatings.Where(x => x.fkTutorId == c.fkUserId) select new TutorReviewModel { rating = Convert.ToString((r.helpful + r.knowledgable + r.punctual) / 3), studentName = r.userName, reviewText = r.review, }).ToList() }).ToList(); //foreach (var n in objReq.filterList) { // if (n.orderBy == "1") // { // //tutorList = (from t in tutorList // // select t).OrderByDescending(c => c.perHourFees); // tutorList.Sort(x=>x.perHourFees); // } // else if(n.orderBy=="2") { // } //} objResponse.tutorList = tutorList; return objResponse; } }