protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); SetContentView(Resource.Layout.Review); drawerLayout = FindViewById <DrawerLayout>(Resource.Id.drawer_layout); // Create ActionBarDrawerToggle button and add it to the toolbar var toolbar = FindViewById <V7Toolbar>(Resource.Id.toolbar); SetSupportActionBar(toolbar); var drawerToggle = new ActionBarDrawerToggle(this, drawerLayout, toolbar, Resource.String.drawer_open, Resource.String.drawer_close); drawerLayout.SetDrawerListener(drawerToggle); drawerToggle.SyncState(); navigationView = FindViewById <NavigationView>(Resource.Id.nav_view); setupDrawerContent(navigationView); navigationView.NavigationItemSelected += HomeNavigationView_NavigationItemSelected; zvijezdice = FindViewById <RatingBar>(Resource.Id.ratingBar1); posaljiReviewButton = FindViewById <Button>(Resource.Id.button2); recenzijaText = FindViewById <EditText>(Resource.Id.OpisRezenzije1); string input = Intent.GetStringExtra("rent"); string userinput = Intent.GetStringExtra("user"); najam = JsonConvert.DeserializeObject <Data_classes.Rent>(input); korisnik = JsonConvert.DeserializeObject <List <User> >(userinput); posaljiReviewButton.Click += (b, e) => { if (recenzijaText.Text != null) { korisnik = JsonConvert.DeserializeObject <List <User> >(userinput); var klijent = new RestClient("http://marichely.m/"); var zahtjev = new RestRequest("reviews", Method.POST); zahtjev.RequestFormat = DataFormat.Json; zahtjev.AddHeader("rentid", najam.Rentid.ToString()); zahtjev.AddHeader("userapikey", korisnik[0].ApiKey); CreateReview posalji = new CreateReview(); posalji.Description = recenzijaText.Text; posalji.Stars = zvijezdice.NumStars; string test = JsonConvert.SerializeObject(posalji); zahtjev.AddParameter("text/json", test, ParameterType.RequestBody); //text/json IRestResponse odgovor = klijent.Execute(zahtjev); if ((int)odgovor.StatusCode == 200) { Toast.MakeText(this, "Review Sent", ToastLength.Short).Show(); } } }; }
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); SetContentView(Resource.Layout.IncidentReport); drawerLayout = FindViewById <DrawerLayout>(Resource.Id.drawer_layout); // Create ActionBarDrawerToggle button and add it to the toolbar var toolbar = FindViewById <V7Toolbar>(Resource.Id.toolbar); SetSupportActionBar(toolbar); var drawerToggle = new ActionBarDrawerToggle(this, drawerLayout, toolbar, Resource.String.drawer_open, Resource.String.drawer_close); drawerLayout.SetDrawerListener(drawerToggle); drawerToggle.SyncState(); navigationView = FindViewById <NavigationView>(Resource.Id.nav_view); setupDrawerContent(navigationView); navigationView.NavigationItemSelected += HomeNavigationView_NavigationItemSelected; string input = Intent.GetStringExtra("rent"); string userinput = Intent.GetStringExtra("user"); najam = JsonConvert.DeserializeObject <Data_classes.Rent>(input); user = JsonConvert.DeserializeObject <List <User> >(userinput); //RequestWindowFeature(WindowFeatures.NoTitle); //SetContentView(Resource.Layout.PrijavaIncidenta); Button prijaviinc = FindViewById <Button>(Resource.Id.posaljiIncident); odaberiSliku = FindViewById <ImageButton>(Resource.Id.odaberiSliku); EditText opis = FindViewById <EditText>(Resource.Id.Incidenttekst); prijaviinc.Click += (e, s) => { RemoveRent slanje = new RemoveRent(); slanje.IssueDesc = opis.Text; slanje.RentID = najam.Rentid; var klijent = new RestClient("http://marichely.me/"); var zahtjev = new RestRequest("rolling/issues", Method.POST); zahtjev.RequestFormat = DataFormat.Json; zahtjev.AddParameter("text/json", JsonConvert.SerializeObject(slanje), ParameterType.RequestBody); zahtjev.AddHeader("userapikey", user[0].ApiKey); IRestResponse odgovor = klijent.Execute(zahtjev); zahtjev = new RestRequest("issues/pictures", Method.POST); if ((int)odgovor.StatusCode == 200) { Toast.MakeText(this, "Successfully created the incident", ToastLength.Short).Show(); string issueid = odgovor.Content; if (path != null) { zahtjev = new RestRequest("issues/pictures", Method.POST); zahtjev.RequestFormat = DataFormat.Json; zahtjev.AddHeader("userapikey", user[0].ApiKey); zahtjev.AddHeader("incident", issueid); zahtjev.AddFile("picture", path); IRestResponse odgovor2 = klijent.Execute(zahtjev); if ((int)odgovor2.StatusCode == 200) { Toast.MakeText(this, "Successfully created the incident", ToastLength.Short).Show(); } } } }; odaberiSliku.Click += (s, e) => { var imageIntent = new Intent(); imageIntent.SetType("image/*"); imageIntent.SetAction(Intent.ActionGetContent); StartActivityForResult( Intent.CreateChooser(imageIntent, "Select photo"), 0); }; }
public void SaveRent() { string text = Intent.GetStringExtra("user") ?? "Data not available"; var user = JsonConvert.DeserializeObject <List <User> >(text); var latitudes = Intent.GetStringExtra("latitude") ?? "Data not available"; var longers = Intent.GetStringExtra("longitude") ?? "Data not available"; Data_classes.Location sda = new Data_classes.Location { Latitude = latitudes, Longitude = longers, LocationG = "Current location", Bicycle = bicObj }; RestClient client3 = new RestClient("http://marichely.me:8099/"); RestRequest request3 = new RestRequest("bicycle/location", Method.POST); request3.RequestFormat = DataFormat.Json; request3.AddHeader("userapikey", user[0].ApiKey); string test1 = JsonConvert.SerializeObject(sda); request3.AddParameter("application/json", test1, ParameterType.RequestBody); IRestResponse odgovor3 = client3.Execute(request3); if ((int)odgovor3.StatusCode == 200) { var locate = JsonConvert.DeserializeObject <Data_classes.Location>(odgovor3.Content); } Data_classes.Rent ds = new Data_classes.Rent(); ds.Bicycle = bicObj; var bicIdstat = ds.Bicycle.Bicycleid; DateTime now = DateTime.UtcNow; ds.Date_from = now.ToString("yyyy-MM-ddTHH\\:mm\\:ssZ"); ds.Date_to = now.AddDays(rentDays).ToString("yyyy-MM-ddTHH\\:mm\\:ssZ"); ds.Status = 1; ds.User = user[0]; ds.Location = sda; RestClient client4 = new RestClient("http://marichely.me:8099/"); RestRequest request4 = new RestRequest("bicycle/update", Method.POST); request4.RequestFormat = DataFormat.Json; request4.AddHeader("userapikey", user[0].ApiKey); request4.AddQueryParameter("bicycleid", bicId.ToString()); request4.AddQueryParameter("status", "1"); IRestResponse odgovor4 = client4.Execute(request4); if ((int)odgovor4.StatusCode == 200) { var bicstat = JsonConvert.DeserializeObject <Data_classes.Bicycle>(odgovor4.Content); Toast.MakeText(this, ("Successfully changed status of bicycle!" + ds.Bicycle.Name), ToastLength.Short).Show(); } RestClient client2 = new RestClient("http://marichely.me:8099/"); RestRequest request2 = new RestRequest("rent", Method.POST); request2.RequestFormat = DataFormat.Json; request2.AddHeader("userapikey", user[0].ApiKey); string test3 = JsonConvert.SerializeObject(ds); request2.AddParameter("application/json", test3, ParameterType.RequestBody); IRestResponse odgovor2 = client2.Execute(request2); if ((int)odgovor2.StatusCode == 200) { var rentObj2 = JsonConvert.DeserializeObject <Data_classes.Rent>(odgovor2.Content); Toast.MakeText(this, ("Successfully rented a bicycle: " + ds.Bicycle.Name), ToastLength.Short).Show(); } }