Exemplo n.º 1
0
        public async Task <bool> BulkSaveFavorites(DtoAccount account)
        {
            SqliteDatabase sqlite          = new SqliteDatabase();
            var            sqlitefavorites = await sqlite.GetFavorites();

            string             apiUrl  = string.Format("https://{0}/api/favorite/{1}/bulk", databaseAPIIP, account.Id);
            Uri                uri     = new Uri(string.Format(apiUrl, string.Empty));
            HttpRequestMessage request = new HttpRequestMessage
            {
                Method     = HttpMethod.Post,
                RequestUri = uri,
                Content    = new StringContent(JsonConvert.SerializeObject(sqlitefavorites), Encoding.UTF8, "application/json")
            };
            var response = await client.SendAsync(request).ConfigureAwait(false);

            if (response.IsSuccessStatusCode)
            {
                var content = await response.Content.ReadAsStringAsync();

                var success = JsonConvert.DeserializeObject <bool>(content);

                return(success);
            }
            return(false);
        }