コード例 #1
0
        public async Task <IActionResult> Edit(int id, [Bind("RecipeCommentsId,Comments,UserProfileId,RecipeId")] RecipeComments recipeComments)
        {
            if (id != recipeComments.RecipeCommentsId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(recipeComments);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!RecipeCommentsExists(recipeComments.RecipeCommentsId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                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));
        }
コード例 #2
0
    //Handles recipe comment
    private void GetComments()
    {
        //Get Recipe Comment - show/hide comment
        RecipeComments Comment = new RecipeComments(Recipe.ID, RecComments, PlaceHolder1);

        Comment.fillup();

        Comment = null;
    }
コード例 #3
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));
        }