예제 #1
0
        public async Task <ActionResult> Post([FromBody] RealEstateDto value)
        {
            var realEstateAd = new RealEstate
            {
                Title       = value.Title,
                Description = value.Description,
                Surface     = value.Surface,
                Price       = value.Price
            };
            await _realEstateAdRepository.InsertAsync(realEstateAd);

            return(Json(realEstateAd));
        }
        public async Task <bool> CreateRealestate(int userid, RealEstateDto realestate, string token)
        {
            string sUrl = _ApiUrlBase + $"api/RealEstates";

            string RealEstateJson = JsonConvert.SerializeObject(realestate);

            var stringContent = new StringContent(RealEstateJson, Encoding.UTF8, "application/json");

            _httpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token);
            var response = await _httpClient.PostAsync(sUrl, stringContent);

            Console.WriteLine(response);
            return(true);
        }