Esempio n. 1
0
        public Upload()
        {
            key = Constants.getAPIKey();

            NavigationPage.SetHasNavigationBar(this, false);
            InitializeComponent();

            propertyUpload = new PropertyUpload();

            BindingContext = propertyUpload;



            MyMap.MoveToRegion(MapSpan.FromCenterAndRadius(new Position(35.6894875, 139.6917064), Distance.FromKilometers(1)));
            MyMap.IsShowingUser     = true;
            MyMap.HorizontalOptions = LayoutOptions.FillAndExpand;
            MyMap.HeightRequest     = 200;


            Position po1 = new Position(35.73200569999999, 139.7668856);

            var pin = new Pin
            {
                Type     = PinType.Place,
                Position = po1,
                Label    = "Nishi-Nippori Station",
                Address  = "Japan, 〒116-0013 Tōkyō-to, Arakawa-ku, Nishinippori, 5 Chome−22, 5 丁目"
            };

            MyMap.Pins.Add(pin);
        }
Esempio n. 2
0
        public static async Task <string> Upload(PropertyUpload propertyUpload)
        {
            try
            {
                string responsestr = "";

                using (var httpClient = new HttpClient())
                {
                    using (MultipartFormDataContent content = new MultipartFormDataContent())
                    {
                        content.Add(new StringContent(propertyUpload.Name), "Name");
                        content.Add(new StringContent("" + propertyUpload.Price), "Price");
                        content.Add(new StringContent(propertyUpload.Latitud + ""), "Latitud");
                        content.Add(new StringContent(propertyUpload.Longitud + ""), "Longitud");
                        content.Add(new StringContent(propertyUpload.Size + ""), "Size");
                        content.Add(new StringContent(propertyUpload.Address), "Address");
                        content.Add(new StringContent(propertyUpload.Rooms + ""), "Rooms");
                        content.Add(new StringContent(propertyUpload.ParkingSlots + ""), "ParkingSlots");
                        content.Add(new StringContent(propertyUpload.Bathrooms + ""), "Bathrooms");
                        content.Add(new StringContent(propertyUpload.Description), "Description");


                        foreach (var file in propertyUpload.Images)
                        {
                            content.Add(new StreamContent(file.GetStream()), "Images", file.FileName);
                        }

                        var response = await httpClient.PostAsync("https://www.vablemporium.com/Images/CreateProperty", content);


                        responsestr = response.Content.ReadAsStringAsync().Result;
                    }
                }

                Debug.WriteLine(responsestr);

                return(responsestr);
            }
            catch (Exception e)
            {
                Debug.WriteLine("Error in POST: " + e.Message);
                Debug.WriteLine("Error in POST: " + e.StackTrace);
                return(null);
            }
        }
Esempio n. 3
0
        private async Task <IFlurlResponse> UploadAsync(PropertyUpload data)
        {
            IFlurlResponse responseHttp = await _odata.WithOAuthBearerToken(token.Content).PostJsonAsync(data);

            string responseBody = await responseHttp.GetStringAsync();

            if (!responseHttp.ResponseMessage.IsSuccessStatusCode && responseHttp.StatusCode != 401)
            {
                _logger.Error($"Bad insert in the database, Message: {responseBody}, StatusCode: {responseHttp.StatusCode}, Json for request: {JsonConvert.SerializeObject(data)}");
            }
            else if (!responseHttp.ResponseMessage.IsSuccessStatusCode && responseHttp.StatusCode == 401)
            {
                await AuthorizeStart();

                return(await UpdateAsync(data));
            }

            return(responseHttp);
        }
Esempio n. 4
0
        public async Task UpdateOrUploadAsync(RealtyObjectsResponse data)
        {
            if (data == null)
            {
                return;
            }

            ODataSelectPropertyRecord flurlSelect = await SelectAsync <ODataSelectPropertyRecord>(data);

            if (flurlSelect == null || flurlSelect?.Value == null || flurlSelect?.Value.Length == 0)
            {
                PropertyUpload propertyUpload = new PropertyUpload(data);
                await UploadAsync(propertyUpload).ConfigureAwait(false);
            }
            else
            {
                foreach (ODataSelectRecord property in flurlSelect.Value)
                {
                    PropertyUpdate propertyUpdate = new PropertyUpdate(data, status: property.Status, propertyId: property.Property);
                    await UpdateAsync(propertyUpdate).ConfigureAwait(false);
                }
            }
        }