public BiotaPropertiesBookPageData AddPage(uint authorId, string authorName, string authorAccount, bool ignoreAuthor, string pageText) { var pages = Biota.GetBookAllPages(Guid.Full, BiotaDatabaseLock); if (pages == null || pages.Count == AppraisalMaxPages) { return(null); } var page = new BiotaPropertiesBookPageData() { ObjectId = Biota.Id, PageId = (uint)pages.Count, AuthorId = authorId, AuthorName = authorName, AuthorAccount = authorAccount, IgnoreAuthor = ignoreAuthor, PageText = pageText }; Biota.AddBookPage(page, BiotaDatabaseLock, out var alreadyExists); if (alreadyExists) { return(null); } SetProperty(PropertyInt.AppraisalPages, pages.Count + 1); ChangesDetected = true; return(page); }
public bool DeletePage(uint pageId, Player player) { var pages = Biota.GetBookAllPages(Guid.Full, BiotaDatabaseLock); var page = Biota.GetBookPageData(Guid.Full, pageId, BiotaDatabaseLock); if (page == null || (!page.IgnoreAuthor && player.Guid.Full != page.AuthorId && !(player is Sentinel) && !(player is Admin))) { return(false); } var success = Biota.DeleteBookPage(pageId, out var entity, BiotaDatabaseLock); if (!success) { return(false); } if (pageId < pages.Count - 1) { // handle deleting page from middle of book for (var i = pageId + 1; i < pages.Count; i++) { var page2 = Biota.GetBookPageData(Guid.Full, i, BiotaDatabaseLock); page2.PageId--; } } SetProperty(PropertyInt.AppraisalPages, pages.Count - 1); ChangesDetected = true; return(true); }
public bool DeletePage(uint pageId) { var pages = Biota.GetBookAllPages(Guid.Full, BiotaDatabaseLock); var success = Biota.DeleteBookPage(pageId, out var entity, BiotaDatabaseLock); if (!success) { return(false); } if (pageId < pages.Count - 1) { // handle deleting page from middle of book for (var i = pageId + 1; i < pages.Count; i++) { var page = Biota.GetBookPageData(Guid.Full, i, BiotaDatabaseLock); page.PageId--; } } SetProperty(PropertyInt.AppraisalPages, pages.Count - 1); ChangesDetected = true; return(true); }