Esempio n. 1
0
        // returns null if no a like users
        public List <int> getSleepSegmentsStatsAveragesFromALikeUsersCombined(string _userId, int userAge, int userHeight, int userWeight, string userGender)
        {
            UserDetailsRepository repo = new UserDetailsRepository();
            UserIdsModel          r    = repo.GetUsersByGenderHeightWeightAndAgeRange(userAge, userHeight, userWeight, userGender);

            if (r.userIds.Count == 0)
            {
                return(null);
            }

            StringBuilder sbs = new StringBuilder();

            foreach (string s in r.userIds)
            {
                sbs.Append(s + ",");
            }
            sbs = sbs.Remove(sbs.Length - 1, 1); //remove the last comma
            string users = sbs.ToString();

            var usersParam = new Parameter("users", users);

            var sleepSegmentsStatsAverages = CallAzureDatabase("GetAverageSleepSegmentsStatsFromUsers", usersParam);

            if (sleepSegmentsStatsAverages == null)
            {
                return(null);
            }

            List <int> averages = JsonConvert.DeserializeObject <List <int> >(sleepSegmentsStatsAverages);

            return(averages);
        }
Esempio n. 2
0
 public static void addUserToUserDetailsTable(UserDetailsRecord userDetails)
 {
     try
     {
         var _userDetailsRepository = new UserDetailsRepository();
         var userRecord             = _userDetailsRepository.SaveUserDetails(userDetails.userId,
                                                                             userDetails.firstName,
                                                                             userDetails.lastName,
                                                                             userDetails.gender,
                                                                             userDetails.age,
                                                                             userDetails.height,
                                                                             userDetails.weight);
         if (userRecord == null)
         {
             throw new Exception("Error inserting user details to UserDetails table");
         }
         return;
     }
     catch (Exception e)
     {
         throw new AzureApiBadResponseCodeExcpetion(e);
     }
 }