Return proper responses for missing seed ids
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
using ALttPRandomizer.Model;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ALttPRandomizer.Service {
|
||||
public class RandomizeService {
|
||||
@@ -14,10 +15,10 @@ namespace ALttPRandomizer.Service {
|
||||
private IdGenerator IdGenerator { get; }
|
||||
private Randomizer Randomizer { get; }
|
||||
|
||||
public string RandomizeSeed(SeedSettings settings) {
|
||||
public async Task<string> RandomizeSeed(SeedSettings settings) {
|
||||
var id = this.IdGenerator.GenerateId();
|
||||
this.Logger.LogInformation("Generating seed {seedId} with settings {@settings}", id, settings);
|
||||
this.Randomizer.Randomize(id, settings);
|
||||
await this.Randomizer.Randomize(id, settings);
|
||||
return id;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,21 +1,26 @@
|
||||
namespace ALttPRandomizer.Service {
|
||||
using ALttPRandomizer.Azure;
|
||||
using ALttPRandomizer.Model;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text.Json;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
public class SeedService {
|
||||
public SeedService(AzureStorage azureStorage) {
|
||||
public SeedService(AzureStorage azureStorage, ILogger<SeedService> logger) {
|
||||
this.AzureStorage = azureStorage;
|
||||
this.Logger = logger;
|
||||
}
|
||||
|
||||
private AzureStorage AzureStorage { get; }
|
||||
private ILogger<SeedService> Logger { get; }
|
||||
|
||||
public async Task<IDictionary<string, object>> GetSeed(string seedId) {
|
||||
var files = await this.AzureStorage.GetFiles(seedId);
|
||||
|
||||
this.Logger.LogDebug("Found files: {@files}", files.Keys);
|
||||
|
||||
var result = new Dictionary<string, object>();
|
||||
|
||||
if (!files.TryGetValue("settings.json", out var settingsData)) {
|
||||
|
||||
Reference in New Issue
Block a user