Пример #1
0
        // GET: MOOCLists/Create
        public async Task <IActionResult> Create(Guid?id)
        {
            var user = await _userManager.GetUserAsync(User);

            if (user == null)
            {
                throw new ApplicationException($"Unable to load user with ID '{_userManager.GetUserId(User)}'.");
            }
            MOOCListViewModel MOOCListVM = new MOOCListViewModel()
            {
                // CountryId = user.CountryId
            };

            ViewData["CountryId"]         = new SelectList(_context.Countries, "Id", "ArCountryName");
            ViewData["ApplicationUserId"] = new SelectList(_context.ApplicationUsers, "Id", "Id");
            ViewData["MOOCProviderId"]    = new SelectList(_context.MOOCProviders, "Id", "Name");
            ViewData["SpecialityId"]      = new SelectList(_context.Specialities, "Id", "Name");
            //  ViewData["UniversityId"] = new SelectList(_context.Universities, "Id", "ArUniversityName");
            return(View(MOOCListVM));


            //ViewData["ApplicationUserId"] = new SelectList(_context.ApplicationUsers, "Id", "Id");
            //ViewData["MOOCProviderId"] = new SelectList(_context.MOOCProvider, "Id", "Email");
            //ViewData["SpecialityId"] = new SelectList(_context.Specialities, "Id", "EnSpecialityName");
            //ViewData["UniversityId"] = new SelectList(_context.Universities, "Id", "ArUniversityName");
            //return View();
        }
Пример #2
0
        // GET: MOOCLists
        public async Task <IActionResult> Index(string SearchString, int productPage = 1)
        {
            MOOCListViewModel MOOCListVM = new MOOCListViewModel();

            if (string.IsNullOrEmpty(SearchString))
            {
                MOOCListVM = new MOOCListViewModel()
                {
                    MOOCLists = _context.MOOCLists.Include(p => p.ApplicationUser).Include(p => p.MOOCProvider).Include(p => p.Speciality).Include(p => p.University)
                };
            }
            else if (SearchString == "reported")
            {
                MOOCListVM = new MOOCListViewModel()
                {
                    MOOCLists = _context.MOOCLists.Where(a => a.IsReported == true).Include(p => p.ApplicationUser).Include(p => p.MOOCProvider).Include(p => p.Speciality).Include(p => p.University)
                };
            }
            else if (!string.IsNullOrEmpty(SearchString))
            {
                MOOCListVM = new MOOCListViewModel()
                {
                    MOOCLists = _context.MOOCLists.Where(a => a.Title.Contains(SearchString) || a.MOOCProvider.Name.Contains(SearchString) || a.Description.Contains(SearchString) || a.Image.Contains(SearchString) || a.Duration.Contains(SearchString) || a.ApplicationUser.ArName.Contains(SearchString) || a.University.ArUniversityName.Contains(SearchString) || a.Link.Contains(SearchString) || a.Tags.Contains(SearchString) || a.Instructor.Contains(SearchString) || a.YouTubeLink.Contains(SearchString)).Include(p => p.ApplicationUser).Include(p => p.MOOCProvider).Include(p => p.Speciality).Include(p => p.University)
                };
            }

            var count = MOOCListVM.MOOCLists.Count();

            MOOCListVM.MOOCLists = MOOCListVM.MOOCLists.OrderBy(p => p.Id)
                                   .Skip((productPage - 1) * PagSize)
                                   .Take(PagSize).ToList();


            MOOCListVM.PagingInfo = new PagingInfo
            {
                CurrentPage  = productPage,
                ItemsPerPage = PagSize,
                TotalItem    = count
            };

            //var aRIDDbContext = _context.MOOCList.Include(m => m.ApplicationUser).Include(m => m.MOOCProvider).Include(m => m.Speciality).Include(m => m.University);
            return(View(MOOCListVM));
        }
Пример #3
0
        public async Task <IActionResult> Edit(Guid?id)
        {
            var user = _context.MOOCLists.Include(c => c.ApplicationUser).SingleOrDefault(a => a.Id == id).ApplicationUser;

            if (user == null)
            {
                throw new ApplicationException($"Unable to load user with ID '{_userManager.GetUserId(User)}'.");
            }

            //if (id == null)
            //{
            //    return NotFound();
            //}

            //var mOOCList = await _context.MOOCList.SingleOrDefaultAsync(m => m.Id == id);
            //if (mOOCList == null)
            //{
            //    return NotFound();
            //}
            MOOCListViewModel MOOCListVM = new MOOCListViewModel()
            {
                MOOCList        = await _context.MOOCLists.SingleOrDefaultAsync(m => m.Id == id),
                CountryId       = user.CountryId,
                ApplicationUser = await _userManager.Users
                                  .Include(c => c.Country)
                                  .Include(c => c.City)
                                  .Include(c => c.University)
                                  .Include(c => c.Faculty)
                                  .Include(a => a.ReferredBy)
                                  .SingleOrDefaultAsync(u => u.Id == user.Id),
            };

            ViewData["CountryId"]         = new SelectList(_context.Countries, "Id", "ArCountryName", MOOCListVM.CountryId);
            ViewData["ApplicationUserId"] = new SelectList(_context.ApplicationUsers, "Id", "Id", MOOCListVM.MOOCList.ApplicationUserId);
            ViewData["MOOCProviderId"]    = new SelectList(_context.MOOCProviders, "Id", "Email", MOOCListVM.MOOCList.MOOCProviderId);
            ViewData["SpecialityId"]      = new SelectList(_context.Specialities, "Id", "Name", MOOCListVM.MOOCList.SpecialityId);
            ViewData["UniversityId"]      = new SelectList(_context.Universities, "Id", "ArUniversityName", MOOCListVM.MOOCList.UniversityId);
            return(View(MOOCListVM));
        }