public bool ifselect(int userid, int noteid) { NoteSelect select = db.NoteSelect.Where(a => a.UserID == userid && a.NoteID == noteid).FirstOrDefault(); if (select != null) { return(true); } else { return(false); } }
public void NoteSelect(int userid, int noteid) { NoteSelect select = db.NoteSelect.Where(b => b.UserID == userid && b.NoteID == noteid).FirstOrDefault(); if (select != null) { db.NoteSelect.Remove(select); db.SaveChanges(); } else { NoteSelect select1 = new NoteSelect(); select1.NoteID = noteid; select1.UserID = userid; select1.Time = DateTime.Now; db.NoteSelect.Add(select1); db.SaveChanges(); } }