public long UpdateBookVersion(long projectId, int userId, BookData bookData) { var now = DateTime.UtcNow; var project = m_resourceRepository.Load <Project>(projectId); var user = m_resourceRepository.Load <User>(userId); var dbBookVersionResource = m_resourceRepository.GetLatestBookVersion(projectId); if (dbBookVersionResource == null) { var newDbResource = new Resource { Name = "BookVersion", ContentType = ContentTypeEnum.FullLiteraryWork, ResourceType = ResourceTypeEnum.BookVersion, Project = project, }; return(CreateBookVersionResource(newDbResource, 1, bookData.VersionXmlId, user, now)); } else { return(CreateBookVersionResource(dbBookVersionResource.Resource, dbBookVersionResource.VersionNumber + 1, bookData.VersionXmlId, user, now)); } }