Exemplo n.º 1
0
 public ActionResult DetailLecture(string id)
 {
     if (id != null)
     {
         var upcomming = _dbContext.Courses
                         .Include(c => c.Lecture)
                         .Include(c => c.Category)
                         .Where(c => c.DateTime > DateTime.Now && c.IsCanceled == false && c.LectureId == id);
         var iduser       = User.Identity.GetUserId();
         var Getatendance = _dbContext.Attendances
                            .Where(p => p.AttendeeId == iduser)
                            .ToList();
         var GetFollowing = _dbContext.Followings
                            .Where(x => x.FolloweeId == iduser)
                            .Include(p => p.Follower)
                            .Include(p => p.Followee)
                            .ToList();
         var viewModel = new CoursesViewMode
         {
             UpcommingCourses = upcomming,
             ShowAction       = User.Identity.IsAuthenticated,
             GetAttendances   = Getatendance,
             GetFollowings    = GetFollowing
         };
         return(View(viewModel));
     }
     return(RedirectToAction("Home", "Course"));
 }
Exemplo n.º 2
0
        /// <summary>
        /// Send data to AngularJs
        /// </summary>
        /// <returns>
        /// Json
        /// </returns>
        public ActionResult values()
        {
            var upcomming = _dbContext.Courses
                            .Include(c => c.Lecture)
                            .Include(c => c.Category)
                            .Where(c => c.DateTime > DateTime.Now && c.IsCanceled == false).ToList();
            var iduser       = User.Identity.GetUserId();
            var Getatendance = _dbContext.Attendances
                               .Where(p => p.AttendeeId == iduser)
                               .ToList();
            var GetFollowing = _dbContext.Followings
                               .Where(x => x.FolloweeId == iduser)
                               .Include(p => p.Follower)
                               .Include(p => p.Followee)
                               .ToList();
            var viewModel = new CoursesViewMode
            {
                UpcommingCourses = upcomming,
                ShowAction       = User.Identity.IsAuthenticated,
                GetAttendances   = Getatendance,
                GetFollowings    = GetFollowing
            };
            var list = JsonConvert.SerializeObject(viewModel,
                                                   Formatting.None,
                                                   new JsonSerializerSettings()
            {
                ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Ignore
            });

            return(Content(list, "application/json"));
        }
Exemplo n.º 3
0
        public ActionResult Attending()
        {
            var userId = User.Identity.GetUserId();
            var iduser = User.Identity.GetUserId();
            var course = _dbContext.Attendances
                         .Where(a => a.AttendeeId == userId)
                         .Select(a => a.Course)
                         .Include(l => l.Lecture)
                         .Include(l => l.Category)
                         .ToList();
            var Getatendance = _dbContext.Attendances
                               .Where(p => p.AttendeeId == iduser)
                               .ToList();
            var viewModel = new CoursesViewMode
            {
                UpcommingCourses = course,
                ShowAction       = User.Identity.IsAuthenticated,
                GetAttendances   = Getatendance
            };

            return(View(viewModel));
        }