コード例 #1
0
 public ActionResult EditLecturerProfile(UserInformation user, LecturerEditProfileModel model)
 {
     if (user != null)
     {
         if (user.IsStudent)
         {
             return View("Error");
         }
         else
         {
             try
             {
                 Lecturer lecturer = _repository.Lecturers.Where(x => x.ID == user.UserId).First();
                 lecturer.Information = model.Interests;
                 lecturer.Interests = model.Interests;
                 lecturer.Name = model.Name;
                 lecturer.Surname = model.Surname;
                 lecturer.IsAcademic = model.IsAcademic;
                 _repository.SaveLecturer(lecturer);
                 return View("ChangesSaved");
             }
             catch
             {
                 return View("Error");
             }
         }
     }
     else
     {
         return View("UnauthorizedAccess");
     }
 }
コード例 #2
0
        public ActionResult EditTopic(UserInformation user, Guid topicId)
        {
            if (user != null)
            {
                if (user.IsStudent)
                {
                    return View("Students limitations");
                }
                else
                {
                    try
                    {
                        if (!CheckIfLecturerHasAccessToTheTopic(user, topicId))
                            return View("AccessDenied");
                        else
                        {
                            TopicForEditing t = new TopicForEditing();
                            t.ID = topicId;
                            t.CourseId = _repository.CourseTopics.Where(x => x.ID == topicId).First().CourseId;
                            ViewBag.CourseName = _repository.Courses.Where(x => x.ID == t.CourseId).First<Course>().Name;
                            ViewBag.TopicName = _repository.CourseTopics.Where(x => x.ID == topicId).First().Name;
                            t.Lectures = _repository.Lectures.Where(x => x.TopicId == topicId).ToList<Lecture>().OrderBy(x => x.OrderNumber).ToList<Lecture>();
                            t.Tests = _repository.Tests.Where(x => x.TopicId == topicId).ToList<Test>();
                            return View(t);
                        }
                    }
                    catch (Exception e)
                    {
                        return View("Error");
                    }

                }
            }
            else return View("UnauthorizedAccess");
        }
コード例 #3
0
        public ActionResult CreateLecture(UserInformation user, Guid topicId)
        {
            if (user != null)
            {
                if (user.IsStudent)
                {
                    return View("Students limitations");
                }
                else
                {
                    try
                    {
                        if (!CheckIfLecturerHasAccessToTheTopic(user, topicId))
                            return View("AccessDenied");
                        else
                        {
                            return View("EditLecture", new LectureForEditing() { TopicId = topicId, OrderNumber = (_repository.Lectures.Where(x => x.TopicId == topicId).Count() + 1) });
                        }
                    }
                    catch (Exception e)
                    {
                        return View("Error");
                    }

                }
            }
            else return View("UnauthorizedAccess");
        }
コード例 #4
0
 public object BindModel(ControllerContext controllerContext, ModelBindingContext bindingContext)
 {
     UserInformation info = new UserInformation();
     info.UserName = controllerContext.HttpContext.Session[userNameSessionKey] as string;
     info.UserId = controllerContext.HttpContext.Session[userIdSessionKey] as Guid?;
     info.IsStudent = (controllerContext.HttpContext.Session[userIsStudentKey] as bool?) ?? false;
     if (info.UserId == null || info.UserName == null)
         return null;
     return info;
 }
コード例 #5
0
        public ActionResult EditProfile(UserInformation user)
        {
            if (user != null)
            {
                if (user.IsStudent)
                {
                    try
                    {
                        StudentEditProfileModel model = (from x in _repository.Students
                                                         where x.ID == user.UserId
                                                         select new StudentEditProfileModel
                                                         {
                                                             Id = x.ID,
                                                             Information = x.Information,
                                                             Interests = x.Interests,
                                                             Name = x.Name,
                                                             Surname = x.Surname
                                                         }).First();
                        return View("EditStudentProfile", model);

                    }
                    catch
                    {
                        return View("Error");
                    }
                }
                else
                {
                    try
                    {
                        LecturerEditProfileModel model = (from x in _repository.Lecturers
                                                          where x.ID == user.UserId
                                                          select new LecturerEditProfileModel
                                                          {
                                                              Id = x.ID,
                                                              Information = x.Information,
                                                              Interests = x.Interests,
                                                              Name = x.Name,
                                                              Surname = x.Surname,
                                                              IsAcademic = x.IsAcademic
                                                          }).First();
                        return View("EditLecturerProfile", model);

                    }
                    catch
                    {
                        return View("Error");
                    }
                }
            }
            else
            {
                return View("UnauthorizedAccess");
            }
        }
