Beispiel #1
0
        public static async Task <bool> PostIssue <T>(object obj, Android.Content.Context acc) where T : Model.Issue
        {
            if (UserInfoHolder.Status == "blocked")
            {
                Toast.MakeText(acc, "You have been blocked from problem update and cannot post any issue", ToastLength.Long).Show();
                Intent i = new Intent(acc, typeof(FragmentHomeActivity));
                acc.StartActivity(i);
                return(false);
            }
            var issueObj = (T)obj;

            issueObj.isresolved = 0;

            HttpClient client   = new HttpClient();
            var        uri      = baseuri + "/api/issue/postnewissue";
            var        json     = JsonConvert.SerializeObject(obj);
            var        content  = new StringContent(json, Encoding.UTF8, "application/json");
            var        response = await client.PostAsync(uri, content);

            if (response.StatusCode == System.Net.HttpStatusCode.Accepted)
            {
                Intent i = new Intent(acc, typeof(FragmentHomeActivity));


                DataOper.SendNotification(new Model.Notification()
                {
                    notification_title = "Issue Alert", notification_text = issueObj.issueStatement, notification_image = issueObj.IssueImage
                });
                acc.StartActivity(i);

                return(true);
            }
            return(false);
        }
        public static void ProceedToIssueActivity(string selected, Android.Content.Context acc, object obj)
        {
            switch (selected)
            {
            case "pothole":
                DataOper.PutData <createissue3>(acc, obj);
                break;

            case "manhole":
                DataOper.PutData <Manhole1>(acc, obj);
                break;

            case "debris":
                DataOper.PutData <Debris>(acc, obj);
                break;

            case "garbage":
                DataOper.PutData <Garbage>(acc, obj);
                break;

            case "planting":
                DataOper.PutData <PlantingCampaign1>(acc, obj);
                break;

            case "missingvehicle":
                DataOper.PutData <MissingVehicle>(acc, obj);
                break;

            case "rainwater":
                DataOper.PutData <Rainwater>(acc, obj);
                break;

            case "brokenpole":
                DataOper.PutData <BrokenWires>(acc, obj);
                break;
            }
        }