private async void OnSaveBook() { bool checkTitle, checkAuthor, checkTags, checkEntries; string[] tags; checkTitle = NewBook.Title == "" || NewBook.Title == null ? false : true; checkAuthor = NewBook.Author == "" || NewBook.Author == null ? false : true; checkTags = BookTags == null || BookTags == "" ? false : true; if (!(checkTitle && checkAuthor && checkTags)) { AlertManager.IncompleteInfo(); return; } if (NewBook.Entries == null || NewBook.Entries.Count == 0) { checkEntries = await AlertManager.NoEntries(); if (!checkEntries) { return; } } tags = Regex.Split(BookTags, ", "); NewBook.BookTags.Clear(); foreach (String s in tags) { NewBook.BookTags.Add(s); } HashSet <WorkTag> entryTags = new HashSet <WorkTag>(); NewBook.EntryTags.Clear(); foreach (WorkEntry e in NewBook.Entries) { if (e.ImageChanged && e.OldImagePath != null) { await FileManager.RemoveImage(e.OldImagePath); await FileManager.AddImage(e.ImagePath, e.NewImageData); } foreach (WorkTag t in e.Tags) { NewBook.EntryTags.Add(t.Name); } } foreach (string s in NewBook.RemovedImages) { await FileManager.RemoveImage(s); } Debug.WriteLine(NewBook.ToString()); RealmManager.UpdateBook(NewBook); await Navigation.PopAsync(); }