예제 #1
0
        public async Task <UserResponse> UpdateHealthInfor(HealthInfor userInfo, string token)
        {
            var httpClient = new HttpClient(new HttpLoggingHandler())
            {
                BaseAddress = URL_LOGIN
            };

            httpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token);
            var userApi = RestService.For <UserApi>(httpClient);
            var request = new ProvideInforRequest
            {
                healthHeight     = userInfo.height,
                healthWeight     = userInfo.weight,
                ic               = userInfo.ic,
                healthProfession = userInfo.profession,
                bodyMass         = userInfo.bodyMass,
                habit            = userInfo.habit,
                lifeStyle        = userInfo.basicLifeStyle,
                bmi              = userInfo.bmi,
                fatContent       = userInfo.fat,
                stomachFat       = userInfo.stomachFat,
                muscleContent    = userInfo.muscle
            };

            return(await userApi.UpdateHealthInformation(request).ConfigureAwait(false));
        }
 public void UpdateHealthInfor(HealthInfor health)
 {
     //List<Appointment> list = new List<Appointment>();
     Task.Factory.StartNew(() => dataManager.GetUserRepository().UpdateHealthInformation(health, dataManager.GetToken()))
     .ContinueWith(task =>
     {
         //m_view.updateListService(services);
     }, TaskScheduler.FromCurrentSynchronizationContext());
 }
        public Dictionary <int, string> UpdateHealthInformation(HealthInfor user, string token)
        {
            var response = userService.UpdateHealthInfor(user, token);
            Dictionary <int, string> resp = new Dictionary <int, string>();

            try
            {
                response.Wait();
                return(resp);
            }
            catch (Exception e)
            {
                Debug.WriteLine(e.StackTrace);
                resp.Add(500, token);
                return(resp);
            }
        }
        public HealthInfor GetHealthInformation(string token)
        {
            var response = userService.GetHealthInfor(token);

            //string token = "";

            try
            {
                response.Wait();
                HealthInfor healthInfor = new HealthInfor(response.Result);
                return(healthInfor);
            }
            catch (Exception e)
            {
                //Debug.WriteLine("Request Timeout");
                Debug.WriteLine(e.StackTrace);
                return(null);
            }
        }
예제 #5
0
        //public void UpdateHealthInfor(HealthInfor health)
        //{
        //    //List<Appointment> list = new List<Appointment>();
        //    Task.Factory.StartNew(() => dataManager.GetUserRepository().UpdateHealthInformation(health, dataManager.GetToken()))
        //        .ContinueWith(task =>
        //        {
        //            //m_view.updateListService(services);
        //        }, TaskScheduler.FromCurrentSynchronizationContext());

        //}
        public void ProvideInfor()
        {
            int isValidInfor = CheckInputValid.ProvideInformationCheckInputValid(
                profession, ic, weight, height);

            if (isValidInfor != 0)
            {
                view.OnProvideFailed(400, isValidInfor.ToString());
                return;
            }

            if (!view.IsNavigating && !view.IsPerformingAction && HasValidInput())
            {
                HealthInfor infor = new HealthInfor(
                    profession, ic, weight, height, basicLifeStyle, habit, bodyMass, bmi, fat, muscle, stomachFat);

                view.OnActionStarted();
                var userRepository = dataManager.GetUserRepository();

                Dictionary <int, string> resp = new Dictionary <int, string>();
                Task.Factory.StartNew(() =>
                {
                    resp = userRepository.UpdateHealthInformation(infor, dataManager.GetToken());
                }).ContinueWith(task =>
                {
                    view.OnActionFinished();

                    if (resp.ContainsKey(200))
                    {
                        view.OnNavigationStarted();
                        navigationService.PushPresenter(new MainPresenter(navigationService));
                    }
                    else
                    {
                        view.OnProvideFailed(500, "There was a problem creating your information, please try again later.");
                    }
                }, TaskScheduler.FromCurrentSynchronizationContext());
            }
        }