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

            return(post);
        }
Beispiel #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));
        }
Beispiel #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));
        }
Beispiel #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));
        }