示例#1
0
        public static HttpResponseMessage Run(
            [HttpTrigger(AuthorizationLevel.Function, "get", "post", Route = null)] HttpRequestMessage req, TraceWriter log)
        {
            var userParameters = AbstractRequest.GetParameter(req, "userId");
            var result         = new ComparisonProvider(new BoostRepository()).GetUserComparison(userParameters);

            return(AbstractRequest.SerializeRespone(req, result));
        }
        public static HttpResponseMessage Run(
            [HttpTrigger(AuthorizationLevel.Function, "get", "post", Route = null)] HttpRequestMessage req, ILogger log)
        {
            string action = AbstractRequest.GetParameter(req, "action");

            switch (action)
            {
            /* Single requests */

            case "SaveUser":
                return(new ManageUsers().Save(req, log));

            case "GetUser":
                return(new ManageUsers().Get(req, log));

            case "RemoveUser":
                return(new ManageUsers().Remove(req, log));

            case "SaveUserDetails":
                return(new UserDetails().Save(req, log));

            case "GetUserDetails":
                return(new UserDetails().Get(req, log));

            case "GetUsersByGender":
                return(new UserDetails().GetUserIdsByGender(req, log));

            case "GetUsersByAgeRange":
                return(new UserDetails().GetUserIdsByAgeRange(req, log));

            case "GetUsersByGenderAndAgeRange":
                return(new UserDetails().GetUserIdsByGenderAndAgeRange(req, log));

            case "GetUsersByGenderHeightAndWeight":
                return(new UserDetails().GetUserIdsByGenderHeightAndWeight(req, log));

            case "GetUsersByGenderHeightWeightAndAgeRange":
                return(new UserDetails().GetUserIdsByGenderHeightWeightAndAgeRange(req, log));

            case "RemoveUserDetails":
                return(new UserDetails().Remove(req, log));

            case "GetUserAwakeningAccuracy":
                return(new AwakeningAccuracy().Get(req, log));

            case "SaveUserAwakeningAccuracy":
                return(new AwakeningAccuracy().Save(req, log));

            case "GetUserSleepSegmentsStats":
                return(new SleepSegmentsStats().Get(req, log));

            case "SaveUserSleepSegmentsStats":
                return(new SleepSegmentsStats().Save(req, log));

            case "UpdateUserSleepSegmentsStats":
                return(new SleepSegmentsStats().Update(req, log));

            case "GetAverageSleepSegmentsStatsFromUsers":
                return(new SleepSegmentsStats().GetAverageSleepSegmentsStatsFromUsers(req, log));

            case "GetUserSleepQuality":
                return(new SleepQuality().Get(req, log));

            case "SaveUserSleepQuality":
                return(new SleepQuality().Save(req, log));

            case "UpdateUserSleepQuality":
                return(new SleepQuality().Update(req, log));

            case "GetIsUserInTopTenUsersBySleepEfficiency":
                return(new SleepQuality().GetIsUserInTopTenUsersBySleepEfficiency(req, log));

            case "GetIsUserInTopFiveUsersBySleepEfficiency":
                return(new SleepQuality().GetIsUserInTopFiveUsersBySleepEfficiency(req, log));

            case "GetIsUserInTopTenUsersByWakeUps":
                return(new SleepQuality().GetIsUserInTopTenUsersByWakeUps(req, log));

            case "GetIsUserInTopFiveUsersByWakeUps":
                return(new SleepQuality().GetIsUserInTopFiveUsersByWakeUps(req, log));

            case "GetAverageWakeUpsForUsers":
                return(new SleepQuality().GetAverageWakeUpsForUsers(req, log));

            case "GetAverageSleepEfficiencyForUsers":
                return(new SleepQuality().GetAverageSleepEfficiencyForUsers(req, log));

            default:
                return(req.CreateResponse(HttpStatusCode.BadRequest, "Unknown action"));
            }
        }
示例#3
0
        public static HttpResponseMessage Run(
            [HttpTrigger(AuthorizationLevel.Function, "get", "post", Route = null)] HttpRequestMessage req, TraceWriter log)
        {
            string action = AbstractRequest.GetParameter(req, "action");

            switch (action)
            {
            /*
             * Single requests
             */
            case "SaveUserType":
                return(new UserType().Save(req, log));

            case "GetUserType":
                return(new UserType().Get(req, log));

            case "RemovePlayerType":
                return(new UserType().Remove(req, log));

            case "SavePlayer":
                return(new Player().Save(req, log));

            case "GetPlayer":
                return(new Player().Get(req, log));

            case "RemovePlayer":
                return(new Player().Remove(req, log));

            case "SaveCoach":
                return(new Coach().Save(req, log));

            case "GetCoach":
                return(new Coach().Get(req, log));

            case "RemoveCoach":
                return(new Coach().Remove(req, log));

            case "SaveGoals":
                return(new Goals().Save(req, log));

            case "GetGoals":
                return(new Goals().Get(req, log));

            case "RemoveGoals":
                return(new Goals().Remove(req, log));

            /*
             * Bulk requests
             */
            case "GetPlayersByCoach":
                return(new PlayersByCoach().Get(req, log));

            case "SaveSleepRecords":
                return(new Sleep().Save(req, log));

            case "GetSleepRecords":
                return(new Sleep().Get(req, log));

            case "SaveProgress":
                return(new DailyProgress().Save(req, log));

            case "GetProgress":
                return(new DailyProgress().Get(req, log));

            case "SaveActivities":
                return(new Activity().Save(req, log));

            case "GetActivities":
                return(new Activity().Get(req, log));

            case "SaveTransactions":
                return(new Transaction().Save(req, log));

            case "GetTransactions":
                return(new Transaction().Get(req, log));

            default:
                return(req.CreateResponse(HttpStatusCode.BadRequest, "Unknown action"));
            }
        }