Ejemplo n.º 1
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,SliceId,UserId,Title,PostText,Comments,Likes,Dislikes,PostDate")] Post post)
        {
            if (id != post.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(post);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!PostExists(post.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(post));
        }
        public async Task <IActionResult> Edit(int id, [Bind("Id,Name,Description,Followers,UserId")] Slice slice)
        {
            if (id != slice.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(slice);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!SliceExists(slice.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(slice));
        }