Esempio n. 1
0
        public async Task <IActionResult> OnPostExportAsync()
        {
            if (!await GetModifyAuthorization())
            {
                return(Forbid());
            }
            if (!ModelState.IsValid)
            {
                return(BadRequest());
            }

            HttpClient     httpclient = clientFactory.CreateClient();
            ProblemsClient client     = new ProblemsClient(httpclient);

            try
            {
                Core.Problems.ProblemPackage package = await client.ExportAsync(PostData.Metadata.Id);

                string str = Newtonsoft.Json.JsonConvert.SerializeObject(package);
                return(File(Encoding.UTF8.GetBytes(str), "text/plain", $"{PostData.Metadata.Id}.json"));
            }
            catch
            {
                return(NotFound());
            }
        }