private void AcceptDialog(object sender, RoutedEventArgs e) { if (!Validation.GetHasError(Title) && !Validation.GetHasError(Author) && !Validation.GetHasError(Description)) { string _storyTitle = Title.Text; string _storyAuthor = Author.Text; string _storyDate = Date.Text; string _storyType = Type.Text; string _storyDescription = Description.Text; STORY story = new STORY() { Name = _storyTitle, Author = _storyAuthor, Created = _storyDate, Type = _storyType, Description = _storyDescription }; var forgeDatabase = Global.Instance.ForgeDatabase(); forgeDatabase.Stories.InsertOnSubmit(story); forgeDatabase.SubmitChanges(); /*string sql = @"insert into STORY (StoryName, StoryAuthor, DateCreated, StoryType, StoryDescription) * values ('" + _storyTitle + "','" + _storyAuthor + "','" + _storyDate + "','" + _storyType + "','" + _storyDescription + "')"; * * Global.Instance.InitiateDatabaseNonQuery(); * Global.Instance.SQLInsert(sql); * Global.Instance.CloseDatabase();*/ IoC.Get <IEventAggregator>().PublishOnUIThread("AcceptRootDialog"); IoC.Get <IEventAggregator>().PublishOnUIThread("AcceptRealmCreation"); } }
private void AcceptDialog(object sender, RoutedEventArgs e) { if (!Validation.GetHasError(StoryTitle) && !Validation.GetHasError(StoryAuthor) && !Validation.GetHasError(StoryDescription)) { var contains = new StringContains(); string _storyTitle = StoryTitle.Text; string _storyAuthor = StoryAuthor.Text; string _storyDate = StoryDate.Text; string _storyType = StoryType.Text; string _storyDescription = StoryDescription.Text; var forgeDatabase = Global.Instance.ForgeDatabase(); STORY story = forgeDatabase.Stories.Single(s => s.ID == Global.Instance.StoryID); story.Name = _storyTitle; story.Author = _storyAuthor; story.Created = _storyDate; story.Type = _storyType; story.Description = _storyDescription; forgeDatabase.SubmitChanges(); Global.Instance.UpdateNote(@"Story UPDATED! (Name = " + _storyTitle + @") (Author = " + _storyAuthor + @") (Created = " + _storyDate + @") (Type = " + _storyType + @") (Description = " + _storyDescription + @")"); IoC.Get <IEventAggregator>().PublishOnUIThread("AcceptRootDialog"); IoC.Get <IEventAggregator>().PublishOnUIThread("AcceptRealmUpdate"); } }
public void DeleteStory() { try { var forgeDatabase = Global.Instance.ForgeDatabase(); int storyID = StoryCollection[SelectedIndex].ID; List <string> mapPath = new List <string>(); foreach (var map in forgeDatabase.Maps.Where(x => x.StoryID == storyID)) { mapPath.Add(map.Path); } STORY story = forgeDatabase.Stories.Single(s => s.ID == storyID); //MessageBox.Show(story.ID.ToString()); forgeDatabase.Stories.DeleteOnSubmit(story); forgeDatabase.SubmitChanges(); PopulateStoryCollection(); Global.Instance.StoryID = -1; Global.Instance.StoryName = string.Empty; Global.Instance.StoryAuthor = string.Empty; Global.Instance.DateCreated = string.Empty; Global.Instance.StoryType = string.Empty; Global.Instance.StoryDescription = string.Empty; Global.Instance.StoryLoaded = false; StoryLoadedName = string.Empty; StoryLoadedAuthor = string.Empty; LoadedDateCreated = string.Empty; StoryLoadedType = string.Empty; StoryLoadedDescription = string.Empty; IsStoryLoaded = false; Global.Instance.MapID = -1; Global.Instance.ParentMapID = -1; Global.Instance.MapName = string.Empty; Global.Instance.MapPath = string.Empty; Global.Instance.MapWidth = -1; Global.Instance.MapHeight = -1; Global.Instance.IsBaseMap = false; Global.Instance.BaseMapLoaded = false; Global.Instance.BaseMapID = -1; Global.Instance.BaseParentMapID = -1; Global.Instance.BaseMapName = string.Empty; Global.Instance.BaseMapPath = string.Empty; Global.Instance.BaseMapWidth = -1; Global.Instance.BaseMapHeight = -1; Global.Instance.BaseIsBaseMap = false; foreach (var map in mapPath) { if (File.Exists(map)) { File.Delete(map); } else { MessageBox.Show("Map not found: " + map); } } IoC.Get <IEventAggregator>().PublishOnUIThread("DeleteStory"); } catch (Exception e) { MessageBox.Show(e.ToString()); } }