コード例 #1
0
        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));
        }
コード例 #2
0
        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));
        }
コード例 #3
0
        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));
        }
コード例 #4
0
        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));
        }
コード例 #5
0
        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));
        }
コード例 #6
0
        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));
        }