/// <summary>
        /// Creates an include template
        /// </summary>
        /// <param name="template">Template to create</param>
        /// <returns>Created template, with filled id</returns>
        public async Task <IncludeExportTemplate> CreateIncludeTemplate(IncludeExportTemplate template)
        {
            template.Id = Guid.NewGuid().ToString();

            await _TemplateCollection.InsertOneAsync(template);

            return(template);
        }
        /// <summary>
        /// Updates an include template
        /// </summary>
        /// <param name="template">Template to update</param>
        /// <returns>Task</returns>
        public async Task UpdateIncludeTemplate(IncludeExportTemplate template)
        {
            ReplaceOneResult result = await _TemplateCollection.ReplaceOneAsync(t => t.Id == template.Id, template);

            if (result.MatchedCount == 0)
            {
                throw new KeyNotFoundException();
            }
        }
        /// <summary>
        /// Deletes an include template
        /// </summary>
        /// <param name="template">Template to delete</param>
        /// <returns>Task</returns>
        public async Task DeleteIncludeTemplate(IncludeExportTemplate template)
        {
            IncludeExportTemplate existingTemplate = await GetIncludeTemplateById(template.Id);

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

            IMongoCollection <IncludeExportTemplate> recyclingBin = _Database.GetCollection <IncludeExportTemplate>(IncludeExportTemplateRecyclingBinCollectionName);
            await recyclingBin.InsertOneAsync(existingTemplate);

            DeleteResult result = await _TemplateCollection.DeleteOneAsync(t => t.Id == template.Id);
        }
        /// <summary>
        /// Returns a template by name
        /// </summary>
        /// <param name="projectId">Id of the project</param>
        /// <param name="templateName">Template name</param>
        /// <returns>Export Template</returns>
        public async Task <IncludeExportTemplate> GetIncludeTemplateByName(string projectId, string templateName)
        {
            IncludeExportTemplate template = await _TemplateCollection.Find(t => t.ProjectId == projectId && t.Name == templateName).FirstOrDefaultAsync();

            return(template);
        }
        /// <summary>
        /// Returns a template by its Id
        /// </summary>
        /// <param name="id">Id of the template</param>
        /// <returns>Export Template</returns>
        public async Task <IncludeExportTemplate> GetIncludeTemplateById(string id)
        {
            IncludeExportTemplate template = await _TemplateCollection.Find(t => t.Id == id).FirstOrDefaultAsync();

            return(template);
        }