コード例 #6
0
 public ActionResult Index(UserInformation user)
 {
     if (user != null)
     {
         if (user.IsStudent)
         {
             List<StudentCourseRequestModel> requests = (from x in _repository.CourseRequests
                                                         where x.StudentId == user.UserId
                                                         select new StudentCourseRequestModel()
                                                         {
                                                             CourseId = x.CourseId,
                                                             Id = x.ID,
                                                             Date = x.Date,
                                                             CourseName = _repository.Courses.Where(c => c.ID == x.CourseId).Select(s => s.Name).FirstOrDefault(),
                                                             WasApproved = !x.IsDeclined,
                                                         }).OrderByDescending(x => x.Date).ToList<StudentCourseRequestModel>();
             return View("StudentCourseRequests", requests);
         }
         else
         {
             List<Guid> courseIds = _repository.Courses.Where(x => x.LecturerId == user.UserId).Select(m => m.ID).ToList<Guid>();
             List<LecturerCourseRequestModel> requests = (from x in _repository.CourseRequests
                                                          where courseIds.Contains(x.CourseId) &&
                                                                  x.IsDeclined == true
                                                          select new LecturerCourseRequestModel()
                                                          {
                                                              CourseId = x.CourseId,
                                                              Id = x.ID,
                                                              StudentId = x.StudentId,
                                                              Message = x.Message,
                                                              Date = x.Date,
                                                              CourseName = _repository.Courses.Where(c => c.ID == x.CourseId).Select(s => s.Name).FirstOrDefault(),
                                                              StudentName = _repository.Students.Where(s => s.ID == x.StudentId).Select(n => n.Name + " " + n.Surname).FirstOrDefault()
                                                          }).OrderByDescending(d => d.Date).ToList<LecturerCourseRequestModel>();
             return View("LecturerCourseRequests", requests);
         }
     }
     else
     {
         return View("UnauthorizedAccess");
     }
 }
コード例 #7
0
 public JsonResult DeleteRequest(UserInformation user, Guid id)
 {
     if (user != null)
     {
         Guid courseId = _repository.CourseRequests.Where(x => x.ID == id).Select(m => m.CourseId).FirstOrDefault();
         if (courseId != Guid.Empty && CheckIfLecturerCanAccessTheCourse(user.UserId.Value, courseId))
         {
             _repository.DeleteCourseRequest(id);
             return Json(true);
         }
         else
         {
             return Json(false);
         }
     }
     else
     {
         return Json(false);
     }
 }
コード例 #8
0
 public JsonResult ApproveRequest(UserInformation user, Guid courseId, Guid studentId)
 {
     if (user != null)
     {
         if (CheckIfLecturerCanAccessTheCourse(user.UserId.Value, courseId))
         {
             CourseRequest request = _repository.CourseRequests.Where(x => x.StudentId == studentId && x.CourseId == courseId).First();
             request.IsDeclined = false;
             _repository.SaveCourseRequest(request);
             _repository.SaveStudentCourse(new StudentCourse() { StudentId = studentId, CourseId = courseId, StartDate = DateTime.Now });
             return Json(true);
         }
         else
         {
             return Json(false);
         }
     }
     else
     {
         return Json(false);
     }
 }
コード例 #9
0
        public ActionResult DeleteTopic(UserInformation user, Guid topicId)
        {
            if (user != null)
            {
                if (user.IsStudent)
                {
                    return View("Students limitations");
                }
                else
                {
                    try
                    {
                        if (!CheckIfLecturerHasAccessToTheTopic(user, topicId))
                            return View("AccessDenied");
                        else
                        {
                            //Change order
                            CourseTopic topic = _repository.CourseTopics.Where(x => x.ID == topicId).First();
                            List<CourseTopic> topics = _repository.CourseTopics.Where(x => x.CourseId == topic.CourseId && x.OrderNumber > topic.OrderNumber).ToList();
                            topics.ForEach(x => x.OrderNumber--);
                            //delete and save
                            _repository.DeleteTopic(topicId);
                            foreach (var item in topics)
                            {
                                _repository.SaveTopic(item);
                            }
                            return RedirectToAction("EditCourse","Course", new { ID = topic.CourseId });
                        }
                    }
                    catch (Exception e)
                    {
                        return View("Error");
                    }

                }
            }
            else return View("UnauthorizedAccess");
        }
