public string diarydelete([FromBody] JObject obj) { var diarypagenum = new { pagenum = Convert.ToInt32(obj["pagenum"]) }; using (DiaryDBEntitiesOne diarydb = new DiaryDBEntitiesOne()) { Diaryinfo_tb diarycount = diarydb.Diaryinfo_tb.Where(diary => diary.DiaryinfoID == diarypagenum.pagenum).FirstOrDefault(); diarydb.Diaryinfo_tb.Remove(diarycount); return(diarydb.SaveChanges() > 0?"Yes": "No"); } }
public string diaryinsert([FromBody] JObject obj) { var diaryinfo = new { userid = obj["userid"], diarytype = obj["diarytype"], diarycontent = obj["diarycontent"], diarymedia = obj["diarymedia"] }; using (DiaryDBEntitiesOne diarydb = new DiaryDBEntitiesOne()) { var Diaryinfo = new Diaryinfo_tb(); Diaryinfo.User_tbID = (int)diaryinfo.userid; Diaryinfo.Diarytype = (int)diaryinfo.diarytype; Diaryinfo.Diarycontent = (string)diaryinfo.diarycontent; Diaryinfo.Diarymedia = (string)diaryinfo.diarymedia; Diaryinfo.Diarytime = DateTime.Parse(DateTime.Now.ToString("yyyy-MM-dd")); diarydb.Diaryinfo_tb.Add(Diaryinfo); return(diarydb.SaveChanges() > 0 ? "Yes" : "No"); } }