public IList <long> CreatePageBookmark(string bookXmlId, string pageXmlId, string title, IList <long> labelIds) { var now = DateTime.UtcNow; var user = TryGetUser(); var bookPage = m_bookVersionRepository.GetPageByXmlId(bookXmlId, pageXmlId); if (bookPage == null) { string message = string.Format("Page not found for bookXmlId: '{0}' and page xmlId: '{1}'", bookXmlId, pageXmlId); if (m_log.IsErrorEnabled) { m_log.Error(message); } throw new ArgumentException(message); } var labels = GetFavoriteLabelsAndCheckAuthorization(labelIds, user.Id); var labelsDictionary = labels.ToDictionary(x => x.Id); var itemsToSave = new List <PageBookmark>(); foreach (var labelId in labelIds) { var label = labelsDictionary[labelId]; label.LastUseTime = now; Book book = m_bookVersionRepository.Load <Book>(bookPage.BookVersion.Book.Id); PageBookmark favoriteItem = new PageBookmark { PageXmlId = pageXmlId, User = user, PagePosition = bookPage.Position, Book = book, Title = title, FavoriteLabel = label, CreateTime = now, }; itemsToSave.Add(favoriteItem); } var result = m_favoritesRepository.CreateAll(itemsToSave); return(result.Cast <long>().ToList()); }