Exemplo n.º 1
0
        /// <summary>
        /// Creates a Kirja Page
        /// </summary>
        /// <param name="page">page to create</param>
        /// <returns>Created page, with filled id</returns>
        public async Task <KirjaPage> CreatePage(KirjaPage page)
        {
            page.Id = Guid.NewGuid().ToString();
            await _PageCollection.InsertOneAsync(page);

            return(page);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Deletes a page
        /// </summary>
        /// <param name="page">Page to delete</param>
        /// <returns>Task</returns>
        public async Task DeletePage(KirjaPage page)
        {
            KirjaPage existingPage = await GetPageById(page.Id);

            if (existingPage == null)
            {
                throw new NullReferenceException();
            }

            IMongoCollection <KirjaPage> recyclingBin = _Database.GetCollection <KirjaPage>(KirjaPageRecyclingBinCollectionName);
            await recyclingBin.InsertOneAsync(existingPage);

            DeleteResult result = await _PageCollection.DeleteOneAsync(p => p.Id == page.Id);
        }
Exemplo n.º 3
0
        /// <summary>
        /// Returns the default page for a project
        /// </summary>
        /// <param name="projectId">Project Id</param>
        /// <returns>Page</returns>
        public async Task <KirjaPage> GetDefaultPageForProject(string projectId)
        {
            KirjaPage page = await _PageCollection.Find(p => p.ProjectId == projectId && p.IsDefault).FirstOrDefaultAsync();

            return(page);
        }
Exemplo n.º 4
0
        /// <summary>
        /// Returns an a page by its id
        /// </summary>
        /// <param name="id">Id</param>
        /// <returns>Page</returns>
        public async Task <KirjaPage> GetPageById(string id)
        {
            KirjaPage page = await _PageCollection.Find(p => p.Id == id).FirstOrDefaultAsync();

            return(page);
        }
Exemplo n.º 5
0
 /// <summary>
 /// Updates a page
 /// </summary>
 /// <param name="page">Page to update</param>
 /// <returns>Task</returns>
 public async Task UpdatePage(KirjaPage page)
 {
     ReplaceOneResult result = await _PageCollection.ReplaceOneAsync(p => p.Id == page.Id, page);
 }