public static async Task<WeightChartModel> GetModel(UserEntity user) { if (user == null) return null; var weightRepo = new WeightRepository(); var points = await weightRepo.GetByLatest(user.Id, new DateTime(DateTime.UtcNow.Year - 1, 1, 1, 0, 0, 0, DateTimeKind.Utc)); if (points == null || points.Count <= 0) return null; points.Sort(new WeightEntity()); var result = new WeightChartModel() { MinValue = points[0].Value, MaxValue = points[0].Value, From = points[0].TimeStamp, End = points[points.Count - 1].TimeStamp, Points = new List<dynamic>() }; foreach (var timeValue in points) { result.Points.Add(new List<dynamic>() { DateTimeHelper.ToLocalJavaTime(timeValue.TimeStamp, user.TimezoneOffset), Math.Round(timeValue.Value, 1) }); if (timeValue.Value < result.MinValue) result.MinValue = timeValue.Value; if (timeValue.Value > result.MaxValue) result.MaxValue = timeValue.Value; } return result; }