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


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


            }
        }