Esempio n. 1
0
        public IActionResult MySubscriptions()
        {
            //Get current user ID
            var current_user_id = _userManager.GetUserId(User);

            //Query all subscriptions for this user
            var subscriptions = _context.UserCourse.Where(x => x.UserId == current_user_id).ToList();

            //Prepare list of the view model type
            var return_obj = new List <MySubscriptionsViewModel>();

            foreach (var s in subscriptions)
            {
                //Get the course name
                var course_name = _context.Course.Where(x => x.Id == s.CourseId).FirstOrDefault().Name;

                //Check Validity
                var license_validity = _context.LicenseKey.Where(x => x.Value == s.KeyUsed).FirstOrDefault().Active;

                var local_obj = new MySubscriptionsViewModel();

                local_obj.License_Key = s.KeyUsed;
                local_obj.Course_Name = course_name;
                local_obj.Valid       = license_validity;

                return_obj.Add(local_obj);
            }

            return(View(return_obj));
        }
Esempio n. 2
0
        public async Task <IActionResult> MySubscriptions()
        {
            var currentUserId = GetCurrentUserId();
            var subscriptions = await _subscriptionsRepository.GetSubscriptions(currentUserId).ToListAsync();

            var model = new MySubscriptionsViewModel(subscriptions);

            return(View(model));
        }