Exemplo n.º 1
0
        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;
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// saving all the stundet Profile Informations
        /// </summary>
        /// <param name="objReq"></param>
        /// <returns></returns>
        internal List<SearchResponseTutorsModel> SaveStudentRequest(StudentRequestModelV2 objReq)
        {
            List<SearchResponseTutorsModel> tutorList = new List<SearchResponseTutorsModel>();
            try
            {
                using (var db = new WizzDataContext())
                {
                    long userId = Convert.ToInt64(objReq.userId);

                    tblStudentRequest studentData = new tblStudentRequest();

                    Guid uniqueRequestId = Guid.NewGuid();

                    // studentData.fkSubjectId = Convert.ToInt32(objReq.subjectId);
                    List<tblStudentRequest> studentStudentList = new List<tblStudentRequest>();
                    foreach (var n in objReq.dayList)
                    {
                        tblStudentRequest scheduleData = new tblStudentRequest();
                        scheduleData.fkUserId = userId;
                        scheduleData.isDelete = false;
                        scheduleData.timeType = Convert.ToInt16(n.timeType);
                        scheduleData.dayType = Convert.ToInt16(n.dayType);
                        scheduleData.createdDate = DateTime.UtcNow;
                        scheduleData.lat = Convert.ToDouble(objReq.lat);
                        scheduleData.reschedleTimes = 0;
                        scheduleData.longi = Convert.ToDouble(objReq.longi);


                        if (String.IsNullOrEmpty(objReq.subjectId))
                        {
                            if (!String.IsNullOrEmpty(objReq.classId))
                            {
                                scheduleData.fkSubjectId = Convert.ToInt32(objReq.classId);
                                scheduleData.subjectType = 2;
                            }
                            else
                            {
                                scheduleData.fkSubjectId = Convert.ToInt32(objReq.courseId);
                                scheduleData.subjectType = 1;

                            }

                        }
                        else
                        {
                            scheduleData.fkSubjectId = Convert.ToInt32(objReq.subjectId);
                            scheduleData.subjectType = 3;
                        }



                        scheduleData.uniqueStudentRequestId = uniqueRequestId.ToString();
                        scheduleData.location = objReq.location;

                        switch (Convert.ToInt16(n.timeType))
                        {
                            case 1:
                                scheduleData.fromTime = "600";
                                scheduleData.toTime = "1200";
                                break;
                            case 2:

                                scheduleData.fromTime = "1200";
                                scheduleData.toTime = "1600";
                                break;
                            case 3:

                                scheduleData.fromTime = "1600";
                                scheduleData.toTime = "2200";
                                break;
                            default: break;
                        }

                        studentStudentList.Add(scheduleData);
                    }
                    db.tblStudentRequests.InsertAllOnSubmit(studentStudentList);
                    db.SubmitChanges();

                    //  var userInfo = db.tblStudentRequests.Where(x => x.fkUserId == Convert.ToInt64(objReq.userId)).LastOrDefault();

                    tutorList = (from c in db.usp_P2GetTutorsList(objReq.subjectId.ToString(), Convert.ToDecimal(objReq.lat), Convert.ToDecimal(objReq.longi), objReq.location, 0)
                                 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;
                }
            }
            catch (Exception e)
            {

                return tutorList;
            }

        }
Exemplo n.º 3
0
        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;
            }
        }