public void Init()
        {
            ValidWeight = new WeightPastModel
            {
                Weight = 10
            };

            ValidWeightNew = new WeightNewModel
            {
                Timestamp      = DateTime.Now,
                Weight         = 10,
                PostToFacebook = null,
                PostToTwitter  = null
            };
        }
Exemplo n.º 2
0
        /// <summary>
        /// Prepares the request object to create a new model.
        /// </summary>
        /// <param name="weightToCreate"></param>
        /// <returns></returns>
        private IRestRequest PrepareWeightCreateRequest(WeightNewModel weightToCreate)
        {
            var request = new RestRequest(Method.POST);

            request.Resource = _user.Weight;

            ValidateModel(weightToCreate);

            //Add body to the request
            request.AddParameter(WeightNewModel.ContentType, _tokenManager.DefaultJsonSerializer.Serialize(new
            {
                timestamp        = weightToCreate.Timestamp.ToUniversalTime(),
                bmi              = weightToCreate.Bmi,
                fat_percent      = weightToCreate.FatPercent,
                free_mass        = weightToCreate.FreeMass,
                mass_weight      = weightToCreate.MassWeight,
                weight           = weightToCreate.Weight,
                post_to_twitter  = weightToCreate.PostToTwitter,
                post_to_facebook = weightToCreate.PostToFacebook
            }), ParameterType.RequestBody);
            return(request);
        }
Exemplo n.º 3
0
        public void CreateWeightAsync(Action <string> success, Action <HealthGraphException> failure, WeightNewModel weightToCreate)
        {
            var request = PrepareWeightCreateRequest(weightToCreate);

            _tokenManager.ExecuteCreateAsync(request, success, failure);
        }
Exemplo n.º 4
0
        public string CreateWeight(WeightNewModel weightToCreate)
        {
            var request = PrepareWeightCreateRequest(weightToCreate);

            return(_tokenManager.ExecuteCreate(request));
        }