示例#1
0
        public async Task <Post> InsertPost(Post post)
        {
            Ctx.Add <Post>(post);
            await Ctx.SaveChangesAsync();

            return(post);
        }
示例#2
0
        public async Task <IActionResult> Create([Bind("SectionId,SectionName,Description")] Section section)
        {
            if (ModelState.IsValid)
            {
                _context.Add(section);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(section));
        }
示例#3
0
        public async Task <IActionResult> Create([Bind("AuthorName,AuthorMail,AuthorReview")] Author author)
        {
            if (ModelState.IsValid)
            {
                _context.Add(author);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(author));
        }
示例#4
0
        public async Task <IActionResult> Create([Bind("ArticleId,ArticleName,SectionId,Subject,AuthorName,ArticleText")] Article article)
        {
            if (ModelState.IsValid)
            {
                _context.Add(article);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["AuthorName"] = new SelectList(_context.Author, "AuthorName", "AuthorName", article.AuthorName);
            ViewData["SectionId"]  = new SelectList(_context.Section, "SectionId", "SectionName", article.SectionId);
            return(View(article));
        }