コード例 #1
0
        private async Task <VolumeResult> InsertVolumeResult(VolumeResult volumeResultToInsert)
        {
            using (VolumeDBContext dbContext = new VolumeDBContext())
            {
                await dbContext.VolumeResults.AddAsync(volumeResultToInsert);

                await dbContext.SaveChangesAsync();
            }

            return(volumeResultToInsert);
        }
コード例 #2
0
        public async Task <VolumeResult> SaveAndGetVolumeResult(decimal height, decimal radius, Type type)
        {
            VolumeResult volumeResult = new VolumeResult {
                Height = height, Radius = radius, Type = type
            };
            var content = new StringContent(JsonSerializer.Serialize(volumeResult), Encoding.UTF8, "application/json");

            var response =
                await _httpClient.PostAsync(
                    $"calculate/{(type == Type.Cone ? "cone" : "cylinder")}?height={height}&radius={radius}", null);

            return(JsonSerializer.Deserialize <VolumeResult>(await response.Content.ReadAsStringAsync()));
        }