Пример #1
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;
            }

        }
        public Response<SearchResponseTutorsModel> SaveStudentRequest(StudentRequestModelV2 objReq)
        {
            Response<SearchResponseTutorsModel> response = new Response<SearchResponseTutorsModel>();
            List<SearchResponseTutorsModel> objResp = new List<SearchResponseTutorsModel>();
            try
            {
                objDbMethodV2 = new wizz.Dal.DbMethodsV2();

                if (CheckRequestIsvalidornot(this.Request))
                {
                    if (ModelState.IsValid)
                    {
                        objResp.Add(objDbMethodV2.SaveStudentRequest(objReq));
                        if (objResp.Count > 0)
                            response.Create(true, Messages.FormatMessage(Messages.Success, "Student request saved"), Messages.AppVersion, objResp);
                        else
                            response.Create(false, "No tutor Found", Messages.AppVersion, objResp);
                    }
                    else
                        response.Create(false, ModelState.Values.FirstOrDefault().Errors.FirstOrDefault().ErrorMessage, Messages.AppVersion, objResp);
                }
                else
                    response.Create(false, Messages.FormatMessage(Messages.InvalidReq), 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;
        }