public async Task <AddDriveResponse> AddDrive(AddDriveRequest request) { string json = JsonConvert.SerializeObject(request, _settings); HttpResponseMessage res = await _client.PutAsync("drive", new StringContent(json, Encoding.UTF8, "application/json")); var content = await res.Content.ReadAsStringAsync(); EnsureSuccessStatusCode(res, content); var addDriveReponse = JsonConvert.DeserializeObject <AddDriveResponse>(content); return(addDriveReponse); }
public async Task <AddDriveResponse> AddDrive(AddDriveRequest request) { AddDriveResponse addDriveResponse = new AddDriveResponse(); try { addDriveResponse = await App.Database.AddDrive(new AddDriveRequest { Dest = request.Dest, Date = request.Date, Driver = request.Driver, Participants = request.Participants }); } catch (Exception e) { await _dialogService.ShowMessage($"The server returned an error: {e.Message}", "Error", "OK", null); } return(addDriveResponse); }