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)); } }
public static WeightResponse minimize(WeightData source) { WeightResponse target = new WeightResponse(); target.Date = source.Date; target.Height = source.Height; target.Weight = source.Weight; return(target); }