private Bid MapFromDto(BidDto bid) { return(new Bid() { Accepted = bid.Accepted, Amount = bid.Amount, ReceivedOnUtc = bid.ReceivedOnUtc, Id = bid.Id, Bidder = new Member() { DisplayName = bid.BidderName } }); }
public Bid PlaceBid(Auction auction, double amount) { var url = string.Format("api/auctions/{0}/bids", auction.Id); var dto = new BidDto() { Amount = amount }; var result = this.httpClient.PostAsync(url, new StringContent(JsonConvert.SerializeObject(dto), System.Text.Encoding.UTF8, "application/json")).Result; if (result.IsSuccessStatusCode) { var rawJson = result.Content.ReadAsStringAsync().Result; var responseDto = JsonConvert.DeserializeObject <BidDto>(rawJson); return(this.MapFromDto(responseDto)); } throw new Exception(result.Content.ReadAsStringAsync().Result); }