Beispiel #1
0
        static async Task RunAsync()
        {
            StartSvcClient stsvc = new StartSvcClient("https://localhost:44378/");
            StartRecord    stRec = await stsvc.GetStartRecordAsync(1);

            StartRecord stRec2 = new StartRecord {
                Value = 3002
            };
            StartRecord stRec3 = await stsvc.CreateStartRecordAsync(stRec2);
        }
        public async Task <StartRecord> GetStartRecordAsync(int id)
        {
            StartRecord         rec      = null;
            HttpResponseMessage response = await client.GetAsync($"api/StartRecords/{id}");

            if (response.IsSuccessStatusCode)
            {
                rec = await response.Content.ReadAsAsync <StartRecord>();
            }

            return(rec);
        }
        public async Task <StartRecord> CreateStartRecordAsync(StartRecord stRec)
        {
            StartRecord         rec      = null;
            HttpResponseMessage response = await client.PostAsJsonAsync(
                "api/StartRecords", stRec);

            response.EnsureSuccessStatusCode();

            // return URI of the created resource.
            //return response.Headers.Location;\
            if (response.IsSuccessStatusCode)
            {
                rec = await response.Content.ReadAsAsync <StartRecord>();
            }
            return(rec);
        }