internal int SavePaymentDetails(StripePaymentModel objReq) { using (var db = new WizzDataContext()) { try { // return 1; if (db.tblPaymentDetails.Any(x => x.sessionId == Convert.ToInt64(objReq.sessionId) && x.isSuccess == true && x.studentId == Convert.ToInt64(objReq.userId))) { return 2; } else { var sessionData = db.tblSessions.Where(x => x.pkSessionId == Convert.ToInt64(objReq.sessionId)).FirstOrDefault(); tblPaymentDetail paymentData = new tblPaymentDetail(); paymentData.studentId = Convert.ToInt64(objReq.userId); paymentData.sessionId = Convert.ToInt64(objReq.sessionId); paymentData.tutorId = Convert.ToInt64(sessionData.tutorId); paymentData.transactionId = objReq.transactionId; paymentData.isSuccess = true; paymentData.createdDate = DateTime.UtcNow; paymentData.paymentType = Convert.ToInt16(objReq.paymentType); db.tblPaymentDetails.InsertOnSubmit(paymentData); // var requestData = db.tblSessions.Where(x => x.hasPaid == false && x.uniqueRequestId == objReq.uniqueRequestId).FirstOrDefault(); //if (requestData == null) // return 2; //requestData.hasPaid = true; db.SubmitChanges(); return 1; } } catch (TimeoutException e) { return 3; } catch (Exception e) { return 0; } } }
internal bool SaveStripeDetails(StripeModel objReq) { using (var db = new WizzDataContext()) { tblUser userData = new tblUser(); userData = db.tblUsers.Where(x => x.pkUserId == Convert.ToInt64(objReq.userId)).FirstOrDefault(); userData.stripeId = objReq.stripeAcKey; db.SubmitChanges(); return true; } }
internal RespIsTeacherRequest isTeacher(IsTeacherRequest objReq) { var isTutor = Convert.ToBoolean(objReq.isTutor); RespIsTeacherRequest response = new RespIsTeacherRequest(); response.isAlreadySignup = "False"; using (var db = new WizzDataContext()) { tblUser tUser = new tblUser(); int fkuserid = Convert.ToInt32(objReq.userId); tUser = db.tblUsers.Where(x => x.pkUserId == fkuserid).FirstOrDefault(); if (tUser == null) response.isTutor="False"; // return false; else { var tutor = db.tblTutorProfiles.Where(t => t.fkUserId == fkuserid).FirstOrDefault(); //check already signup or not if (tutor==null) { response.isAlreadySignup = "False"; } else { response.isAlreadySignup = "True"; } if (tutor == null && objReq.isTutor=="True") { response.isAlreadySignup = "False"; } else { response.isTutor = isTutor.ToString(); tUser.isTeacher = isTutor; db.SubmitChanges(); } // return true; } } return response; }
internal int ChangePassword(AdminChangePassword objReq) { using (var db = new WizzDataContext()) { tblUser tUser = new tblUser(); CurrentUser cu = new CurrentUser(); tUser = db.tblUsers.Where(x => x.pkUserId == Convert.ToInt32(cu.PkUserId)).FirstOrDefault(); if (tUser.password != objReq.oldPassword) return 0; else { tUser.password = objReq.newPassword.Trim(); db.SubmitChanges(); return 1; } } }
internal bool SaveCardInfo(PaymentInfo objReq) { using (var db = new WizzDataContext()) { bool update = true; tblCardDetail objCard = new tblCardDetail(); long userpkId=Convert.ToInt64(objReq.userId); objCard = db.tblCardDetails.Where(c => c.fkUserId == userpkId).FirstOrDefault(); if (objCard == null) { update = false; objCard = new tblCardDetail(); } //objCard.paymentType = Convert.ToInt16(objReq.paymentType); objCard.cardType = objReq.cardType; objCard.createdDate = DateTime.UtcNow; objCard.digitCvv = objReq.digitCvv.Trim(); objCard.cardHolderName = objReq.cardHolderName == null ? "" : objReq.cardHolderName; objCard.cardNumber = objReq.cardNumber; objCard.bankName = objReq.bankName == null ? "" : objReq.bankName; objCard.fkUserId = userpkId; objCard.lastFour = Convert.ToInt32(objReq.lastFour); objCard.isActive = true; objCard.isDelete = false; objCard.validMonth = objReq.validMonth.Trim(); objCard.validYear = objReq.validYear.Trim(); try { if (!update) db.tblCardDetails.InsertOnSubmit(objCard); db.SubmitChanges(); return true; } catch(Exception ex) { return false; } } }
internal int ChangePassword(ChangePasswordModel objReq) { using (var db = new WizzDataContext()) { tblUser tUser = new tblUser(); int fkuserid = Convert.ToInt32(objReq.userId); tUser = db.tblUsers.Where(x => x.pkUserId == fkuserid).FirstOrDefault(); if (tUser == null) return 0; else if (tUser.isActive == false || tUser.isDelete == true) return 2; else if (tUser.password != objReq.oldPassword) return 3; else { tUser.password = objReq.Password.Trim(); db.SubmitChanges(); return 1; } } }
internal int ApplyPromoCode(PromoCodeReq objReq) { try { using (var db = new WizzDataContext()) { tblPromoCode promoCodeData = new tblPromoCode(); long fkUserId = Convert.ToInt64(objReq.userId); promoCodeData = db.tblPromoCodes.Where(p => p.promoCode == objReq.promocode && p.isDelete == false).FirstOrDefault(); if (promoCodeData == null) return 0; else if (DateTime.UtcNow.IsBetween(promoCodeData.validFrom.Value, promoCodeData.validTo.Value) || promoCodeData.isActive == false) return 3; else if (db.tblPromoHistories.Any(d => d.fkUserId == fkUserId && d.fkPromoCodeId == promoCodeData.pkPromoCodeId)) return 2; else if (db.tblPromoHistories.Count(x => x.fkPromoCodeId == promoCodeData.pkPromoCodeId) > promoCodeData.usageCount) return 3; else { tblPromoHistory objHistory = new tblPromoHistory(); objHistory.fkPromoCodeId = promoCodeData.pkPromoCodeId; objHistory.createdDate = DateTime.UtcNow; objHistory.fkUserId = Convert.ToInt64(objReq.userId); db.tblPromoHistories.InsertOnSubmit(objHistory); // tblUser userDetails = new tblUser(); var userDetails = db.tblUsers.Where(u => u.pkUserId == fkUserId).FirstOrDefault(); userDetails.credits += Convert.ToInt32(promoCodeData.discountPercentage); db.SubmitChanges(); return 1; } } } catch (Exception e) { return 0; } }
internal bool SessionReviewByStudent(StudentReviewModel objReq) { using (var db = new WizzDataContext()) { tblTutorRating rating = new tblTutorRating(); var sessionData = db.tblSessions.FirstOrDefault(x => x.pkSessionId == Convert.ToInt64(objReq.sessionId)); rating = db.tblTutorRatings.FirstOrDefault(x => x.sessionId == objReq.sessionId && x.fkStudentId == Convert.ToInt32(objReq.userId)); if (rating == null) { rating = new tblTutorRating(); rating.createdDate = DateTime.UtcNow; rating.sessionId = objReq.sessionId; rating.userName = objReq.userName; rating.fkStudentId = Convert.ToInt32(objReq.userId); rating.fkTutorId = sessionData.tutorId; rating.updatedDate = DateTime.UtcNow; rating.punctual = 0; rating.knowledgable = 0; rating.helpful = 0; rating.review = objReq.reviewText; db.tblTutorRatings.InsertOnSubmit(rating); } else { rating.userName = objReq.userName; rating.updatedDate = DateTime.UtcNow; rating.review = objReq.reviewText; } db.SubmitChanges(); return true; } }
internal bool SessionReviewByTutor(SessionReviewModel objReq) { using (var db = new WizzDataContext()) { var sessionData = db.tblSessions.Where(x => x.pkSessionId == Convert.ToInt64(objReq.sessionId)).FirstOrDefault(); if (Convert.ToBoolean(objReq.isreschedule))//if reschedule then homework and session notes is neccessary and than reschedule request { sessionData.homeWork = objReq.homeWork; sessionData.sessionNotes = objReq.sessionNotes; sessionData.isComplete = true; sessionData.sessionAmount = objReq.sessionCost; tblSession sessionObj = new tblSession(); sessionObj.createdDate = DateTime.UtcNow; sessionObj.fromTime = timeConversionMethod(objReq.fromTime); sessionObj.toTime = timeConversionMethod(objReq.toTime); sessionObj.uniqueRequestId = objReq.uniqueRequestId; sessionObj.dayType = Convert.ToInt16(objReq.dayType); sessionObj.isDelete = false; sessionObj.homeWork = objReq.homeWork; sessionObj.sessionNotes = objReq.sessionNotes; sessionObj.updatedDate = DateTime.UtcNow; sessionObj.studentId = Convert.ToInt64(objReq.studentId); sessionObj.tutorId = Convert.ToInt64(objReq.userId); //var studentData = db.tblStudentRequests.Where(x => x.uniqueStudentRequestId == objReq.uniqueRequestId).FirstOrDefault(); //tutorRating.avgRatingTutor = ((tutorRating.avgRatingTutor) + (rating.punctual + rating.knowledgable + rating.helpful) / 3) / 2; //studentData.lat = Convert.ToDouble(studentData); //studentData.longi = Convert.ToDouble(objReq.longitude); //studentData.location = Convert.ToString(objReq.location); db.tblSessions.InsertOnSubmit(sessionObj); } else { sessionData.homeWork = objReq.homeWork; sessionData.sessionNotes = objReq.sessionNotes; sessionData.isComplete = true; sessionData.sessionAmount = objReq.sessionCost; } var objUsers = db.tblInviteFriends.Where(x => x.uniqueRequestId == sessionData.uniqueRequestId).ToList(); if (objUsers.Count > 0) { foreach (var n in objUsers) { if (n.fkFriendId == Convert.ToInt32(objReq.userId) || n.isDelete == true) { continue; } var objUser = db.tblUsers.Where(x => x.pkUserId == Convert.ToInt64(n.fkFriendId)).FirstOrDefault(); objUser.avgRatingStudent = (Convert.ToDecimal(objUser.avgRatingStudent) + Convert.ToDecimal(objReq.rating)) / 2; db.SubmitChanges(); } } else { var objUser = db.tblUsers.Where(x => x.pkUserId == Convert.ToInt64(sessionData.studentId)).FirstOrDefault(); objUser.avgRatingStudent = (Convert.ToDecimal(objUser.avgRatingStudent) + Convert.ToDecimal(objReq.rating)) / 2; //db.SubmitChanges(); } db.SubmitChanges(); } //throw new NotImplementedException(); return true; }
private static void SaveLogInfo(enLogType logType, string messageFormat, Exception ex, params object[] args) { object stackTrace = DBNull.Value; object LoggedInUserId = DBNull.Value; object url = DBNull.Value; object refUrl = DBNull.Value; object session = DBNull.Value; object methodName = DBNull.Value; bool hasError = false; StringBuilder stackInfo = new StringBuilder(); var current = HttpContext.Current; if (current != null && current.Request != null) { url = current.Request.Url.ToString(); if (current.Request.UrlReferrer != null) refUrl = current.Request.UrlReferrer.ToString(); } string userid = HttpContext.Current.User.Identity.Name; if (string.IsNullOrEmpty(userid)) { try { session = new JavaScriptSerializer().Serialize(userid); } catch (Exception exSer) { stackInfo.AppendLine("Session Values Serialization Error"); stackInfo.AppendLine(exSer.Message); if (exSer.InnerException != null) { stackInfo.AppendLine(); stackInfo.AppendLine(exSer.InnerException.Message); stackInfo.AppendLine(); stackInfo.AppendLine(); } } } if (ex != null) { hasError = true; stackInfo.AppendLine("Error Message:"); stackInfo.AppendLine(ex.Message); stackInfo.AppendLine(); stackInfo.AppendLine("Source:"); stackInfo.AppendLine(ex.Source); stackInfo.AppendLine(); stackInfo.AppendLine("Stack Trace:"); stackInfo.AppendLine(ex.StackTrace); if (ex.InnerException != null) { stackInfo.AppendLine(); stackInfo.AppendLine("Inner Exception"); stackInfo.AppendLine(); stackInfo.AppendLine("Error Message:"); stackInfo.AppendLine(ex.InnerException.Message); stackInfo.AppendLine(); stackInfo.AppendLine("Source:"); stackInfo.AppendLine(ex.InnerException.Source); stackInfo.AppendLine(); stackInfo.AppendLine("Stack Trace:"); stackInfo.AppendLine(ex.InnerException.StackTrace); } } if (hasError) stackTrace = stackInfo.ToString(); try { var frames = new System.Diagnostics.StackTrace().GetFrames(); System.Diagnostics.StackFrame frame = null; for (var i = 1; i < frames.Length; i++) { if (frames[i].GetMethod().Name != "Info" && frames[i].GetMethod().Name != "Error") { frame = frames[i]; break; } } if (frame != null) { var stackMethod = frame.GetMethod(); methodName = stackMethod.ReflectedType.FullName + "." + stackMethod.Name; } using (var objDBContext = new WizzDataContext()) { objDBContext.usp_SaveLog((int)logType, Convert.ToString(messageFormat), Convert.ToString(stackTrace), Convert.ToString(methodName), 0, Convert.ToString(url), Convert.ToString(refUrl), Convert.ToString(session)); objDBContext.SubmitChanges(); } } catch (Exception logEx) { _logger.Error("Error occurd while saving error log in database", logEx); } }
internal bool UserLogout(ReqLogOut objReq) { using (var db = new WizzDataContext()) { tblUser tUser = new tblUser(); int fkuserid = Convert.ToInt32(objReq.userId); tUser = db.tblUsers.Where(x => x.pkUserId == fkuserid).FirstOrDefault(); if (tUser == null) return false; else { tUser.deviceToken = null; db.SubmitChanges(); return true; } } }
internal bool ReportSpam(ReportSpamModel objReq) { using (var db = new WizzDataContext()) { tblReportSpam objSpamData = new tblReportSpam(); objSpamData.fkFromId = Convert.ToInt64(objReq.fromId); objSpamData.fkToId = Convert.ToInt64(objReq.toId); objSpamData.userType = Convert.ToInt16(objReq.forUserType); objSpamData.isDelete = false; objSpamData.createdDate = DateTime.UtcNow; objSpamData.updatedDate = DateTime.UtcNow; db.tblReportSpams.InsertOnSubmit(objSpamData); db.SubmitChanges(); return true; } }
//internal int StudentRequest(StudentRequestModel objReq) //{ // using (var db = new WizzDataContext()) // { // var studentId = Convert.ToInt64(objReq.userId); // tblRequestStudent objStudent; // var requestUniqueId = Guid.NewGuid().ToString(); // if (objReq.isNow.ToLower()=="false"||String.IsNullOrEmpty(objReq.isNow)) // { // foreach (var n in objReq.listSlot) // { // objStudent = new tblRequestStudent(); // objStudent.latitude = Convert.ToDecimal(objReq.latitude); // objStudent.longitude = Convert.ToDecimal(objReq.longitude); // objStudent.forMinutes = Convert.ToInt32(objReq.totalMinutes); // objStudent.accompanyNum = Convert.ToInt16(objReq.accompanies); // objStudent.updatedDate = DateTime.UtcNow; // objStudent.createdDate = DateTime.UtcNow; // objStudent.day = Convert.ToInt16(n.dayNo); // objStudent.subjects = objReq.assignments; // objStudent.fkClassId = Convert.ToInt32(objReq.fkSubjectId); // objStudent.isActive = true; // objStudent.fromTime = n.fromTime; // objStudent.toTime = n.toTime; // objStudent.fkUserId = studentId; // objStudent.isDelete = false; // objStudent.isNow = false; // objStudent.TimeStamp = Convert.ToInt64(objReq.timeStamp); // objStudent.uniqueRequestId = requestUniqueId; // objStudent.calculatedAmount=Convert.ToInt32(objReq.calculatedAmount); // objStudent.location = objReq.location; // db.tblRequestStudents.InsertOnSubmit(objStudent); // db.SubmitChanges(); // } // } // else if (objReq.isNow.ToLower() == "true") // { // objStudent = new tblRequestStudent(); // objStudent.isNow = true; // objStudent.latitude = Convert.ToDecimal(objReq.latitude); // objStudent.longitude = Convert.ToDecimal(objReq.longitude); // objStudent.forMinutes = Convert.ToInt32(objReq.totalMinutes); // objStudent.accompanyNum = Convert.ToInt16(objReq.accompanies); // objStudent.fromTime = objReq.currentTime; // DateTime currentTime = Convert.ToDateTime(objReq.currentTime); // double minuts = Convert.ToDouble(objReq.totalMinutes); // currentTime = currentTime.AddMinutes(minuts); // objStudent.toTime = Convert.ToString(currentTime); // objStudent.updatedDate = DateTime.UtcNow; // objStudent.createdDate = DateTime.UtcNow; // objStudent.subjects = objReq.assignments; // objStudent.fkClassId = Convert.ToInt32(objReq.fkSubjectId); // objStudent.isActive = true; // objStudent.isDelete = false; // objStudent.fkUserId = studentId; // objStudent.TimeStamp =Convert.ToInt64(objReq.timeStamp); // objStudent.uniqueRequestId = requestUniqueId; // objStudent.calculatedAmount = Convert.ToInt32(objReq.calculatedAmount); // objStudent.location = objReq.location; // db.tblRequestStudents.InsertOnSubmit(objStudent); // db.SubmitChanges(); // } // else // { // return 0; // } // //get matched tutors // var turors = db.usp_GetTutors(objReq.fkSubjectId, Convert.ToDecimal(objReq.latitude), Convert.ToDecimal(objReq.longitude),Convert.ToInt64(objReq.userId)).ToList(); // //save request to db and send push to tutor // SendRequest(objReq, turors, requestUniqueId); // return 1; // } //} internal int SaveTutorProfile(TutorProfile objReq) { tblTutorProfile profileData = new tblTutorProfile(); using(var db=new WizzDataContext()){ profileData = db.tblTutorProfiles.Where(x => x.fkUserId == Convert.ToInt64(objReq.userId) && x.isDelete!=true).FirstOrDefault(); if (profileData == null) { //objReq.fileName profileData = new tblTutorProfile(); profileData.isApproved = false; profileData.isActive = true; profileData.isDelete = false; profileData.fkUserId = Convert.ToInt64(objReq.userId); //profileData.latitude = Convert.ToDecimal(objReq.latitude); //profileData.longitude = Convert.ToDecimal(objReq.longitude); //profileData.subjects = objReq.majors; profileData.TimeStamp = Convert.ToInt64(objReq.timeStamp); profileData.updatedDate = DateTime.UtcNow; profileData.createdDate = DateTime.UtcNow; profileData.passingYear = objReq.passingYear; // profileData.referralcode = objReq.referalCode==null?"": objReq.referalCode; // profileData.fkClassId = String.Join(",", objReq.classes); // profileData.docName = objReq.fileName; //profileData. = Convert.ToInt32(objReq.collegeId); db.tblTutorProfiles.InsertOnSubmit(profileData); } else { profileData.isApproved = false; profileData.isActive = true; //profileData.fkUserId = Convert.ToInt64(objReq.userId); //profileData.latitude = Convert.ToDecimal(objReq.latitude); //profileData.longitude = Convert.ToDecimal(objReq.longitude); //profileData.subjects = objReq.majors; //profileData.passingYear = objReq.passingYear; //profileData.docName = objReq.fileName; profileData.TimeStamp = Convert.ToInt64(objReq.timeStamp); profileData.updatedDate = DateTime.UtcNow; profileData.createdDate = DateTime.UtcNow; // profileData.fkClassId = String.Join(",", objReq.classes); //profileData.fkCollegeId = Convert.ToInt32(objReq.collegeId); } db.SubmitChanges(); return 1; } }
internal bool CreateSession(StartSessionModel objReq) { using (var db=new WizzDataContext()) { try { var uniqueRequestData = db.tblStudentRequests.Where(x => x.fkUserId == Convert.ToInt64(objReq.userId) && x.isDelete == false).FirstOrDefault(); tblSession sessionObj = new tblSession(); sessionObj.createdDate = DateTime.UtcNow; sessionObj.fromTime = timeConversionMethod(objReq.fromTime); sessionObj.toTime = timeConversionMethod(objReq.toTime); sessionObj.uniqueRequestId = uniqueRequestData.uniqueStudentRequestId; sessionObj.isDelete = false; sessionObj.updatedDate = DateTime.UtcNow; sessionObj.studentId = Convert.ToInt64(objReq.userId); sessionObj.tutorId = Convert.ToInt64(objReq.tutorId); db.tblSessions.InsertOnSubmit(sessionObj); db.SubmitChanges(); return true; } catch (Exception) { return false; } } }
internal bool VerifyOtp(OtpModel objReq) { using (var db=new WizzDataContext()) { var userData = db.tblUsers.Where(c => c.pkUserId == Convert.ToInt64(objReq.userId)).FirstOrDefault(); if (objReq.OTPCode == userData.otpCode) { userData.isOtpVerified = true; db.SubmitChanges(); return true; } else { return false; } } }
internal string SendOtp(OtpModel objReq) { Random generator = new Random(); String r = generator.Next(10000, 1000000).ToString(); using (var db= new WizzDataContext()) { var userObj = db.tblUsers.Where(x => x.pkUserId == Convert.ToInt64(objReq.userId)).FirstOrDefault(); userObj.phoneNum = objReq.phoneNum; userObj.isOtpVerified = false; twiliorest objTwillio = new twiliorest(); string msg = "Welcome to Wizz tutors your Otp validation code is " + r; if (objTwillio.SendTeilioMessage(objReq.phoneNum, msg)) { db.SubmitChanges(); } else { } return r; } }
internal bool SaveTutorSchedule(TutorScheduleModel objReq) { using (var db = new WizzDataContext()) { try { long userId = Convert.ToInt64(objReq.userId); #region Deleting old data on behalf of user Id var scheduleList = db.tblTutorSchedules.Where(x => x.fkUserId == userId).ToList(); List<tblTutorSchedule> objScheduleList = new List<tblTutorSchedule>(); if (scheduleList.Count > 0) { db.tblTutorSchedules.DeleteAllOnSubmit(scheduleList); db.SubmitChanges(); } #endregion foreach (var n in objReq.scheduleList) { tblTutorSchedule objSchedule = new tblTutorSchedule(); objSchedule.fkUserId = userId; objSchedule.fromTime = timeConversionMethod(n.fromTime); objSchedule.toTime = timeConversionMethod(n.toTime); objSchedule.isDelete = false; objSchedule.dayType = Convert.ToInt16(n.dayType); objSchedule.createdDate = DateTime.UtcNow; objScheduleList.Add(objSchedule); } db.tblTutorSchedules.InsertAllOnSubmit(objScheduleList); db.SubmitChanges(); return true; } catch (Exception) { return false; } } return false; }
internal int SaveTutorProfile(TutorProfileModel objReq, List<string> fileNamesList) { using (var db = new WizzDataContext()) { try { long userId = Convert.ToInt64(objReq.userId); #region Multiple List work List<tblTutorDoc> objTutorDocList = new List<tblTutorDoc>(); objTutorDocList = db.tblTutorDocs.Where(x => x.fkTutorId == userId).ToList(); if (objTutorDocList.Count > 0) { db.tblTutorDocs.DeleteAllOnSubmit(objTutorDocList); db.SubmitChanges(); objTutorDocList = new List<tblTutorDoc>(); } foreach (string n in fileNamesList) { tblTutorDoc objDoc = new tblTutorDoc(); objDoc.createdDate = DateTime.UtcNow; objDoc.fileName = n; objDoc.fkTutorId = userId; objDoc.isDelete = false; objTutorDocList.Add(objDoc); } db.tblTutorDocs.InsertAllOnSubmit(objTutorDocList); List<tblTutorSubject> objTutorSubList = new List<tblTutorSubject>(); objTutorSubList = db.tblTutorSubjects.Where(x => x.fkTutorId == userId).ToList(); if (objTutorSubList.Count > 0) { db.tblTutorSubjects.DeleteAllOnSubmit(objTutorSubList); db.SubmitChanges(); objTutorSubList = new List<tblTutorSubject>(); } if (objReq.subjectIdList.Count > 0) foreach (string n in objReq.subjectIdList) { tblTutorSubject objTutorSubject = new tblTutorSubject(); objTutorSubject.isApproved = false; objTutorSubject.fkSubjectId = Convert.ToInt32(n); objTutorSubject.fkTutorId = userId; objTutorSubject.subjectType = 3; objTutorSubList.Add(objTutorSubject); } else if (objReq.classIdList.Count > 0) foreach (string n in objReq.classIdList) { tblTutorSubject objTutorSubject = new tblTutorSubject(); objTutorSubject.isApproved = false; objTutorSubject.fkSubjectId = Convert.ToInt32(n); objTutorSubject.fkTutorId = userId; objTutorSubject.subjectType = 2; objTutorSubList.Add(objTutorSubject); } else { foreach (string n in objReq.courseIdList) { tblTutorSubject objTutorSubject = new tblTutorSubject(); objTutorSubject.isApproved = false; objTutorSubject.fkSubjectId = Convert.ToInt32(n); objTutorSubject.fkTutorId = userId; objTutorSubject.subjectType = 1; objTutorSubList.Add(objTutorSubject); } } db.tblTutorSubjects.InsertAllOnSubmit(objTutorSubList); #endregion #region tableTutorprofileEntry tblTutorProfile objTutorProfile = new tblTutorProfile(); var previousProfileObj = db.tblTutorProfiles.Where(x => x.fkUserId == userId).FirstOrDefault(); if (previousProfileObj != null) db.tblTutorProfiles.DeleteOnSubmit(previousProfileObj); objTutorProfile.feesPerHour = objReq.feesPerHour; objTutorProfile.fkCollegeId = objReq.collegeId == null ? 0 : Convert.ToInt32(objReq.collegeId); objTutorProfile.referralCode = objReq.referralCode == null ? "" : objReq.referralCode; objTutorProfile.isApproved = false; //fake data entry for maintaining previous tblschema (not use ful) objTutorProfile.createdDate = DateTime.UtcNow; objTutorProfile.description = ""; objTutorProfile.passingYear = ""; //creating a unique search code for tutor objTutorProfile.tutorSearchCode = "W" + objReq.userName.Substring(0, 3) + System.Guid.NewGuid().ToString().Substring(0, 4); //getting radius for tutor objTutorProfile.distance = objReq.distanceRadius; objTutorProfile.fkUserId = userId; objTutorProfile.isActive = true; objTutorProfile.updatedDate = DateTime.UtcNow; objTutorProfile.TimeStamp = DateTime.UtcNow.Ticks; objTutorProfile.lat = Convert.ToDouble(objReq.latitude); objTutorProfile.longi = Convert.ToDouble(objReq.longitude); objTutorProfile.location = objReq.location; db.tblTutorProfiles.InsertOnSubmit(objTutorProfile); #endregion db.SubmitChanges(); return 1; } catch (Exception e) { return 0; } } }
internal bool CreateSession(StartSessionModel objReq) { using (var db = new WizzDataContext()) { try { // var uniqueRequestData = db.tblStudentRequests.Where(x => x.fkUserId == Convert.ToInt64(objReq.userId) && x.isDelete == false).FirstOrDefault(); tblSession sessionObj = new tblSession(); sessionObj.createdDate = DateTime.UtcNow; sessionObj.fromTime = timeConversionMethod(objReq.fromTime); sessionObj.toTime = timeConversionMethod(objReq.toTime); sessionObj.uniqueRequestId = objReq.uniqueRequestId; sessionObj.dayType = Convert.ToInt16(objReq.dayType); sessionObj.isDelete = false; sessionObj.updatedDate = DateTime.UtcNow; sessionObj.studentId = Convert.ToInt64(objReq.userId); sessionObj.tutorId = Convert.ToInt64(objReq.tutorId); sessionObj.isCancelled = false; sessionObj.isComplete = false; sessionObj.homeWork = ""; sessionObj.homeWorkDueDate = ""; sessionObj.isActive = true; sessionObj.isStarted = false; sessionObj.sessionAmount = "0"; sessionObj.sessionNotes = ""; db.tblSessions.InsertOnSubmit(sessionObj); db.SubmitChanges(); return true; } catch (Exception) { return false; } } }
internal bool SessionRatingByStudent(StudentRatingwModel objReq) { using (var db = new WizzDataContext()) { tblTutorRating rating = new tblTutorRating(); var sessionData = db.tblSessions.FirstOrDefault(x => x.pkSessionId == Convert.ToInt64(objReq.sessionId)); rating = db.tblTutorRatings.FirstOrDefault(x => x.sessionId == objReq.sessionId && x.fkStudentId == Convert.ToInt32(objReq.userId)); var tutorRating = db.tblUsers.Where(x => x.pkUserId == Convert.ToInt64(sessionData.tutorId)).FirstOrDefault(); if (rating == null) { rating = new tblTutorRating(); rating.createdDate = DateTime.UtcNow; rating.sessionId = objReq.sessionId; rating.userName = objReq.userName; rating.fkStudentId = Convert.ToInt32(objReq.userId); rating.fkTutorId = sessionData.tutorId; rating.updatedDate = DateTime.UtcNow; rating.punctual = Convert.ToInt16(objReq.punctual); rating.knowledgable = Convert.ToInt16(objReq.knowledge); rating.helpful = Convert.ToInt16(objReq.helpFul); rating.review = ""; tutorRating.avgRatingTutor = ((tutorRating.avgRatingTutor) + (rating.punctual + rating.knowledgable + rating.helpful) / 3) / 2; db.tblTutorRatings.InsertOnSubmit(rating); } else { rating.userName = objReq.userName; rating.updatedDate = DateTime.UtcNow; rating.punctual = Convert.ToInt16(objReq.punctual); rating.knowledgable = Convert.ToInt16(objReq.knowledge); rating.helpful = Convert.ToInt16(objReq.helpFul); tutorRating.avgRatingTutor = ((tutorRating.avgRatingTutor) + (rating.punctual + rating.knowledgable + rating.helpful) / 3) / 2; } db.SubmitChanges(); return true; } }
///// <summary> ///// Send Push Message to Device ///// </summary> ///// <param name="RegistrationID">RegistrationID or Token</param> ///// <param name="Message">Message to be sent on device</param> ///// <param name="AuthString">Authentication string</param> ///// //public string send(PushMessage objPush,string type) //{ // // msg = "order confirmed"; // WebRequest tRequest; // tRequest = WebRequest.Create("https://android.googleapis.com/gcm/send"); // tRequest.Method = "post"; // tRequest.ContentType = "application/x-www-form-urlencoded"; // string resistrationId = objPush.registration_ids; // var key=""; // key=ConfigurationManager.AppSettings["androidPushKey"]; // tRequest.Headers.Add(string.Format("Authorization: key={0}", key)); // String collaspeKey = Guid.NewGuid().ToString("n"); // string messagetosend = "{\"aps\":{\"alert\":\"" + objPush.message + "\",\"badge\":\"1\",\"sound\":\"default\",\"Tag\":" + objPush.type + ",\"notificationId\":" + objPush.notificationId + "}}"; // String postData = string.Format("registration_id={0}&data.payload={1}&collapse_key={2}", resistrationId, "" + messagetosend, collaspeKey); // Byte[] byteArray = Encoding.UTF8.GetBytes(postData); // tRequest.ContentLength = byteArray.Length; // Stream dataStream = tRequest.GetRequestStream(); // dataStream.Write(byteArray, 0, byteArray.Length); // dataStream.Close(); // WebResponse tResponse = tRequest.GetResponse(); // dataStream = tResponse.GetResponseStream(); // StreamReader tReader = new StreamReader(dataStream); // String sResponseFromServer = tReader.ReadToEnd(); // tReader.Close(); // dataStream.Close(); // tResponse.Close(); // return sResponseFromServer; //} /// <summary> /// Send Push Message to Device /// </summary> /// <param name="RegistrationID">RegistrationID or Token</param> /// <param name="Message">Message to be sent on device</param> /// <param name="AuthString">Authentication string</param> /// public string send(PushData objPush) { tblUser objuser; try { // msg = "order confirmed"; WebRequest tRequest; tRequest = WebRequest.Create("https://android.googleapis.com/gcm/send"); tRequest.Method = "post"; tRequest.ContentType = "application/x-www-form-urlencoded"; string resistrationId = objPush.registration_ids; string sessionId = objPush.uniqueRequestid; var key = ""; Int16 iBadge = 0; using (var db = new WizzDataContext()) { int bedge = 0; try { bedge = Convert.ToInt32(db.tblUsers.FirstOrDefault(S => S.deviceToken == resistrationId).badge); } catch { bedge = 0; } if (bedge == 0) { iBadge = 1; } else { objuser = db.tblUsers.First(S => S.deviceToken == resistrationId); if (objuser != null) { Int16 addbedge = Convert.ToInt16(objuser.badge + 1); iBadge = addbedge; } } } key = ConfigurationManager.AppSettings["androidPushKey"]; tRequest.Headers.Add(string.Format("Authorization: key={0}", key)); String collaspeKey = Guid.NewGuid().ToString("n"); string messagetosend = "{\"aps\":{\"alert\":\"" + objPush.message + "\",\"badge\":\"" + iBadge.ToString() + "\",\"sound\":\"default\",\"type\":\"" + objPush.type + "\",\"sessionId\":\"" + objPush.sessionId + "\",\"tutorId\":\"" + objPush.tutorId + "\",\"uniqueRequestid\":\"" + objPush.uniqueRequestid + "\",\"userId\":\"" + objPush.userId + "\",\"amount\":\"" + objPush.amount + "\"}}"; String postData = string.Format("registration_id={0}&data.payload={1}&collapse_key={2}&sessionId={3}&amount={3}", resistrationId, "" + messagetosend, collaspeKey, objPush.uniqueRequestid,objPush.amount); Byte[] byteArray = Encoding.UTF8.GetBytes(postData); tRequest.ContentLength = byteArray.Length; Stream dataStream = tRequest.GetRequestStream(); dataStream.Write(byteArray, 0, byteArray.Length); dataStream.Close(); WebResponse tResponse = tRequest.GetResponse(); dataStream = tResponse.GetResponseStream(); StreamReader tReader = new StreamReader(dataStream); String sResponseFromServer = tReader.ReadToEnd(); tReader.Close(); dataStream.Close(); tResponse.Close(); using (var db = new WizzDataContext()) { objuser = db.tblUsers.FirstOrDefault(S => S.deviceToken == objPush.registration_ids); if (objuser != null) { objuser.badge = iBadge; db.SubmitChanges(); } } return sResponseFromServer; } catch (Exception ex) { return null; } }
/// <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; } }
//internal int SaveTutorSubjects(TutorSubjects objReq) //{ // tblTutorSubject objSubjectData = new tblTutorSubject(); // using (var db = new WizzDataContext()) // { // objSubjectData = db.tblTutorSubjects.Where(x => x.fkTutorId == Convert.ToInt64(objReq.tutorId)).FirstOrDefault(); // if (objSubjectData == null) // { // //objSubjectData = new TutorSubjects(); // //objSubjectData.isApproved = true; // //objSubjectData.isActive = true; // //objSubjectData.fkUserId = Convert.ToInt64(objReq.userId); // //objSubjectData.latitude = Convert.ToDecimal(objReq.latitude); // //objSubjectData.longitude = Convert.ToDecimal(objReq.longitude); // //objSubjectData.subjects = objReq.majors; // //objSubjectData.TimeStamp = Convert.ToDateTime(objReq.timeStamp).Ticks; // //objSubjectData.updatedDate = DateTime.UtcNow; // //objSubjectData.createdDate = DateTime.UtcNow; // //objSubjectData.passingYear = objReq.passingYear; // //objSubjectData.referralcode = objReq.referalCode == null ? "" : objReq.referalCode; // //// profileData.fkClassId = String.Join(",", objReq.classes); // //objSubjectData.fkCollegeId = Convert.ToInt32(objReq.collegeId); // //db.tblTutorProfiles.InsertOnSubmit(objSubjectData); // } // else // { // //objSubjectData.isApproved = true; // //objSubjectData.isActive = true; // //objSubjectData.fkUserId = Convert.ToInt64(objReq.userId); // //objSubjectData.latitude = Convert.ToDecimal(objReq.latitude); // //objSubjectData.longitude = Convert.ToDecimal(objReq.longitude); // //objSubjectData.subjects = objReq.majors; // //objSubjectData.TimeStamp = Convert.ToDateTime(objReq.timeStamp).Ticks; // //objSubjectData.updatedDate = DateTime.UtcNow; // //objSubjectData.createdDate = DateTime.UtcNow; // //// profileData.fkClassId = String.Join(",", objReq.classes); // //objSubjectData.fkCollegeId = Convert.ToInt32(objReq.collegeId); // } // db.SubmitChanges(); // return 1; // } //} //save matched tutos in db and send notifications void SendRequest(StudentRequestModel objReq,List<usp_GetTutorsResult> tutors,string requestId) { var studentId =Convert.ToInt64(objReq.userId); using(var db=new WizzDataContext()) { foreach (var tutor in tutors.ToList()) { var request = new tblRequest(); request.createdDate = DateTime.UtcNow; request.updatedDate = DateTime.UtcNow; request.isAccepted = false; request.isDeleted = false; request.fkStudentId = studentId; request.fkTutorId = tutor.fkUserId; request.uniqueRequestId = requestId; request.timeStamp = DateTime.UtcNow.Ticks; db.tblRequests.InsertOnSubmit(request); db.SubmitChanges(); //sendpush if(!string.IsNullOrEmpty(tutor.deviceToken)) { PushData push=new PushData() { registration_ids = tutor.deviceToken, message = PushMessages.newRequest, type = Convert.ToInt16(PushType.newRequest).ToString(), badge = Convert.ToString(tutor.badge) }; // push.data = CommonMethod.ObjectToJson(objPush); if (tutor.deviceType == Convert.ToInt16(DeviceType.ios))//ios { SendPush objIOS=new SendPush(); objIOS.ConnectToAPNS(push); } else if (tutor.deviceType == Convert.ToInt16(DeviceType.android))//android { Android objAndroid = new Android(); objAndroid.send(push); } } } } }
internal string SendOtp(OtpModel objReq) { Random generator = new Random(); String r = generator.Next(10000, 1000000).ToString(); r = r.Substring(0, 5); using (var db = new WizzDataContext()) { if (db.tblUsers.Any(x => x.phoneNum.ToLower().Trim() == objReq.phoneNum.ToLower().Trim() && x.isOtpVerified == true && x.pkUserId != Convert.ToInt64(objReq.userId))) { return "4"; } var userObj = db.tblUsers.Where(x => x.pkUserId == Convert.ToInt64(objReq.userId)).FirstOrDefault(); userObj.phoneNum = objReq.phoneNum; userObj.isOtpVerified = false; userObj.otpCode = r; twiliorest objTwillio = new twiliorest(); string msg = "Welcome to Wizz Tutors your Otp validation code is " + r; db.SubmitChanges(); if (objTwillio.SendTeilioMessage(objReq.phoneNum, msg)) { } else { } return r; } }
internal bool SaveSubjectsForTutor(SubjectsListModel objReq) { using (var db = new WizzDataContext()) { int tutorId = Convert.ToInt32(objReq.userId); // List<tblTutorSubject> objSubject = new List<tblTutorSubject>(); var objSubjectDbList = db.usp_GetSubjectsForTutor(tutorId).ToList(); tblTutorSubject listObj = new tblTutorSubject(); if (objReq.subjectsIdList!=null&&objReq.subjectsIdList.Count != 0) { foreach (var n in objSubjectDbList) { var data = objReq.subjectsIdList.Where(x => x == Convert.ToString(n.subjectId)).FirstOrDefault(); //data is null and n.isadded false h means not in all list wont be added wont be deleted //data is null and n.isadded true h deleted from subject table // if not null then check is added if yes den leave //if not null and is added false insert //if not null and is added true then do nothing if (data == null && n.isApplied == "True") { var tutorSub = db.tblTutorSubjects.Where(x => x.fkSubjectId == n.subjectId&&x.fkTutorId==Convert.ToInt64(objReq.userId)).FirstOrDefault(); db.tblTutorSubjects.DeleteOnSubmit(tutorSub); db.SubmitChanges(); } else if (data != null) { if (n.isApplied == "False") { var tutorSub = new tblTutorSubject(); tutorSub.fkTutorId = Convert.ToInt64(objReq.userId); tutorSub.fkSubjectId = Convert.ToInt64(data); tutorSub.isApproved = false; db.tblTutorSubjects.InsertOnSubmit(tutorSub); db.SubmitChanges(); //insert with is approved false in tutorsubject } } } } return true; } }
internal SessionEndResponseModel EndSession(CreateSesion objReq) { SessionEndResponseModel resp = new SessionEndResponseModel(); using (var db = new WizzDataContext()) { var sessionData = db.tblSessions.Where(x => x.pkSessionId == Convert.ToInt64(objReq.sessionId)).FirstOrDefault(); if (sessionData == null) return resp; sessionData.sessionEndtime = objReq.endTime; sessionData.isComplete = true; sessionData.sessionDate = DateTime.UtcNow.ToString(); sessionData.updatedDate = DateTime.UtcNow; int friendCount = db.tblInviteFriends.Where(x => x.uniqueRequestId == objReq.uniqueRequestId && x.isDelete == false).ToList().Count; if (friendCount == 0) { } else friendCount = friendCount - 1; objReq.earnedAmt = CalculateSessionCost(sessionData.sessionStartTime, sessionData.sessionEndtime, friendCount, db, Convert.ToInt32(sessionData.tutorId)); sessionData.totalMinutes = globalMinutes; resp.scheduleCounts = Convert.ToString(db.tblSessions.Where(x => x.uniqueRequestId == objReq.uniqueRequestId).ToList().Count); if (friendCount == 0) resp.sessionCost = objReq.earnedAmt; else resp.sessionCost = Convert.ToString(Convert.ToDecimal(objReq.earnedAmt) * friendCount); sessionData.sessionAmount =totalSessionAmt==0?resp.sessionCost:totalSessionAmt.ToString(); resp.uniqueRequestId = sessionData.uniqueRequestId; resp.sessionId = sessionData.pkSessionId.ToString(); var studentData = db.tblStudentRequests.Where(x => x.uniqueStudentRequestId == objReq.uniqueRequestId).FirstOrDefault(); resp.latitude = Convert.ToString(studentData.lat); resp.longitude = Convert.ToString(studentData.longi); resp.location = Convert.ToString(studentData.location); db.SubmitChanges(); SendSessionEndPushes(objReq.earnedAmt, objReq.uniqueRequestId, db, Convert.ToInt64(sessionData.studentId), sessionData.pkSessionId, Convert.ToInt64(sessionData.tutorId)); } return resp; }
internal bool CancelSession(UniqueRequestModel objReq) { using (var db = new WizzDataContext()) { try { Int32 userId = Convert.ToInt32(objReq.userId); if (Convert.ToBoolean(objReq.isTutor)) { var sessionData = db.tblSessions.Where(x => x.pkSessionId == Convert.ToInt64(objReq.sessionId)).FirstOrDefault(); sessionData.isDelete = true; sessionData.isCancelled = true; } else { db.tblStudentRequests.Where(x => x.uniqueStudentRequestId == objReq.uniqueRequestId && x.fkUserId == userId).ToList().ForEach(x => x.isDelete = true); var friendData = db.tblInviteFriends.Where(x => x.uniqueRequestId == objReq.uniqueRequestId && x.isDelete == false).ToList(); if (friendData.Count == 0) { var sessionData = db.tblSessions.Where(x => x.pkSessionId == Convert.ToInt64(objReq.sessionId)).FirstOrDefault(); sessionData.isDelete = true; sessionData.isCancelled = true; } else { var userData = friendData.Where(x => x.fkFriendId == userId).FirstOrDefault(); userData.isDelete = true; } } db.SubmitChanges(); return true; } catch (Exception) { return false; } } }
internal bool CancelSession(CreateSesion objReq) { using (var db = new WizzDataContext()) { tblRequest sessionData; sessionData = db.tblRequests.Where(x => x.uniqueRequestId == objReq.sessionId).FirstOrDefault(); if (sessionData == null) return false; sessionData.isCancelled = true; sessionData.updatedDate = DateTime.UtcNow; db.SubmitChanges(); } return true; }
//internal List<RespNewRequest> GetSessions(Entity objRequest) //{ // List<RespNewRequest> response = new List<RespNewRequest>(); // using (var db = new WizzDataContext()) // { // response = (from i in db.usp_GetNewRequest(0, Convert.ToInt64(objRequest.userId), true) // select new RespNewRequest // { // accompanyNum = Convert.ToString(i.accompanyNum), // assignment = i.assignment, // calculatedAmount = Convert.ToString(i.calculatedAmount), // className = Convert.ToString(i.className), // forMinutes = Convert.ToString(i.forMinutes), // latitude = Convert.ToString(i.latitude), // longitude = Convert.ToString(i.longitude), // profilepic = string.IsNullOrWhiteSpace(i.tutorPic) ? "" : i.tutorPic.IndexOf("http") >= 0 ? i.tutorPic : Constants.imagepath + i.tutorPic, // requestId = Convert.ToString(i.requestId), // uniqueRequestId = Convert.ToString(i.uniqueRequestId), // name = i.tutorName, // id = Convert.ToString(i.fkTutorId), // // tutorId = Convert.ToString(i.fkTutorId), // // tutorName = i.tutorName, // isNow = i.isNow, // location = i.location, // listSlot = (from l in db.tblRequestStudents // where l.uniqueRequestId == i.uniqueRequestId // select new TimeSlot // { // dayNo = l.day == null ? "0" : l.day.ToString(), // slotId = l.pkRequirementId.ToString(), // fromTime = l.fromTime, // toTime = l.toTime, // isBooked = l.isBooked == true ? "True" : "False", // }).ToList(),// im i in objDBContext.usp_GetItemListForApp(0, 0, Convert.ToInt64(objReq.merchantId), 0, 0, 0, "", 0) // listTutorSlot = (from l in db.tblSlotManagements // where l.uniqueRequestId == i.uniqueRequestId // select new TimeSlot // { // dayNo = l.day == null ? "0" : l.day.ToString(), // slotId = l.pkId.ToString(), // fromTime = l.fromTime, // toTime = l.toTime, // }).ToList() // }).ToList(); // } // return response; //} //internal RespNewRequest GetSessionById(Entity objRequest) //{ // RespNewRequest response = new RespNewRequest(); // using (var db = new WizzDataContext()) // { // response = (from i in db.usp_GetSessionInfoById(objRequest.uniqueRequestId,Convert.ToInt64(objRequest.userId)) // select new RespNewRequest // { // className = Convert.ToString(i.className), // profilepic = string.IsNullOrWhiteSpace(i.profilePic) ? "" : i.profilePic.IndexOf("http") >= 0 ? i.profilePic : Constants.imagepath + i.profilePic, // name = i.userName, // isNow=i.isNow.ToString(), // calculatedAmount=Convert.ToString(i.calculatedAmount), // sessionStartTime=i.sessionStartTime, // sessionEndTime=i.sesssionEndTime, // requestId=objRequest.uniqueRequestId, // id = Convert.ToString(i.pkUserId), // listSlot = (from l in db.tblRequestStudents // where l.uniqueRequestId == objRequest.uniqueRequestId // select new TimeSlot // { // dayNo = l.day == null ? "0" : l.day.ToString(), // slotId = l.pkRequirementId.ToString(), // fromTime = l.fromTime, // toTime = l.toTime, // isBooked = l.isBooked == true ? "True" : "False", // }).ToList(),// im i in objDBContext.usp_GetItemListForApp(0, 0, Convert.ToInt64(objReq.merchantId), 0, 0, 0, "", 0) // listTutorSlot = (from l in db.tblSlotManagements // where l.uniqueRequestId == objRequest.uniqueRequestId // select new TimeSlot // { // dayNo = l.day == null ? "0" : l.day.ToString(), // slotId = l.pkId.ToString(), // fromTime = l.fromTime, // toTime = l.toTime, // }).ToList() // }).FirstOrDefault(); // } // return response; //} //internal HistoryModel GetSessionHistory(Entity objRequest) //{ //// public string paidAmount { get; set; } ////public string sessionDate { get; set; } ////public string tutorId { get; set; } ////public string tutorName { get; set; } ////public string tutorImage { get; set; } ////public string subject { get; set; } // HistoryModel response = new HistoryModel(); // //using (var db = new WizzDataContext()) // //{ // for (int i = 1; i < 5; i++) // { // HistoryModel sm = new HistoryModel(); // sm.availableAmount = "50" + i * 24; // sm.learnHours = "4" + i * i * 4; // sm.listTutor = new List<HistoryTutor>(); // HistoryTutor ts = new HistoryTutor(); // ts.paidAmount = "" + i * 100; // ts.tutorId = "7" + i; // ts.sessionDate = DateTime.UtcNow.AddHours(i).ToString("dd MMM yyyy"); // switch (i) // { // case 1: // ts.tutorName = "Bruce waine"; // ts.subject = "Chemistry"; // ts.tutorImage = "http://farm9.static.flickr.com/8386/8490887372_fb1622edac_m.jpg"; // break; // case 2: // ts.tutorName = "Berry allen"; // ts.subject = "Physics"; // ts.tutorImage = "http://farm4.static.flickr.com/3308/5759383374_1f948b988b_m.jpg"; // break; // case 3: // ts.tutorName = "Oliver Queen"; // ts.subject = "Physical"; // ts.tutorImage = "http://farm8.static.flickr.com/7258/13547010673_e62471bfc0_m.jpg"; // break; // case 4: // ts.tutorName = "Clark"; // ts.tutorImage = "http://farm9.static.flickr.com/8386/8490887372_fb1622edac_m.jpg"; // ts.subject = "Astrology"; // break; // } // response.listTutor.Add(ts); // } // // response = sp call // // } // return response; // //using (var db = new WizzDataContext()) // //{ // // // response = sp call // //} // //return response; //} //internal List<RespNewRequest> GetSessionsForTutor(Entity objRequest) //{ // List<RespNewRequest> response = new List<RespNewRequest>(); // using (var db = new WizzDataContext()) // { // response = (from i in db.usp_GetNewRequest(Convert.ToInt64(objRequest.userId), 0, true) // select new RespNewRequest // { // accompanyNum = Convert.ToString(i.accompanyNum), // assignment = i.assignment, // calculatedAmount = Convert.ToString(i.calculatedAmount), // className = Convert.ToString(i.className), // forMinutes = Convert.ToString(i.forMinutes), // latitude = Convert.ToString(i.latitude), // longitude = Convert.ToString(i.longitude), // profilepic = string.IsNullOrWhiteSpace(i.studentPic) ? "" : i.studentPic.IndexOf("http") >= 0 ? i.studentPic : Constants.imagepath + i.studentPic, // requestId = Convert.ToString(i.requestId), // uniqueRequestId = Convert.ToString(i.uniqueRequestId), // name = i.studenName, // id = Convert.ToString(i.fkStudentId), // // tutorId = Convert.ToString(i.fkTutorId), // // tutorName = i.tutorName, // isNow = i.isNow, // location = i.location, // listSlot = (from l in db.tblRequestStudents // where l.uniqueRequestId == i.uniqueRequestId // select new TimeSlot // { // dayNo = l.day == null ? "0" : l.day.ToString(), // slotId = l.pkRequirementId.ToString(), // fromTime = l.fromTime, // toTime = l.toTime, // isBooked = l.isBooked == true ? "True" : "False", // }).ToList(), // im i in objDBContext.usp_GetItemListForApp(0, 0, Convert.ToInt64(objReq.merchantId), 0, 0, 0, "", 0) // listTutorSlot = (from l in db.tblSlotManagements // where l.uniqueRequestId == i.uniqueRequestId // select new TimeSlot // { // dayNo = l.day == null ? "0" : l.day.ToString(), // slotId = l.pkId.ToString(), // fromTime = l.fromTime, // toTime = l.toTime, // }).ToList() // }).ToList(); // } // //if (response==null || response.Count==0) // //{ // //for (int i = 1; i < 5; i++) // //{ // // RespNewRequest sm = new RespNewRequest(); // // switch (i) // // { // // case 1: // // sm.assignment = "Trigo,Geometery,Calculus"; // // sm.className = "Math"; // // sm.forMinutes = "125"; // // sm.name = "McMohan"; // // sm.profilepic = "https://staging10.techaheadcorp.com/wizz/WebImages/95e6458ba8824e02885a26fcfc2d8e50.jpg"; // // sm.id = "10" + i; // // break; // // case 2: // // sm.assignment = "Thermodynamics,Gravity,Law of Motion"; // // sm.className = "12"; // // sm.forMinutes = "" + i * 2; // // sm.name = "Shrikant"; // // sm.profilepic = "https://staging10.techaheadcorp.com/wizz/WebImages/15a29c136a054446a2cd79884c878f16.jpg"; // // sm.id = "10" + i; // // break; // // case 3: // // sm.assignment = "Compiler design,Automata,Turing machine"; // // sm.className = "9"; // // sm.forMinutes = "" + i * 2; // // sm.name = "Yash"; // // sm.profilepic = "https://staging10.techaheadcorp.com/wizz/WebImages/1ba0ba5992ca43f086837f30e7720972.jpg"; // // sm.id = "10" + i; // // break; // // case 4: // // sm.assignment = "basics of c,Printers,History of computers"; // // sm.className = "16"; // // sm.forMinutes = "" + i * 2; // // sm.name = "Shweta"; // // sm.profilepic = "https://staging10.techaheadcorp.com/wizz/WebImages/1c84e4b5e8df49ea9940794310f23c45.jpg"; // // sm.id = "10" + i; // // break; // // } // // sm.accompanyNum = (i * i + 2).ToString(); // // sm.listSlot = new List<TimeSlot>(); // // TimeSlot ts = new TimeSlot(); // // ts.dayNo = "" + i; // // ts.fromTime = DateTime.UtcNow.AddHours(i).ToString("dd-MMM-yyyy"); // // ts.toTime = DateTime.UtcNow.AddHours(i + 2).ToString("dd-MMM-yyyy"); // // ts.slotId = "" + i * 32; // // response.Add(sm); // // // .Add(sm); // //} // // response = sp call // // } // return response; //} //internal TutorHistoryModel GetTutorSessionHistory(Entity objRequest) //{ // // public string paidAmount { get; set; } // //public string sessionDate { get; set; } // //public string tutorId { get; set; } // //public string tutorName { get; set; } // //public string tutorImage { get; set; } // //public string subject { get; set; } // TutorHistoryModel response = new TutorHistoryModel(); // response.availableAmount = "500" ; // response.learnHours = "4" ; // //using (var db = new WizzDataContext()) // //{ // for (int i = 1; i < 5; i++) // { // HistoryStudent ts = new HistoryStudent(); // ts.paidAmount = "" + i * 100; // ts.studentId = "7" + i; // ts.sessionDate = DateTime.UtcNow.AddHours(i).ToString("dd MMM yyyy"); // switch (i) // { // case 1: // ts.studentName = "Bruce waine"; // ts.subject = "Chemistry"; // ts.studentImage = "staging10.techaheadcorp.com/wizz/WebImages/0c02ecd2bcb44faca7f80bb6cf52cb18.jpg"; // break; // case 2: // ts.studentName = "Berry allen"; // ts.subject = "Physics"; // ts.studentImage = "staging10.techaheadcorp.com/wizz/WebImages/15a29c136a054446a2cd79884c878f16.jpg"; // break; // case 3: // ts.studentName = "Oliver Queen"; // ts.subject = "Physical"; // ts.studentImage = "staging10.techaheadcorp.com/wizz/WebImages/1c84e4b5e8df49ea9940794310f23c45.jpg"; // break; // case 4: // ts.studentName = "Clark"; // ts.studentImage = "staging10.techaheadcorp.com/wizz/WebImages/33fc9351b4e64434b64938d03e8935ec.jpg"; // ts.subject = "Astrology"; // break; // } // response.listStudent.Add(ts); // } // // response = sp call // // } // return response; // //using (var db = new WizzDataContext()) // //{ // // // response = sp call // //} // //return response; //} //internal bool BookTimeSlot(TimeSlotEntity objReq) //{ // using (var db = new WizzDataContext()) // { // var reqData = db.tblRequestStudents.Where(x => x.uniqueRequestId == objReq.uniqueRequestId).FirstOrDefault(); // // var sessionData=db.tblRequests.Where(x=>x.uniqueRequestId==objReq.uniqueRequestId).FirstOrDefault(); // if (reqData == null) // return false; // reqData.isBooked = true; // tblSlotManagement slotData; // List<tblSlotManagement> slotList = new List<tblSlotManagement>(); // slotList = db.tblSlotManagements.Where(x => x.uniqueRequestId == objReq.uniqueRequestId).ToList(); // if (slotList.Count > 0) // { // db.tblSlotManagements.DeleteAllOnSubmit(slotList); // db.SubmitChanges(); // } // slotList = new List<tblSlotManagement>(); // foreach (var n in objReq.listSlot) // { // slotData = new tblSlotManagement(); // slotData.day = Convert.ToInt16(n.dayNo); // slotData.fkStudentId = Convert.ToInt64(objReq.studentId); // slotData.fkTutorId = Convert.ToInt64(objReq.tutorId); // slotData.fromTime = n.fromTime; // slotData.toTime = n.toTime; // slotData.updatedDate = DateTime.UtcNow; // slotData.createdDate = DateTime.UtcNow; // slotData.uniqueRequestId = objReq.uniqueRequestId; // slotList.Add(slotData); // } // reqData.updatedDate = DateTime.UtcNow; // db.tblSlotManagements.InsertAllOnSubmit(slotList); // db.SubmitChanges(); // } // return true; //} //internal List<RespNewRequest> GetHistoryForUser(Entity objReq) //{ // List<RespNewRequest> objResp = new List<RespNewRequest>(); // long studentId = 0; // long tutorId = 0; // if (objReq.isTutor == "True") // { // tutorId = Convert.ToInt64(objReq.userId); // } // else // { // studentId = Convert.ToInt64(objReq.userId); // } // using (var db = new WizzDataContext()) // { // objResp = (from i in db.usp_GetUserHistory(tutorId, studentId) // select new RespNewRequest // { // accompanyNum = Convert.ToString(i.accompanyNum), // assignment = i.assignment, // calculatedAmount = Convert.ToString(objReq.isTutor == "True"?i.tutorEarnedAmt:i.calculatedAmount), // className = Convert.ToString(i.className), // forMinutes = Convert.ToString(i.forMinutes), // latitude = Convert.ToString(i.latitude), // longitude = Convert.ToString(i.longitude), // profilepic = studentId == 0 ? (string.IsNullOrWhiteSpace(i.studentPic) ? "" : i.studentPic.IndexOf("http") >= 0 ? i.studentPic : Constants.imagepath + i.studentPic) : (string.IsNullOrWhiteSpace(i.tutorPic) ? "" : i.tutorPic.IndexOf("http") >= 0 ? i.tutorPic : Constants.imagepath + i.tutorPic), // sessionDate = i.sessionenddate, // requestId = Convert.ToString(i.requestId), // uniqueRequestId = Convert.ToString(i.uniqueRequestId), // name = studentId == 0 ? i.studenName : i.tutorName, // id = studentId == 0 ? Convert.ToString(i.fkStudentId) : Convert.ToString(i.fkTutorId), // // tutorId = Convert.ToString(i.fkTutorId), // // tutorName = i.tutorName, // location = i.location, // listSlot = (from l in db.tblRequestStudents // where l.uniqueRequestId == i.uniqueRequestId // select new TimeSlot // { // dayNo = l.day == null ? "0" : l.day.ToString(), // slotId = l.pkRequirementId.ToString(), // fromTime = l.fromTime, // toTime = l.toTime // }).ToList() // im i in objDBContext.usp_GetItemListForApp(0, 0, Convert.ToInt64(objReq.merchantId), 0, 0, 0, "", 0) // }).ToList(); // return objResp; // } //} #endregion #region V2Code internal bool StartSession(CreateSesion objReq) { using (var db = new WizzDataContext()) { var sessionData = db.tblSessions.Where(x => x.pkSessionId == Convert.ToInt64(objReq.sessionId)).FirstOrDefault(); if (sessionData == null) return false; sessionData.sessionStartTime = objReq.startTime; sessionData.sessionDate = DateTime.UtcNow.Date.ToString("dd mm yyyy"); sessionData.isStarted = true; sessionData.isComplete = false; sessionData.isCancelled = false; sessionData.isDelete = false; sessionData.updatedDate = DateTime.UtcNow; //sending push to the student SendSessionStartPushes(db, Convert.ToInt64(sessionData.studentId), sessionData.uniqueRequestId, sessionData.pkSessionId); db.SubmitChanges(); } return true; }
internal bool CreateGroup(GroupModel objReq) { try { using (var db = new WizzDataContext()) { tblGroup groupObj = new tblGroup(); groupObj = db.tblGroups.FirstOrDefault(x => x.groupId == objReq.groupId); //if (groupData != null) //{ // db.tblGroups.DeleteOnSubmit(groupData); //} if (groupObj == null) { groupObj = new tblGroup(); groupObj.groupName = objReq.groupName; groupObj.fkAdminId = objReq.userId; groupObj.createdDate = DateTime.UtcNow; groupObj.updatedDate = DateTime.UtcNow; groupObj.isActive = true; groupObj.timeSlot = objReq.timeSlot; groupObj.subjectName = objReq.subjectName; groupObj.groupId = objReq.groupId; groupObj.groupPic = objReq.groupPic; db.tblGroups.InsertOnSubmit(groupObj); db.SubmitChanges(); } else { groupObj.groupName = objReq.groupName; groupObj.fkAdminId = objReq.userId; groupObj.createdDate = DateTime.UtcNow; groupObj.updatedDate = DateTime.UtcNow; groupObj.isActive = true; groupObj.timeSlot = objReq.timeSlot; groupObj.subjectName = objReq.subjectName; groupObj.groupId = objReq.groupId; groupObj.groupPic = objReq.groupPic; } List<string> groupMems = new List<string>(); List<tblGroupMember> memObjList = new List<tblGroupMember>(); int groupId = Convert.ToInt32(groupObj.pkId); foreach (string n in objReq.groupMembers) { tblGroupMember memObj = new tblGroupMember(); memObj.fkGroupId = groupId; memObj.fkUserId = Convert.ToInt32(n); memObj.createdDate = DateTime.UtcNow; memObj.updatedDate = DateTime.UtcNow; memObj.isDelete = false; memObjList.Add(memObj); } db.tblGroupMembers.InsertAllOnSubmit(memObjList); db.SubmitChanges(); return true; } } catch (Exception ex) { return false; } }