internal string AcceptTutor(CreateSesion objRequest) { string response = ""; //using (var db = new WizzDataContext()) //{ // // response = sp call //} return response; }
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 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 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; }
public Response<SessionEndResponseModel> EndSession(CreateSesion objReq) { Response<SessionEndResponseModel> response = new Response<SessionEndResponseModel>(); List<SessionEndResponseModel> objResp = new List<SessionEndResponseModel>(); try { Session obj = new Session(); if (CheckRequestIsvalidornot(this.Request)) { if (ModelState.IsValid) { objResp.Add(obj.EndSession(objReq)); if (objResp.Count > 0) response.Create(true, Messages.FormatMessage(Messages.Success, "You have ended session"), Messages.AppVersion, objResp); else response.Create(false, Messages.FormatMessage(Messages.InvalidReq), 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; }
public Response<string> StartSession(CreateSesion objReq) { Response<string> response = new Response<string>(); List<string> objResp = new List<string>(); try { Session obj = new Session(); if (CheckRequestIsvalidornot(this.Request)) { if (obj.StartSession(objReq)) response.Create(true, Messages.FormatMessage(Messages.Success, "Your session has been started"), 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; }