示例#1
0
 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();
 }
示例#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 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());
        }
示例#4
0
 public void Update(Note note)
 {
     _dbContext.Entry(note).State = EntityState.Modified;
 }