public async Task <IActionResult> Create([Bind("Id,Title,MOOCProviderId,Description,SpecialityId,IsFree,IsReported,Language,Certificate,Duration,UniversityId,Link,YouTubeLink,Tags,Instructor,Image,StartDate,ApplicationUserId,DateOfRecord")] MOOCList mOOCList, IFormFile myfile) { if (ModelState.IsValid) { mOOCList.ApplicationUserId = _userManager.GetUserId(User); mOOCList.DateOfRecord = DateTime.Now; mOOCList.Image = await UserFile.UploadeNewImageAsync(mOOCList.Image, myfile, _environment.WebRootPath, Properties.Resources.ScientificEvent, 500, 500); mOOCList.Description = mOOCList.Description.Replace("\n", "<br/>"); mOOCList.Id = Guid.NewGuid(); _context.Add(mOOCList); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewData["ApplicationUserId"] = new SelectList(_context.ApplicationUsers, "Id", "Id", mOOCList.ApplicationUserId); ViewData["MOOCProviderId"] = new SelectList(_context.MOOCProviders, "Id", "Name", mOOCList.MOOCProviderId); ViewData["SpecialityId"] = new SelectList(_context.Specialities, "Id", "Name", mOOCList.SpecialityId); // ViewData["UniversityId"] = new SelectList(_context.Universities, "Id", "ArUniversityName", mOOCList.UniversityId); return(View(mOOCList)); }
public IActionResult Report(Guid id) { MOOCList MOOCList = _context.MOOCLists.Where(m => m.Id == id).SingleOrDefault(); if (MOOCList == null) { return(NotFound()); } MOOCList.IsReported = true; _context.SaveChanges(); return(RedirectToAction("Details/" + id)); }
public async Task <IActionResult> Edit(Guid id, [Bind("Id,Title,MOOCProviderId,Description,SpecialityId,IsFree,IsReported,Language,Certificate,Duration,UniversityId,Link,YouTubeLink,Tags,Instructor,Image,StartDate,ApplicationUserId,DateOfRecord")] MOOCList mOOCList, IFormFile myfile) { if (id != mOOCList.Id) { return(NotFound()); } if (ModelState.IsValid) { try { mOOCList.Image = await UserFile.UploadeNewImageAsync(mOOCList.Image, myfile, _environment.WebRootPath, Properties.Resources.ScientificEvent, 500, 500); _context.Update(mOOCList); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!MOOCListExists(mOOCList.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["ApplicationUserId"] = new SelectList(_context.ApplicationUsers, "Id", "Id", mOOCList.ApplicationUserId); ViewData["MOOCProviderId"] = new SelectList(_context.MOOCProviders, "Id", "Email", mOOCList.MOOCProviderId); ViewData["SpecialityId"] = new SelectList(_context.Specialities, "Id", "EnSpecialityName", mOOCList.SpecialityId); ViewData["UniversityId"] = new SelectList(_context.Universities, "Id", "ArUniversityName", mOOCList.UniversityId); return(View(mOOCList)); }