This commit is contained in:
@@ -48,7 +48,7 @@ namespace AyaNova.Api.Controllers
|
|||||||
serverState = apiServerState;
|
serverState = apiServerState;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -243,6 +243,56 @@ namespace AyaNova.Api.Controllers
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Get Translation all values
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="id"></param>
|
||||||
|
/// <returns>A single Translation and it's values</returns>
|
||||||
|
[HttpGet("download/{id}")]
|
||||||
|
public async Task<IActionResult> DownloadTranslation([FromRoute] long id)
|
||||||
|
{
|
||||||
|
if (serverState.IsClosed)
|
||||||
|
return StatusCode(503, new ApiErrorResponse(serverState.ApiErrorCode, null, serverState.Reason));
|
||||||
|
|
||||||
|
|
||||||
|
if (!ModelState.IsValid)
|
||||||
|
{
|
||||||
|
return BadRequest(new ApiErrorResponse(ModelState));
|
||||||
|
}
|
||||||
|
|
||||||
|
//Instantiate the business object handler
|
||||||
|
TranslationBiz biz = TranslationBiz.GetBiz(ct, HttpContext);
|
||||||
|
|
||||||
|
var o = await biz.GetAsync(id);
|
||||||
|
|
||||||
|
//turn into correct format and then send as file
|
||||||
|
if (o == null)
|
||||||
|
{
|
||||||
|
return NotFound(new ApiErrorResponse(ApiErrorCode.NOT_FOUND));
|
||||||
|
}
|
||||||
|
var asText = Newtonsoft.Json.JsonConvert.SerializeObject(o, Newtonsoft.Json.Formatting.None);
|
||||||
|
var bytes = System.Text.Encoding.UTF8.GetBytes(asText);
|
||||||
|
var file = new FileContentResult(bytes, "application/octet-stream");
|
||||||
|
file.FileDownloadName = o.Name + ".json";
|
||||||
|
return file;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#if (DEBUG)
|
#if (DEBUG)
|
||||||
public class TranslationCoverageInfo
|
public class TranslationCoverageInfo
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user