Exemple #1
0
        // GET: Suggestion
        public ActionResult StudentSuggestion()
        {
            if ((HttpContext.Session.GetString("Role") == null) ||
                (HttpContext.Session.GetString("Role") != "Student"))
            {
                return(RedirectToAction("Index", "Home"));
            }
            int studentid = Convert.ToInt32(HttpContext.Session.GetInt32("StudentID"));
            List <StudentSuggestionViewModel> studentsuggestionVMList = new List <StudentSuggestionViewModel>();
            List <Suggestion> suggestionList = suggestionContext.GetSuggestionPostedByStudentsMentor(Convert.ToInt32(HttpContext.Session.GetInt32("StudentID")));

            foreach (Suggestion suggestion in suggestionList)
            {
                StudentSuggestionViewModel suggestionVM = MapToLecturerVM(suggestion);
                studentsuggestionVMList.Add(suggestionVM);
            }
            return(View(studentsuggestionVMList));
        }
Exemple #2
0
 public StudentSuggestionViewModel MapToLecturerVM(Suggestion suggestion)
 {
     if (suggestion != null)
     {
         string          lecturerName = "";
         List <Lecturer> lecturerList = lecturerContext.GetAllLecturer();
         Student         student      = studentContext.GetStudentDetails(Convert.ToInt32(HttpContext.Session.GetInt32("StudentID")));
         foreach (Lecturer lecturer in lecturerList)
         {
             if (lecturer.LecturerId == suggestion.LecturerId && lecturer.LecturerId == student.MentorID && student.StudentID == suggestion.StudentId)
             {
                 lecturerName = lecturer.Name;
                 break;
             }
         }
         string suggestionStatus;
         if (suggestion.Status == 'N')
         {
             suggestionStatus = "Not Acknowledged";
         }
         else
         {
             suggestionStatus = "Acknowledged";
         }
         StudentSuggestionViewModel studentVM = new StudentSuggestionViewModel
         {
             SuggestionId = suggestion.SuggestionId,
             LecturerId   = suggestion.LecturerId,
             StudentId    = suggestion.StudentId,
             Description  = suggestion.Description,
             Status       = suggestionStatus,
             DateCreated  = suggestion.DateCreated,
             LecturerName = lecturerName
         };
         return(studentVM);
     }
     else
     {
         return(null);
     }
 }
Exemple #3
0
        // GET: Suggestion/Acknowledge/5
        public ActionResult Acknowledge(int?id)
        {
            if ((HttpContext.Session.GetString("Role") == null) ||
                (HttpContext.Session.GetString("Role") != "Student"))
            {
                return(RedirectToAction("Index", "Home"));
            }

            if (id == null)
            {
                TempData["ErrorMessage"] = "You are not allowed to acknowledge other student's suggestions!";
                return(RedirectToAction("Index"));
            }
            int        studentid  = Convert.ToInt32(HttpContext.Session.GetInt32("StudentID"));
            Suggestion suggestion = suggestionContext.GetSuggestionDetails(id.Value);
            StudentSuggestionViewModel suggestionVM = MapToLecturerVM(suggestion);

            if (suggestion == null || suggestion.StudentId != studentid)
            {
                TempData["ErrorMessage"] = "You are not allowed to acknowledge other student's suggestions!";
                return(RedirectToAction("StudentSuggestion"));
            }
            return(View(suggestionVM));
        }