Exemple #1
0
        private static async Task MigrateRarety()
        {
            using StreamReader reader       = new StreamReader(Path.Combine(Directory.GetCurrentDirectory(), "Migrate", "rarete.json"));
            using JsonTextReader jsonReader = new JsonTextReader(reader);

            jsonReader.SupportMultipleContent = true;

            JsonSerializer serializer = new JsonSerializer();

            while (jsonReader.Read())
            {
                if (jsonReader.TokenType == JsonToken.StartObject)
                {
                    RaretyCreationModel rarety = serializer.Deserialize <RaretyCreationModel>(jsonReader);
                    Console.WriteLine(JsonConvert.SerializeObject(rarety));
                    string json = JsonConvert.SerializeObject(rarety);
                    using (WebClient webClient = new WebClient())
                    {
                        webClient.Headers.Add("Accept", "text/json");
                        webClient.Headers.Add("Content-Type", "text/json");
                        await webClient.UploadDataTaskAsync(new Uri($"{URL}/api/species/rarety"), Encoding.UTF8.GetBytes(json));
                    }
                }
            }
        }
 public async Task UpdateRaretySpeciesAsync([FromBody] RaretyCreationModel model)
 {
     await this.SpeciesManager.UpdateSpeciesRarety(
         new Species
         { SpeciesName = model.Value,
           Rarity      = model.Rarety,
           Difficult   = 2 });
 }