コード例 #10
0
        public ActionResult DeleteLecture(UserInformation user, Guid lectureId)
        {
            if (user != null)
            {
                if (user.IsStudent)
                {
                    return View("Students limitations");
                }
                else
                {
                    try
                    {
                        if (!CheckIfLecturerHasAccess(user, lectureId))
                            return View("AccessDenied");
                        else
                        {
                            //Change order
                            Lecture lecture = _repository.Lectures.Where(x => x.ID == lectureId).First();
                            List<Lecture> lectures = _repository.Lectures.Where(x => x.TopicId == lecture.TopicId && x.OrderNumber > lecture.OrderNumber).ToList();
                            lectures.ForEach(x => x.OrderNumber--);
                            //delete and save
                            _repository.DeleteLecture(lectureId);
                            foreach (var item in lectures)
                            {
                                _repository.SaveLecture(item);
                            }
                            return RedirectToAction("EditTopic", "Topic", new { topicId = lecture.TopicId });
                        }
                    }
                    catch (Exception e)
                    {
                        return View("Error");
                    }

                }
            }
            else return View("UnauthorizedAccess");
        }
コード例 #11
0
 public ActionResult CourseDetails(UserInformation user, Guid courseId)
 {
     Course course = _repository.Courses.Where(x => x.ID == courseId).First();
     CourseDetailsModel model = new CourseDetailsModel()
     {
         CourseId = courseId,
         CourseName = course.Name,
         Details = new Dictionary<string, List<string>>(),
         ComplexityLevel = course.ComplexityLevel,
         CreationDate = course.CreationDate,
         Description = course.Description,
         RequiredSkills = course.RequiredSkills
     };
     foreach (var topic in _repository.CourseTopics.Where(x => x.CourseId == courseId).OrderBy(x => x.OrderNumber).ToList())
     {
         KeyValuePair<string, List<string>> item = new KeyValuePair<string, List<string>>(topic.Name, new List<string>());
         foreach (var lecture in _repository.Lectures.Where(x => x.TopicId == topic.ID).OrderBy(x => x.OrderNumber))
         {
             item.Value.Add(lecture.Name);
         }
         model.Details.Add(item.Key, item.Value);
     }
     if (user != null)
     {
         if (user.IsStudent == true)
         {
             ViewBag.CanSubscribe = _repository.CourseRequests.Where(x => x.CourseId == courseId && x.StudentId == user.UserId).Count() == 0;
             ViewBag.HasAlreadySentRequest = !ViewBag.CanSubscribe;
         }
         else
             ViewBag.CanSubscribe = false;
     }
     else
     {
         ViewBag.CanSubscribe = false;
     }
     return View(model);
 }
コード例 #12
0
 private bool CheckIfLecturerCanAccessTheCourse(UserInformation user, Guid courseId)
 {
     return user.UserId == _repository.Courses.Where(x => x.ID == courseId).First().LecturerId;
 }
コード例 #13
0
        public ActionResult SubscribeCourse(UserInformation user, Guid courseId, string message)
        {
            if (user != null)
            {
                if (!user.IsStudent)
                {
                    return View("Students limitations");
                }
                else
                {
                    try
                    {
                        bool isCoursePublic = _repository.CourseTypes.Where(x => x.ID == _repository.Courses.Where(y => y.ID == courseId).FirstOrDefault().CourseTypeId).Select(k => k.TypeName).First() == "public";

                        if (isCoursePublic)
                        {
                            _repository.SaveCourseRequest(new CourseRequest()
                            {
                                IsDeclined = false,
                                StudentId = user.UserId.Value,
                                CourseId = courseId,
                                Message = message,
                                Date = DateTime.Now
                            });
                            _repository.SaveStudentCourse(new StudentCourse()
                            {
                                CourseId = courseId,
                                StudentId = user.UserId.Value
                            });
                        }
                        else
                        {
                            _repository.SaveCourseRequest(new CourseRequest()
                            {
                                CourseId = courseId,
                                Date = DateTime.Now,
                                IsDeclined = true,
                                Message = message,
                                StudentId = user.UserId.Value
                            });
                        }
                        return Json(true);
                    }
                    catch
                    {
                        return View("Error");
                    }
                }
            }
            return View("UnauthorizedAccess");
        }
