public HttpResponseMessage PostLegacy(HttpRequestMessage req)
{
var body = req.Content.ReadAsStringAsync().Result;
// Parsing QueryString
var nvc = HttpUtility.ParseQueryString(body);
var form = nvc.Keys.Cast<string>().ToDictionary(x => x, x => nvc[x]);
if (!form.ContainsKey("Zaz-Command-Id"))
{
throw ExceptionsFactory.CreateApiException("Required value 'Zaz-Command-Id' was not found.");
}
var cmdKey = form["Zaz-Command-Id"];
var cmdType = _resolver.ResolveCommandType(cmdKey);
object cmd;
try
{
var binder = new CommandBinder();
cmd = binder.Build(cmdType, form);
}
catch (InvalidOperationException ex)
{
throw ExceptionsFactory.CreateApiException("Problems with binding command data. " + ex.Message);
}
return _runner.RunCommand(cmdKey, cmd, new string[0]);
}