Exemple #1
0
        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;
        }
 public Response<string> SessionReviewByTutor(SessionReviewModel objReq)
 {
     Response<string> response = new Response<string>();
     List<string> objResp = new List<string>();
     try
     {
         Session obj = new Session();
         if (CheckRequestIsvalidornot(this.Request))
         {
             if (obj.SessionReviewByTutor(objReq))
                 response.Create(true, Messages.FormatMessage(Messages.Success, "You have submitted"), 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;
 }