private Auction MapFromDto(AuctionDto dto)
 {
     return(new Auction()
     {
         Id = dto.Id,
         Title = dto.Title,
         CurrentPrice = dto.CurrentPrice,
         CloseDateTimeUtc = dto.CloseDateTimeUtc,
         StartDateTimeUtc = dto.StartDateTimeUtc,
         StartPrice = dto.StartPrice,
         IsClosed = dto.IsClosed,
         IsRunning = dto.IsRunning,
         Description = dto.Description,
         EndDateTimeUtc = dto.EndDateTimeUtc,
         ActiveBid = new Bid()
         {
             Bidder = new Member()
             {
                 DisplayName = dto.CurrentWinnerName
             }
         },
         Winner = new Member()
         {
             DisplayName = dto.CurrentWinnerName
         },
         Seller = new Member()
         {
             DisplayName = dto.SellerName
         },
         Image = this.GetAuctionImage(dto.Id),
         Bids = this.MapFromDto(dto.Bids),
     });
 }
        public Auction Save(Auction auction)
        {
            var url = "api/auctions/";

            var dto = new AuctionDto()
            {
                StartPrice       = auction.StartPrice,
                StartDateTimeUtc = auction.StartDateTimeUtc,
                EndDateTimeUtc   = auction.EndDateTimeUtc,
                Title            = auction.Title,
                Description      = auction.Description,
            };

            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 <AuctionDto>(rawJson);

                // Post Image
                if (auction.Image != null)
                {
                    this.SendAuctionImage(responseDto.Id, auction.Image);
                }

                return(this.MapFromDto(responseDto));
            }

            throw new Exception(result.Content.ReadAsStringAsync().Result);
        }