public async Task <IActionResult> Create([Bind("CourseId,Name,Prefix,Number")] Course course)
        {
            if (ModelState.IsValid)
            {
                _context.Add(course);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(course));
        }
Beispiel #2
0
        public async Task <IActionResult> Create([Bind("PostId,Topic,Text,ParentPostId")] Post post)
        {
            if (ModelState.IsValid)
            {
                _context.Add(post);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["ParentPostId"] = new SelectList(_context.Posts, "PostId", "PostId", post.ParentPostId);
            return(View(post));
        }