public async Task <ActionResult> Create(Course course) { if (ModelState.IsValid) { course.Id = Guid.NewGuid().ToString(); db.Courses.Add(course); await db.SaveChangesAsync(); return(RedirectToAction("Index")); } return(View(course)); }
public async Task <ActionResult> Create(Question question) { if (ModelState.IsValid) { question.Id = Guid.NewGuid().ToString(); db.Questions.Add(question); await db.SaveChangesAsync(); return(RedirectToAction("Index")); } ViewBag.ContentId = new SelectList(db.Contents, "Id", "Name", question.ContentId); return(View(question)); }
public async Task <ActionResult> Create(Content content) { if (ModelState.IsValid) { content.Id = Guid.NewGuid().ToString(); db.Contents.Add(content); await db.SaveChangesAsync(); return(RedirectToAction("Index")); } ViewBag.LevelId = new SelectList(db.Levels, "Id", "Name", content.LevelId); return(View(content)); }
public async Task <ActionResult> Create(Level level) { if (ModelState.IsValid) { level.Id = Guid.NewGuid().ToString(); db.Levels.Add(level); await db.SaveChangesAsync(); return(RedirectToAction("Index")); } ViewBag.CourseId = new SelectList(db.Courses, "Id", "Name", level.CourseId); return(View(level)); }
public async Task <ActionResult> Create(Website website) { if (ModelState.IsValid) { website.Id = Guid.NewGuid().ToString(); db.Websites.Add(website); await db.SaveChangesAsync(); return(RedirectToAction("Index")); } ViewBag.ContentId = new SelectList(db.Contents, "Id", "Name", website.ContentId); return(View(website)); }
public async Task <ActionResult> Create(File file) { file.Id = Guid.NewGuid().ToString(); if (ModelState.IsValid) { try { db.Files.Add(file); await db.SaveChangesAsync(); return(RedirectToAction("Index")); } catch (Exception e) { throw e; } } ViewBag.ContentId = new SelectList(db.Contents, "Id", "Name", file.ContentId); return(View(file)); }