コード例 #14
0
        public ActionResult SubscribedCourseDetails(UserInformation user, Guid courseId)
        {
            if (user == null)
                return View("UnauthorizedAccess");
            else
            {
                if (!user.IsStudent)
                    return View("LecturerLimitations");
                else
                {
                    try
                    {
                        //todo: add checking if user don't have access to that course

                        SubscribedCourseDetailsModel model = new SubscribedCourseDetailsModel()
                        {
                            CourseId = courseId,
                            CourseName = _repository.Courses.Where(x => x.ID == courseId).First().Name,
                            Details = new Dictionary<string, List<SubscribedCourseLectureModel>>()
                        };
                        var watchedLectures = _repository.WatchedLectures.Where(x => x.CourseId == courseId && x.StudentId == user.UserId).Select(m => m.LectureId).ToList();
                        foreach (var topic in _repository.CourseTopics.Where(x => x.CourseId == courseId).OrderBy(x => x.OrderNumber).ToList())
                        {
                            KeyValuePair<string, List<SubscribedCourseLectureModel>> item = new KeyValuePair<string, List<SubscribedCourseLectureModel>>(topic.Name, new List<SubscribedCourseLectureModel>());
                            foreach (var lecture in _repository.Lectures.Where(x => x.TopicId == topic.ID).OrderBy(x => x.OrderNumber))
                            {
                                item.Value.Add(new SubscribedCourseLectureModel() { LectureName = lecture.Name, IsLectureWatched = watchedLectures.Contains(lecture.ID), LectureId = lecture.ID });
                            }
                            model.Details.Add(item.Key, item.Value);
                        }
                        return View("SubscribedCourse", model);
                    }
                    catch (Exception e)
                    {
                        return View("Error");
                    }
                }
            }
        }
コード例 #15
0
        public MvcHtmlString ShowLectureContent(UserInformation user, Guid lectureId)
        {
            if (user != null)
            {

                if (isCoursePublic(lectureId))
                {
                    if (lectureId == Guid.Empty)
                        return MvcHtmlString.Create("<h3>There is no more lectures to show</h3>");
                    else
                        return GetLectureContent(user, lectureId);
                }
                else
                {
                    if (CheckIfStudentIsSubscribedForCourse(user.UserId.Value, lectureId))
                    {
                        if (lectureId == Guid.Empty)
                            return MvcHtmlString.Create("<h3>There is no more lectures to show</h3>");
                        else
                            return GetLectureContent(user, lectureId);
                    }
                    else
                    {
                        return MvcHtmlString.Create("<h3>You should be subscribed for this course to see the lecture content.</h3>");
                    }
                }
            }
            else
            {
                return MvcHtmlString.Create("<h3>You should be authorized to see the lecture content.</h3>");
            }
        }
コード例 #16
0
        public ActionResult Index(UserInformation user)
        {
            if (user == null) return View("UnauthorizedAccess");
            else if (user.IsStudent)
            {
                //Get courses for this studentId
                //Give them to the view(StudentCourses)
                IQueryable<CourseSummaryModel> mycourses = from x in _repository.Courses
                                                           where (from k in _repository.StudentCourses where k.StudentId == user.UserId select k.CourseId).Contains(x.ID)
                                                           select new CourseSummaryModel()
                                                           {
                                                               CourseId = x.ID,
                                                               CourseName = x.Name,
                                                               LecturerName = (from l in _repository.Lecturers where l.ID == x.LecturerId select l.Name + " " + l.Surname).FirstOrDefault(),
                                                               Description = x.Description,
                                                           };

                return View("StudentCourses", mycourses);
            }
            else
            {
                //Get courses for this lecturerId
                //Give them to the view(LecturerView)
                IQueryable<Course> courses = _repository.Courses.Where(x => x.LecturerId == user.UserId);
                return View("LecturerCourses", courses);
            }
        }
コード例 #17
0
        public ActionResult DeleteCourse(UserInformation user, Guid courseId)
        {
            if (user != null)
            {
                if (user.IsStudent)
                {
                    return View("Students limitations");
                }
                else
                {
                    try
                    {
                        if (!CheckIfLecturerCanAccessTheCourse(user, courseId))
                            return View("AccessDenied");
                        else
                        {
                            _repository.DeleteCourse(courseId);
                            return RedirectToAction("Index");
                        }
                    }
                    catch (Exception e)
                    {
                        return View("Error");
                    }

                }
            }
            else return View("UnauthorizedAccess");
        }
