Ejemplo n.º 1
0
 public ActionResult AddClassReview(int classId)
 {
     var review = _reviewClassService.GetAll().SingleOrDefault(x => x.ClassId == classId && x.StudentId == SessionDataHelper.UserId);
     //return (review != null) ? View(review) : View(new ReviewTeacher { StudentId = SessionDataHelper.UserId, TeacherId = teacherId, Date = DateTime.Today });
     if (review != null) {
         return View(review);
     } else {
         var newReview = new ReviewClass {
             StudentId = SessionDataHelper.UserId,
             ClassId = classId,
             Date = DateTime.Today
         };
         return View(newReview);
     }
 }
Ejemplo n.º 2
0
 public ActionResult AddClassReview(ReviewClass review)
 {
     _reviewClassService.Insert(review);
     return RedirectToAction("DisplayClasses", "Account");
 }
Ejemplo n.º 3
0
        public ActionResult AddUpdateClassesToReview(ReviewClassViewModel review)
        {
            try
            {
                var ReviewClass = _reviewClassService.GetTableQuery().Where(e => e.StudentId == review.StudentID).ToList();
                var classdesc = _classService.GetById(review.ClassID);
                var record = new ReviewClassViewModel();
                if(ReviewClass.Count()>0)
                {
                    var update = new ReviewClass
                    {
                        Id=ReviewClass.SingleOrDefault().Id,
                        ClassId = review.ClassID,
                        Comment = review.Comment,
                        Date = DateTime.Today,
                        StudentId = review.StudentID,
                        Rating = review.Rating,
                    };
                    _reviewClassService.Update(update);

                    record = new ReviewClassViewModel
                    {
                        ClassID = review.ClassID,
                        Comment = review.Comment,
                        Date = DateTime.Today,
                        StudentID = review.StudentID,
                        Rating = review.Rating,
                        Description = classdesc.Description,
                    };
                }
                else
                {
                    var insert = new ReviewClass();
                    insert.ClassId = review.ClassID;
                    insert.Comment = classdesc.Description;
                    insert.Date = DateTime.Today;
                    insert.StudentId = review.StudentID;
                    insert.Rating = review.Rating;
                    _reviewClassService.Insert(insert);

                    record = new ReviewClassViewModel
                    {
                        ClassID = review.ClassID,
                        Comment = review.Comment,
                        Date = DateTime.Today,
                        StudentID = review.StudentID,
                        Rating = review.Rating,
                        Description = classdesc.Description,
                    };
                }

                return Json(new { Result = "OK", Record = record });
            }
            catch(Exception e)
            {
                throw new Exception(e.Message);
            }
        }