public static string PutPostIssue(MainActivity.IssuesContainer.Issue currIssue, bool isNew = false, string addNotes = null) { RestRequest request; if (isNew == false) { request = new RestRequest("/issues/" + currIssue.id + ".json", Method.PUT); } else { request = new RestRequest("/issues.json", Method.POST); } request.RequestFormat = DataFormat.Json; request.AddJsonBody(new { issue = new { project_id = currIssue.project.id, priority_id = currIssue.priority.id, status_id = currIssue.status.id, start_date = currIssue.start_date, tracker_id = currIssue.tracker.id, due_date = currIssue.due_date, assigned_to_id = currIssue.assigned_to.id, subject = currIssue.subject, description = currIssue.description, estimated_hours = currIssue.estimated_hours, done_ratio = currIssue.done_ratio, notes = addNotes ?? null } }); request.RootElement = "issue"; request.AddHeader("content-type", "application/json"); RestResponse response = (RestResponse)client.Execute(request); return(response.Content); }
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); SetContentView(Resource.Layout.time_entry_layout); toolbar = FindViewById <Toolbar>(Resource.Id.toolbar); toolbar.SetTitle(Resource.String.TimeEntries); SetSupportActionBar(toolbar); pd = new ProgressDialog(this); issue = RedMineManager.Get <IssuesContainer.Issue>("/issues/" + Intent.GetIntExtra("IssueID", 0) + ".json", "issue"); issue.timeEntries = RedMineManager.Get <List <IssuesContainer.TimeEntry> >("/issues/" + Intent.GetIntExtra("IssueID", 0) + "/time_entries.json?nometa=1", "time_entries"); PBProgress = FindViewById <ProgressBar>(Resource.Id.progress); TVSpentTime = FindViewById <TextView>(Resource.Id.spent_time); TVEstimatedTime = FindViewById <TextView>(Resource.Id.estimated_time); BPlay = FindViewById <ImageView>(Resource.Id.play); BStop = FindViewById <ImageView>(Resource.Id.stop); BPause = FindViewById <ImageView>(Resource.Id.pause); LLRoot = FindViewById <LinearLayout>(Resource.Id.root); RLConfirm = FindViewById <RelativeLayout>(Resource.Id.confirm); RLConfirm.Visibility = ViewStates.Gone; ETComment = FindViewById <EditText>(Resource.Id.comment); BSubmit = FindViewById <Button>(Resource.Id.submit); spentTime = TimeSpan.FromHours(issue.spent_hours); newSpentTime = new TimeSpan(); estimatedTime = TimeSpan.FromHours(issue.estimated_hours); float r = (float)spentTime.Ticks / (float)estimatedTime.Ticks; PBProgress.Progress = Convert.ToInt32((float)r * (float)100); ShowTimeEntries(); progress = new Thread(() => { HandleSpentTime(); }); BPlay.Click += delegate { progress.Start(); BPlay.Visibility = ViewStates.Gone; BStop.Visibility = ViewStates.Visible; }; BPause.Click += delegate { if (progress.IsAlive) { progress.Suspend(); } else { progress.Resume(); } }; BStop.Click += delegate { RLConfirm.Visibility = ViewStates.Visible; progress.Abort(); }; BSubmit.Click += delegate { IssuesContainer.TimeEntry t = new IssuesContainer.TimeEntry(); t.issue = issue; t.comments = ETComment.Text; t.hours = newSpentTime.TotalHours; BPlay.Visibility = ViewStates.Visible; BStop.Visibility = ViewStates.Gone; Toast.MakeText(this, RedMineManager.PutPostTimeEntry(t, true), ToastLength.Short).Show(); Recreate(); }; TVSpentTime.Text = spentTime.ToString(); TVEstimatedTime.Text = estimatedTime.ToString(); }