Esempio n. 1
0
        public async Task <TModel> Read(int id, string date)
        {
            JObject json = await APIUtils.GetAsync(IPConfig.GetTotalUrlUser() + id + JsonDataConfig.Url +
                                                   EndUrl(Request, date));

            return((json == null) ? null : (json[JsonDataConfig.Root] as JObject)?.GetObject <TModel>());
        }
        public async Task <object> Update(int id, string day, [FromBody] MealKendo item)
        {
            JObject jsonMeal = JObject.Parse(JsonConvert.SerializeObject
                                                 (Meal.CreateFromOptionKendoList(item), serializerSettings));

            var jsonMealDay = new JObject
            {
                { JsonDataConfig.Key[0], day },
                { JsonDataConfig.Key[1], new JArray()
                  {
                      jsonMeal
                  } }
            };
            var jsonMealDays = new JArray
            {
                jsonMealDay
            };
            var jsonDiet = new JObject
            {
                { JsonDataConfig.Root, jsonMealDays }
            };

            await APIUtils.PostAsync(IPConfig.GetTotalUrlUser() + id + JsonDataConfig.Url, jsonDiet.ToString());

            return(Empty);
        }
Esempio n. 3
0
        public async Task <object> Update(int id, [FromBody] Models.PatientData.GoalCaloriesOut item)
        {
            var goalCaloriesJson = new JObject
            {
                { JsonDataConfig.Root, JObject.Parse(JsonConvert.SerializeObject(item, serializerSettings)) }
            };

            await APIUtils.PostAsync(IPConfig.GetTotalUrlUser() + id + JsonDataConfig.Url, goalCaloriesJson.ToString());

            return(Empty);
        }
Esempio n. 4
0
        public async Task <IEnumerable <TrainingKendo> > Read(int id)
        {
            JObject jsonTraining = await APIUtils.GetAsync(IPConfig.GetTotalUrlUser() + id + JsonDataConfig.Url);

            List <Models.Training> trainings = ((JArray)jsonTraining[JsonDataConfig.Root]).GetList <Models.Training>();

            List <TrainingKendo> trainingsKendo = new List <TrainingKendo>();

            trainings.ForEach(x => trainingsKendo.Add(TrainingKendo.CreateFromOptionList(x)));

            return(trainingsKendo);
        }
        public async Task <IEnumerable <MealKendo> > Read(int id, string day)
        {
            JObject jsonDiet = await APIUtils.GetAsync(IPConfig.GetTotalUrlUser() + id + JsonDataConfig.Url);

            JObject     jsonDietDay = (JObject)jsonDiet[JsonDataConfig.Root].FirstOrDefault(x => x[JsonDataConfig.Key[0]].ToString() == day);
            List <Meal> meals       = ((JArray)jsonDietDay[JsonDataConfig.Key[1]]).GetList <Meal>();

            List <MealKendo> mealsKendo = new List <MealKendo>();

            meals.ForEach(x => mealsKendo.Add(MealKendo.CreateFromOptionList(x)));

            return(mealsKendo);
        }
        public async Task <object> Update(int id, [FromBody] GoalStepsDaily item)
        {
            var GoalsStepsDailyConfig = JsonDataConfig as GoalsStepsDaily;
            var goalStepsJson         = new JObject
            {
                { GoalsStepsDailyConfig.RootUpdate, JObject.Parse(JsonConvert.SerializeObject(item, serializerSettings)) }
            };

            await APIUtils.PostAsync(IPConfig.GetTotalUrlUser() + id + GoalsStepsDailyConfig.UrlUpdate + "?"
                                     + QueryParamsConfig.Period + "=" + GoalsStepsDailyConfig.Period, goalStepsJson.ToString());

            return(Empty);
        }
        public async Task <object> Update(int id, [FromBody] GoalWeight item)
        {
            item.StartDate   = DateTimeNow;
            item.StartWeight = (await new WeightController(IPConfig, JsonStructureConfig).
                                Read(id, DateTimeNow.ToString(italianDateFormat))).Weight;

            var jsonGoalWeight = new JObject
            {
                { JsonDataConfig.Root, JObject.Parse(JsonConvert.SerializeObject(item, serializerSettings)) }
            };

            await APIUtils.PostAsync(IPConfig.GetTotalUrlUser() + id + JsonDataConfig.Url, jsonGoalWeight.ToString());

            return(Empty);
        }
Esempio n. 8
0
        public async Task <List <TModel> > Read(int id, string date, string period)
        {
            JObject listJson = await APIUtils.GetAsync(IPConfig.GetTotalUrlUser() + id + JsonDataConfig.Url +
                                                       EndUrl(Request, date, period));

            if (listJson == null)
            {
                return(new List <TModel>());
            }

            return((listJson[JsonDataConfig.Root] as JArray)?.GetList <TModel>() ??
                   new List <TModel>
            {
                (listJson[JsonDataConfig.Root] as JObject)?.GetObject <TModel>()
            });
        }
Esempio n. 9
0
        public async Task <object> Update(int id, [FromBody] TrainingKendo item)
        {
            JObject jsonDayTrainings = JObject.Parse(JsonConvert.SerializeObject
                                                         (Models.Training.CreateFromOptionKendoList(item), serializerSettings));

            var jsonTrainings = new JObject
            {
                { JsonDataConfig.Root, new JArray()
                  {
                      jsonDayTrainings
                  } }
            };

            await APIUtils.PostAsync(IPConfig.GetTotalUrlUser() + id + JsonDataConfig.Url, jsonTrainings.ToString());

            return(Empty);
        }