ApiService 2

public async Task<BaseResponse<List<PlaceDto>>> GetPlaces() { try { HttpResponseMessage result = await HttpClientService.GetAsync($"{hostApi}api/Places"); if (result.IsSuccessStatusCode) { var serializedResponse = await JsonService.GetSerializedResponse<List<PlaceDto>>(result); var response = new BaseResponse<List<PlaceDto>>() { Response = serializedResponse }; response.HttpResponse = result; return response; } else { return new BaseResponse<List<PlaceDto>>() { HttpResponse = result }; } } catch (Exception ex) { return new BaseResponse<List<PlaceDto>>() { HttpResponse = new HttpResponseMessage() { StatusCode = System.Net.HttpStatusCode.BadRequest } }; } } public async Task<BaseResponse<List<PictureDto>>> GetPictures() { try { HttpResponseMessage result = await HttpClientService.GetAsync($"{hostApi}api/Pictures"); if (result.IsSuccessStatusCode) { var serializedResponse = await JsonService.GetSerializedResponse<List<PictureDto>>(result); var response = new BaseResponse<List<PictureDto>>() { Response = serializedResponse }; response.HttpResponse = result; return response; } else { return new BaseResponse<List<PictureDto>>() { HttpResponse = result }; } } catch (Exception ex) { return new BaseResponse<List<PictureDto>>() { HttpResponse = new HttpResponseMessage() { StatusCode = System.Net.HttpStatusCode.BadRequest } }; } } public async Task<BaseResponse<PlaceDto>> UpdatePlace(PlaceDto placeDto) { try { HttpResponseMessage result = await HttpClientService.PutAsync($"{hostApi}api/Places/{placeDto.Id}", placeDto); if (result.IsSuccessStatusCode) { var serializedResponse = await JsonService.GetSerializedResponse<PlaceDto>(result); var response = new BaseResponse<PlaceDto>() { Response = serializedResponse }; response.HttpResponse = result; return response; } else { return new BaseResponse<PlaceDto>() { HttpResponse = result }; } } catch (Exception ex) { return new BaseResponse<PlaceDto>() { HttpResponse = new HttpResponseMessage() { StatusCode = System.Net.HttpStatusCode.BadRequest } }; } }

Be the first to comment

You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.