예제 #1
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            // Create your application here
            SetContentView(Resource.Layout.AdPreview);
            AdImage             = FindViewById <ImageView>(Resource.Id.imgIssue);
            adTitle             = FindViewById <TextView>(Resource.Id.adtitle);
            adText              = FindViewById <TextView>(Resource.Id.adtext);
            submitButton        = FindViewById <Button>(Resource.Id.adsubmit);
            submitButton.Click += SubmitButton_Click;

            string base64Image = JsonConvert.DeserializeObject <string>(Intent.GetStringExtra("baseimage"));
            string adtitle     = JsonConvert.DeserializeObject <string>(Intent.GetStringExtra("adtitle"));
            string adtext      = JsonConvert.DeserializeObject <string>(Intent.GetStringExtra("adtext"));
            int    budget      = JsonConvert.DeserializeObject <int>(Intent.GetStringExtra("adbudget"));
            string link        = JsonConvert.DeserializeObject <string>(Intent.GetStringExtra("link"));

            data             = new AdsData();
            data.Adsimage    = base64Image;
            data.Adstitle    = adtitle;
            data.Adstext     = adtext;
            data.Amount      = budget;
            data.websitelink = link;

            var    arr    = Convert.FromBase64String(base64Image);
            Bitmap bitmap = BitmapFactory.DecodeByteArray(arr, 0, arr.Length);

            AdImage.SetImageBitmap(bitmap);
            adTitle.Text = data.Adstitle;
            adText.Text  = data.Adstext;
        }
예제 #2
0
        public async Task <bool> StoreAd(AdsData data)
        {
            var        uri      = Control.Account.BaseAddressUri + "/api/issue/storead";
            HttpClient client   = new HttpClient();
            var        json     = JsonConvert.SerializeObject(data);
            var        content  = new StringContent(json, Encoding.UTF8, "application/json");
            var        response = await client.PostAsync(uri, content);

            if (response.StatusCode == System.Net.HttpStatusCode.Accepted)
            {
                return(true);
            }
            return(false);
        }
예제 #3
0
 private async Task <List <AdsData> > InitAds()
 {
     return(await AdsData.GetAllAds());
 }