예제 #1
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,content,mail")] Message message)
        {
            if (HttpContext.Session.GetString("user") == null)
            {
                return(RedirectToAction("Login", "Users"));
            }
            if (id != message.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(message);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!MessageExists(message.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(message));
        }
예제 #2
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,PublishDate,Title,Writer,BodyText")] Post post)
        {
            if (HttpContext.Session.GetString("user") == null)
            {
                return(RedirectToAction("Login", "Users"));
            }
            else
            {
                TempData["user"] = "******";
            }
            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));
        }
예제 #3
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,Name,Password")] User user)
        {
            if (HttpContext.Session.GetString("user") == null)
            {
                return(RedirectToAction("Login", "Users"));
            }
            else
            {
                TempData["user"] = "******";
            }
            if (id != user.Id)
            {
                return(NotFound());
            }

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