Example #1
0
        public async Task <ActionResult <WeightResponse[]> > getAllWeight(string username)
        {
            if (await userRepository.getUser(username) == null)
            {
                return(StatusCode(StatusCodes.Status404NotFound, "User not found!"));
            }

            WeightData[] data = await weightDataRepository.getWeight(username);

            WeightResponse[] responses = new WeightResponse[data.Length];

            if (responses.Length == 0)
            {
                return(Ok(responses));
            }
            else
            {
                for (int i = 0; i < responses.Length; i++)
                {
                    responses[i] = WeightMapper.minimize(data[i]);
                }

                return(Ok(responses));
            }
        }
Example #2
0
        public async Task <ActionResult <WeightResponse> > getWeightOnDay(string username, DateTime date)
        {
            if (await userRepository.getUser(username) == null)
            {
                return(StatusCode(StatusCodes.Status404NotFound, "User not found!"));
            }

            WeightData data = await weightDataRepository.getWeightOnDay(username, date);

            if (data == null)
            {
                return(Ok(null));
            }
            else
            {
                return(Ok(WeightMapper.minimize(data)));
            }
        }