private void AddLikes(NoteDB n, string user) { if (n.Likes == "无") { n.Likes = user; } else { n.Likes += ","; n.Likes += user; } db.Entry(n).State = EntityState.Modified; db.SaveChanges(); }
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)); }
public async Task <IActionResult> PutNotes(int id, Note note) { note.UID = id; _context.Entry(note).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!DCandidateExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public void Update(Note note) { _dbContext.Entry(note).State = EntityState.Modified; }