public async Task <string> Export(GameSpecExport model) { var yaml = new SerializerBuilder() .WithNamingConvention(CamelCaseNamingConvention.Instance) .Build(); var entity = await Store.Retrieve(model.Id, q => q.Include(g => g.Specs)); if (entity is Data.Game) { return(yaml.Serialize(entity)); } entity = new Data.Game { Id = Guid.NewGuid().ToString("n") }; for (int i = 0; i < model.GenerateSpecCount; i++) { entity.Specs.Add(new Data.ChallengeSpec { Id = Guid.NewGuid().ToString("n"), GameId = entity.Id }); } return(model.Format == ExportFormat.Yaml ? yaml.Serialize(entity) : JsonSerializer.Serialize(entity, JsonOptions) ); }
public async Task <string> ExportGameSpec([FromBody] GameSpecExport model) { return(await GameService.Export(model)); }