public bool FileSave() { Cursor.Current = Cursors.WaitCursor; if (!DataIsValid()) { return(false); } ItemData.CourseCode = txtCourseCode.Text; ItemData.Description = txtDescription.Text; if (ItemData.Id != 0) { ItemData.RowStatus = AiTech.LiteOrm.RecordStatus.ModifiedRecord; } var writer = new CourseDataWriter(App.CurrentUser.User.Username, ItemData); writer.SaveChanges(); DialogResult = DialogResult.OK; DirtyStatus.Clear(); return(true); }
protected override void OnDelete(Entity item, out string message, ref Action <Entity> afterConfirm) { if (afterConfirm == null) { throw new ArgumentNullException(nameof(afterConfirm)); } message = ((Course)item).CourseCode + " - " + ((Course)item).Description; afterConfirm = currentItem => { try { var deletedItem = (Course)currentItem; deletedItem.RowStatus = RecordStatus.DeletedRecord; //Save to Database var dataWriter = new CourseDataWriter(App.CurrentUser.User.Username, deletedItem); dataWriter.SaveChanges(); ItemDataCollection.Remove((Dll.SchoolYear.Course)currentItem); App.LogAction("School Year.Course", "Deleted Course : " + deletedItem.CourseCode); } catch (Exception ex) { MessageDialog.ShowError(ex, this); } }; }