コード例 #18
0
 public ActionResult EditTopic(UserInformation user, TopicForEditing topic)
 {
     SaveReorderedLectures(topic.Lectures);
     return RedirectToAction("EditTopic", new { topicId = topic.ID });
 }
コード例 #19
0
 public ActionResult CreateCourse(UserInformation user)
 {
     if (user == null) return View("UnauthorizedAccess");
     else if (user.IsStudent) return View("StudentCourseCreation");
     else
     {
         SelectList categories = new SelectList(_repository.CourseCategories, "ID", "Name");
         SelectList courseTypes = new SelectList(_repository.CourseTypes, "ID", "TypeName");
         ViewBag.Categories = categories;
         ViewBag.CourseTypes = courseTypes;
         Lecturer creator = _repository.Lecturers.Where<Lecturer>(x => x.ID == user.UserId).FirstOrDefault<Lecturer>();
         return View("CreateCourse", new Course() { LecturerId = user.UserId.GetValueOrDefault() });
     }
 }
コード例 #20
0
        public ActionResult CreateCourse(UserInformation user, Course course)
        {
            if (user != null)
            {
                if (user.IsStudent)
                {
                    return View("Students limitations");
                }
                else
                {
                    try
                    {
                        if (ModelState.IsValid)
                        {
                            _repository.SaveCourse(course);
                            return View("CreationSucceed");
                        }
                        else
                        {
                            SelectList categories = new SelectList(_repository.CourseCategories, "ID", "Name");
                            SelectList courseTypes = new SelectList(_repository.CourseTypes, "ID", "TypeName");
                            ViewBag.Categories = categories;
                            ViewBag.CourseTypes = courseTypes;
                            return View("CreateCourse", course);
                        }
                    }
                    catch (Exception e)
                    {
                        return View("Error");
                    }

                }
            }
            else return View("UnauthorizedAccess");
        }
コード例 #21
0
 public PartialViewResult Login(UserInformation info)
 {
     if (info == null)
         return PartialView(new AccountModel());
     else if (info.IsStudent)
     {
         return PartialView("StudentProfile", new AccountModel() { UserName = info.UserName });
     }
     else
     {
         return PartialView("LecturerProfile", new AccountModel() { UserName = info.UserName });
     }
 }
コード例 #22
0
        public ActionResult SaveLecture(UserInformation user, LectureForEditing lecture)
        {
            if (user != null)
            {
                if (user.IsStudent)
                {
                    return View("Students limitations");
                }
                else
                {
                    try
                    {
                        if (!ModelState.IsValid) return View("EditLecture", lecture);
                        else
                        {
                            Lecture lect = new Lecture()
                            {
                                ID = lecture.ID,
                                Name = lecture.Name,
                                TopicId = lecture.TopicId,
                                OrderNumber = lecture.OrderNumber,
                                Homework = lecture.Homework,
                                LectureContent = lecture.LectureContent
                            };
                            _repository.SaveLecture(lect);

                            return RedirectToAction("EditTopic", "Topic", new { topicId = lecture.TopicId });
                        }
                    }
                    catch (Exception e)
                    {
                        return View("Error");
                    }

                }
            }
            else return View("UnauthorizedAccess");
        }
コード例 #23
0
 private bool CheckIfLecturerHasAccessToTheTopic(UserInformation user, Guid topicId)
 {
     return user.UserId == _repository.Courses.Where(x => x.ID == _repository.CourseTopics.Where(y => y.ID == topicId).FirstOrDefault().CourseId).First().LecturerId;
 }
コード例 #24
0
 public MvcHtmlString GetLectureContent(UserInformation user, Guid lectureId)
 {
     var lect = _repository.Lectures.Where(x => x.ID == lectureId);
     if (lect.Count() > 0)
     {
         StringBuilder sb = new StringBuilder();
         sb.Append(lect.First().LectureContent);
         if (lect.First().Homework != null && lect.First().Homework.Length > 0)
         {
             sb.Append("<hr/>");
             sb.Append("<h3>Homework</h3>");
             sb.Append(lect.First().Homework);
         }
         return MvcHtmlString.Create(sb.ToString());
     }
     else
     {
         return MvcHtmlString.Create("<h3>There is no more lectures to show.</h3>");
     }
 }
