public ApiController(AppDbContext context, RestrictionService restriction, IParseAsyncService parseAsync, IStringCompressService compress) { this.context = context; this.restriction = restriction; this.parseAsync = parseAsync; this.compress = compress; }
public IActionResult ViewConversion(int?id, [FromServices] IStringCompressService compress) { if (id is null) { return(BadRequest()); } var conversion = context.Conversions.FirstOrDefault(c => c.Id == id); if (conversion is null) { return(NotFound()); } var result = new { Initial = compress.Decompress(conversion.Initial), Result = compress.Decompress(conversion.Result) }; return(Content(JsonConvert.SerializeObject(result), ContentTypeJson)); }