示例#1
0
        public async Task <IActionResult> Edit(int id, [Bind("ID,Title,DateCreated,DateModified,Details")] NoteContext noteContext)
        {
            if (id != noteContext.ID)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(noteContext);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!NoteContextExists(noteContext.ID))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(noteContext));
        }
示例#2
0
        public IActionResult Edit(Note model)
        {
            if (HttpContext.Session.GetInt32("USER_LOGIN_KEY") == null)
            {
                return(RedirectToAction("Login", "Account"));
            }
            model.UserNo = Int32.Parse(HttpContext.Session.GetInt32("USER_LOGIN_KEY").ToString());
            using (var db = new NoteDBContext())
            {
                db.Entry(model).CurrentValues.SetValues(model);
                db.Update(model);
                db.SaveChanges();
                return(Redirect("Index"));
            }
            ModelState.AddModelError(string.Empty, "게시물을 저장할 수 없습니다.");


            return(View(model));
        }
示例#3
0
        public IActionResult Edit(int?id, [Bind("ID,CreatedDate,Title,Text,Importance,FinishDate,Finished")] Note note)
        {
            ViewData["CurrentStyle"] = style.getCurrent();
            if (id != note.ID)
            {
                return(BadRequest());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _noteDBContext.Update(note);
                    _noteDBContext.SaveChanges();
                }
                catch (DbUpdateConcurrencyException) { return(BadRequest()); }
                catch (DbUpdateException) { return(BadRequest()); }

                return(RedirectToAction("Index", "Home"));
            }
            return(View(note));
        }