コード例 #25
0
        public ActionResult EditCourse(UserInformation user, Guid ID)
        {
            if (user != null)
            {
                if (user.IsStudent)
                {
                    return View("Students limitations");
                }
                else
                {
                    try
                    {
                        if (!CheckIfLecturerCanAccessTheCourse(user, ID))
                            return View("AccessDenied");
                        else
                        {
                            CourseDetails details = new CourseDetails();
                            var course = _repository.Courses.Where(x => x.ID == ID).ToList();
                            if (course.Count() != 0)
                            {
                                details.CourseId = course.First().ID;
                                details.CourseName = course.First().Name;
                                details.Topics = (from x in _repository.CourseTopics where x.CourseId == details.CourseId select new Topic { TopicName = x.Name, ID = x.ID, CourseId = x.CourseId, OrderNumber = x.OrderNumber }).OrderBy(x => x.OrderNumber).ToList<Topic>();
                                for (int i = 0; i < details.Topics.Count; i++)
                                {
                                    Guid topicId = details.Topics[i].ID;
                                    details.Topics[i].LecturesCount = _repository.Lectures.Where(x => x.TopicId == topicId).Count();
                                    details.Topics[i].TestsCount = _repository.Tests.Where(x => x.TopicId == topicId).Count();
                                }
                                //details.Topics = _repository.CourseTopics.Where(x => x.CourseId == details.CourseId);
                            }

                            return View(details);
                        }
                    }
                    catch (Exception e)
                    {
                        return View("Error");
                    }

                }
            }
            else return View("UnauthorizedAccess");
        }
コード例 #26
0
        public ActionResult EditLecture(UserInformation user, Guid lectureId)
        {
            if (user != null)
            {
                if (user.IsStudent)
                {
                    return View("Students limitations");
                }
                else
                {
                    try
                    {
                        if (!CheckIfLecturerHasAccess(user, lectureId))
                            return View("AccessDenied");
                        else
                        {
                            //Check if user can edit this lecture
                            Lecture l = _repository.Lectures.Where(x => x.ID == lectureId).First();
                            LectureForEditing lect = new LectureForEditing()
                            {
                                ID = lectureId,
                                Homework = l.Homework,
                                LectureContent = l.LectureContent,
                                OrderNumber = l.OrderNumber,
                                TopicId = l.TopicId,
                                Name = l.Name
                            };
                            return View(lect);
                        }
                    }
                    catch (Exception e)
                    {
                        return View("Error");
                    }

                }
            }
            else return View("UnauthorizedAccess");
        }
コード例 #27
0
        public ActionResult EditCourse(UserInformation user, CourseDetails details)
        {
            if (user != null)
            {
                if (user.IsStudent)
                {
                    return View("Students limitations");
                }
                else
                {
                    try
                    {
                        foreach (var item in details.Topics)
                        {
                            _repository.SaveTopic(new CourseTopic() { ID = item.ID, CourseId = item.CourseId, Name = item.TopicName, OrderNumber = item.OrderNumber });
                        }
                        return RedirectToAction("EditCourse", new { ID = details.CourseId });
                    }
                    catch (Exception e)
                    {
                        return View("Error");
                    }

                }
            }
            else return View("UnauthorizedAccess");
        }
コード例 #28
0
 public ActionResult EditStudentProfile(UserInformation user, StudentEditProfileModel model)
 {
     if (user != null)
     {
         if (!user.IsStudent)
         {
             return View("Error");
         }
         else
         {
             try
             {
                 Student student = _repository.Students.Where(x => x.ID == user.UserId).First();
                 student.Information = model.Information;
                 student.Interests = model.Interests;
                 student.Name = model.Name;
                 student.Surname = model.Surname;
                 _repository.SaveStudent(student);
                 return View("ChangesSaved");
             }
             catch
             {
                 return View("Error");
             }
         }
     }
     else
     {
         return View("UnauthorizedAccess");
     }
 }
コード例 #29
0
 public void SaveLectureRead(UserInformation user, Guid lectureId)
 {
     if (user != null)
     {
         if (_repository.WatchedLectures.Where(x => x.StudentId == user.UserId && x.LectureId == lectureId).Count() == 0)
         {
             _repository.SaveWatchedLecture(new WatchedLecture()
             {
                 CourseId = GetCourseIdByLectureId(lectureId),
                 LectureId = lectureId,
                 StudentId = user.UserId.Value
             });
         }
     }
 }