private void SaveDraft() { try { if (string.IsNullOrEmpty(Text) || Text.Length < 5) { throw new Exception("Rant or comment must be more than 5 characters long."); } SavedPostContent data = new SavedPostContent(Text); if (type == EditPostWindow.Type.Rant && !string.IsNullOrEmpty(TagsString)) { data.Tags = TagsString; } if (!string.IsNullOrEmpty(ImagePath)) { data.ImagePath = ImagePath; } if (existing == null) { db.AddDraft(data); AddedDraft = data; } else { data.SetId(existing.ID.Value); db.UpdateDraft(data); } Cancelled = false; window.Close(); } catch (Exception e) { MessageBoxFactory.ShowError(e, owner: window); } }
//TODO: Need to have DB update as well? and return updated? public void Update(SavedPostContent draft) { throw new NotImplementedException(); }
public Draft(SavedPostContent draft) : this() { this.draft = draft; }