public void F_GetWorkoutsByUserTest()
        {
            var users   = userService.GetUsers().FirstOrDefault();
            var results = workoutCollectionService.GetWorkoutsByUser(users.user_name).ToList();

            if (results != null)
            {
                Assert.AreNotEqual(null, results);
                Assert.AreNotEqual(0, results.Count());
            }
        }
Пример #2
0
        public HttpResponseMessage GetWeeklyReport(Report wr)
        {
            Report weeklyReport = new Report();

            try
            {
                DateTime firstOfWeek = new DateTime();
                if (wr.IsPrev)
                {
                    firstOfWeek = DateTime.Today.AddDays(wr.IncrId * -7).FirstOfWeek();
                }
                else
                {
                    firstOfWeek = DateTime.Today.AddDays(wr.IncrId * 7).FirstOfWeek();
                }
                DateTime lastofWeek = firstOfWeek.AddDays(7).AddSeconds(-1);
                var      wDays      = Convert.ToInt32(CalcNoOfDays(firstOfWeek, lastofWeek));
                var      res        = _workoutService.GetWorkoutsByUser(wr.User.user_name).ToList();
                if (res != null && res.Count > 0)
                {
                    weeklyReport.Data = new double[wDays];
                    res.ForEach(items =>
                    {
                        GenerateWeeklyReport(items, firstOfWeek, lastofWeek, ref weeklyReport);
                    });
                    weeklyReport.IncrId = wr.IncrId;
                }
                weeklyReport.FromDate = firstOfWeek.Day.ToString() + "/" + firstOfWeek.Month.ToString() + "/" + firstOfWeek.Year.ToString();
                weeklyReport.ToDate   = lastofWeek.Day.ToString() + "/" + lastofWeek.Month.ToString() + "/" + lastofWeek.Year.ToString();
            }
            catch (Exception ex)
            {
                _logManager.WriteLog(ex);
            }
            return(ToJson(weeklyReport));
        }
        public HttpResponseMessage GetAllWorkOutsByUser(User usr)
        {
            IEnumerable <WorkoutCollection> result = null;

            try
            {
                var res = _workoutService.GetWorkoutsByUser(usr.user_name);
                result = Helper.CastObject <IEnumerable <WorkoutCollection> >(res);
            }
            catch (Exception ex)
            {
                _logManager.WriteLog(ex);
            }
            return(ToJson(result));
        }