public QueryResult <ContentSchema> QueryContentSchemas()
 {
     return(new QueryResult <ContentSchema>()
     {
         Items = ContentSchemas.AsQueryable()
                 .OrderBy(x => x.Name)
                 .ToList()
                 .Select(x => x.ToModel())
                 .ToList()
     });
 }
        public async Task CreateAsync(ContentSchema schema)
        {
            if (schema.Id == Guid.Empty)
            {
                schema.Id = Guid.NewGuid();
            }

            DateTime now = DateTimeService.Current();

            schema.CreatedAt  = now;
            schema.ModifiedAt = now;

            var mongo = schema.ToMongo();

            await ContentSchemas.InsertOneAsync(mongo);

            schema.Id = mongo.Id;
        }
 public Task <ContentSchema> GetContentSchemaAsync(Guid id)
 {
     return(Task.Run(() => ContentSchemas.AsQueryable().FirstOrDefault(x => x.Id == id).ToModel()));
 }
 public Task <ContentSchema> GetContentSchemaAsync(string name)
 {
     return(Task.Run(() => ContentSchemas.AsQueryable().FirstOrDefault(x => x.Name == name).ToModel()));
 }
        public async Task UpdateAsync(ContentSchema entity)
        {
            entity.ModifiedAt = DateTimeService.Current();

            await ContentSchemas.FindOneAndReplaceAsync(Builders <MongoContentSchema> .Filter.Where(x => x.Id == entity.Id), entity.ToMongo());
        }