コード例 #1
0
        public async Task <IActionResult> Create([Bind("BlogArticleId,Title,BlogText")] BlogArticle blogArticle)
        {
            if (ModelState.IsValid)
            {
                _context.Add(blogArticle);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(blogArticle));
        }
コード例 #2
0
        public async Task <IActionResult> Create([Bind("UserProfileId,FirstName,LastName,UserAccountId")] UserProfile userProfile)
        {
            if (ModelState.IsValid)
            {
                _context.Add(userProfile);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(ProfileInfo)));
            }
            return(View(userProfile));
        }
コード例 #3
0
        public async Task <IActionResult> Create([Bind("RecipeId,Title,RecipeText")] Recipe recipe)
        {
            if (ModelState.IsValid)
            {
                _context.Add(recipe);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(recipe));
        }
コード例 #4
0
        public async Task <IActionResult> Create([Bind("RecipeCommentsId,Comments,UserProfileId,RecipeId")] RecipeComments recipeComments)
        {
            if (ModelState.IsValid)
            {
                _context.Add(recipeComments);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["RecipeId"]      = new SelectList(_context.Recipe, "RecipeId", "RecipeText", recipeComments.RecipeId);
            ViewData["UserProfileId"] = new SelectList(_context.UserProfile, "UserProfileId", "FirstName", recipeComments.UserProfileId);
            return(View(recipeComments));
        }
コード例 #5
0
        public async Task <IActionResult> Create([Bind("BlogCommentsId,Comment,UserProfileId,BlogId")] BlogComments blogComments)
        {
            if (ModelState.IsValid)
            {
                _context.Add(blogComments);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["BlogId"]        = new SelectList(_context.BlogArticle, "BlogArticleId", "BlogText", blogComments.BlogId);
            ViewData["UserProfileId"] = new SelectList(_context.UserProfile, "UserProfileId", "FirstName", blogComments.UserProfileId);
            return(View(blogComments));
        }