public CCNote SaveNote(CCNote noteObj) { if (noteObj.NotesID == 0) { context.CCNotes.Add(noteObj); context.SaveChanges(); } else { CCNote dbEntry = context.CCNotes.Find(noteObj.NotesID); if (dbEntry != null) { dbEntry.value = noteObj.value; context.SaveChanges(); } } return noteObj; }
public ActionResult SaveNote(string note, string cid) { Account accountObj = (Account)Session["account"]; long contactID = Convert.ToInt64(cid); long noteID = 0; var isAvaiableNote = CCNoteRepository.CCNotes.FirstOrDefault(contid => contid.ContactID == contactID & contid.AccountGUID == accountObj.AccountGUID); if (isAvaiableNote != null) { noteID = isAvaiableNote.NotesID; } CCNote objNote = new CCNote(); objNote.value = note.Trim(); objNote.ContactID = contactID; objNote.NotesID = noteID; var res = CCNoteRepository.SaveNote(objNote); if (res != null) { return Json("sucess", JsonRequestBehavior.AllowGet); } else { return Json("Fail", JsonRequestBehavior.AllowGet); } }