public void Save() { foreach (Diary d in Diaries) { foreach (Diary a in AllDiaries) { if (d.WritenDT.Equals(a.WritenDT)) { AllDiaries.Remove(a); AllDiaries.Add(d); break; } } } var QDiaries = from r in DataContext.Diary where r.UserID == Currentuser.ID select r; foreach (var QD in QDiaries) { DataContext.Diary.DeleteOnSubmit(QD); } foreach (Diary d in AllDiaries) { DataContext.Diary.InsertOnSubmit(d); } Submit(); }
public void InitializeDiary() { AllDiaries.Clear(); Diaries.Clear(); var QDiaries = from r in DataContext.Diary where r.UserID == Currentuser.ID select r; foreach (var QD in QDiaries) { AllDiaries.Add(QD); Diaries.Add(QD); } }
public void CreateDiary(string ntitle, string ncontent) { if (string.IsNullOrWhiteSpace(ntitle)) { ntitle = "Untitled"; } Diary diary = new Diary { UserID = Currentuser.ID, Title = ntitle, Content = ncontent, WritenDT = DateTime.Now }; Diaries.Add(diary); AllDiaries.Add(diary); Status = "创建日记成功!"; }