private async void SetInProgress()
        {
            try
            {
                //var userId = userID;
                //var pushtoken = pushToken;
                Common common = new Common();
                common.UserID = 1;
                SendUDIDEntityResponse _response = new SendUDIDEntityResponse();
                _response.Response = new Responses();

                string s = JsonConvert.SerializeObject(common);
                HttpResponseMessage response = null;
                string uri = "http://noti.fit:130/api/Workout/StatusInProgress?WorkoutId=" + WorkOutId;
                using (var stringContent = new StringContent(s, System.Text.Encoding.UTF8, "application/json"))
                {
                    string     token  = Settings.TokenCode;
                    HttpClient client = new HttpClient();
                    client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token);

                    response = await client.PostAsync(uri, stringContent);

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

                        _response = JsonConvert.DeserializeObject <SendUDIDEntityResponse>(SucessResponse);
                    }
                    else
                    {
                        var ErrorResponse = await response.Content.ReadAsStringAsync();

                        _response.Response.Message = JsonConvert.DeserializeObject <string>(ErrorResponse);
                        DependencyService.Get <IToast>().Show("Token error");
                    }
                }
            }
            catch (Exception ex)
            {
                var msg = ex.Message;
            }
        }
示例#2
0
        public async void Delete_Click(object sender, EventArgs e)
        {
            bool res = await DisplayAlert("Alert", "Are you sure you want to delete this Schedule?", "Yes", "No");

            if (res == true)
            {
                await Navigation.PushPopupAsync(new LoadingPopPage());

                Button btndelete = ((Button)sender);
                Label  lblDesc   = ((Label)(((Grid)btndelete.Parent).Children.ToList().ElementAt(0)));

                string desc = lblDesc.Text;

                var    item       = result.scheduleLists.Where(x => x.Description.Equals(desc)).FirstOrDefault();
                int    ScheduleId = item.ScheduleId;
                Common common     = new Common();
                common.UserID = 1;
                SendUDIDEntityResponse _response = new SendUDIDEntityResponse();
                _response.Response = new Responses();

                string s = JsonConvert.SerializeObject(common);
                HttpResponseMessage response = null;
                string uri = "http://noti.fit:130/api/Schedule/DeleteSchedule/" + ScheduleId;
                using (var stringContent = new StringContent(s, System.Text.Encoding.UTF8, "application/json"))
                {
                    string     token  = Settings.TokenCode;
                    HttpClient client = new HttpClient();
                    client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token);

                    response = await client.PostAsync(uri, stringContent);

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

                        _response = JsonConvert.DeserializeObject <SendUDIDEntityResponse>(SucessResponse);
                        LoadSchdeuleListing();
                        await Navigation.PopAllPopupAsync();

                        DependencyService.Get <IToast>().Show("Successfully Removed");

                        //result.scheduleLists.Remove(item);


                        //WorkoutList.ItemsSource = result.scheduleLists;
                        //WorkoutList.IsRefreshing = true;
                        //WorkoutList.BeginRefresh();
                    }
                    else
                    {
                        var ErrorResponse = await response.Content.ReadAsStringAsync();

                        _response.Response.Message = JsonConvert.DeserializeObject <string>(ErrorResponse);
                        DependencyService.Get <IToast>().Show("Failed");
                    }
                }
            }
            else
            {
            }
        }