Exemple #1
0
        /// <summary>
        ///
        /// </summary>
        public ActionResult StudentAssignmentView(int id)
        {
            #region Security
            string userID = null;
            if (!User.Identity.IsAuthenticated)
            {
                return(RedirectToAction("Login", "Account"));
            }

            if (!accountService.GetIdByUser(User.Identity.Name, ref userID))
            {
                return(RedirectToAction("Index", "Home"));
            }

            //if (!accountService.IsUserQualified("Teacher", userID, id) || !accountService.IsUserQualified("Student", userID, id))
            //  return RedirectToAction("Index", "User");


            if (id <= 0)
            {
                return(View());
            }
            #endregion
            AssignmentViewModel viewModel = assignmentService.GetAssignmentForView(id, false);
            //if(limitSubmisssions != null)
            //{
            //    List<int> milestonesID = (from m in db.Milestones where m.AssignmentID == id select m.ID).ToList();
            //    foreach (var item in milestonesID)
            //    {
            //        int numberOfSubmissions = (from m in db.Milestones where m.ID == milestoneID && m.userID == uerid select m).ToList().Count;
            //        if(numberOfSubmissions >= limit)
            //        {
            //            SelectListItem item = new SelectListItem { Value = milestonesID, Text = Milestone name}
            //            viewModel.milestoneNumber.Remove(item);
            //        }
            //    }
            return(View(viewModel));
        }