public async Task <IActionResult> Edit(int id, [Bind("Id,Question,CourseChapterId,Indx,IsHidden,Description,Imgurl")] CourseChapterExam courseChapterExam, IFormFile myfile) { if (id != courseChapterExam.Id) { return(NotFound()); } if (ModelState.IsValid) { try { courseChapterExam.Imgurl = await UserFile.UploadeNewImageAsync(courseChapterExam.Imgurl, myfile, _environment.WebRootPath, Properties.Resources.Secured, 500, 500); _context.Update(courseChapterExam); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!CourseChapterExamExists(courseChapterExam.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction("Edit", "CourseChapters", new { id = courseChapterExam.CourseChapterId })); } return(View(courseChapterExam)); }
public async Task <IActionResult> Create([Bind("Id,Question,CourseChapterId,Indx,IsHidden,Description,Imgurl")] CourseChapterExam courseChapterExam, IFormFile myfile) { if (ModelState.IsValid) { courseChapterExam.Imgurl = await UserFile.UploadeNewImageAsync(courseChapterExam.Imgurl, myfile, _environment.WebRootPath, Properties.Resources.Secured, 500, 500); _context.Add(courseChapterExam); await _context.SaveChangesAsync(); return(RedirectToAction("Edit", "CourseChapters", new { id = courseChapterExam.CourseChapterId })); } return(View(courseChapterExam)); }