public Response<SearchResponseTutorsModel> GetTutorBySearchCode(SearchTutorByCodeModel 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.GetTutorBySearchCode(objReq));
                        if (objResp.Count > 0)
                            response.Create(true, "Tutor Data ", 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;
        }
Пример #2
0
        internal SearchResponseTutorsModel GetTutorBySearchCode(SearchTutorByCodeModel 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_P2GetTutorBySearchCode(objReq.tutorCode)
                             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();


                objResponse.tutorList = tutorList;
                return objResponse;
            }
        }