public IEnumerable <WorkHourOnProjecstJson> GetThisPeriodProjectsByUserId(GetThisMonthDataByUserJson json)
        {
            List <WorkHourOnProjecstJson> result     = new List <WorkHourOnProjecstJson>();
            UnitOfWork           uow                 = new UnitOfWork();
            UserManager          userManager         = new UserManager(uow);
            TimeSheetManager     timeSheetManager    = new TimeSheetManager(uow);
            DisplayPeriodManager displayPeriodMnager = new DisplayPeriodManager(uow);
            User          currUser      = userManager.GetByID(Guid.Parse(json.userid));
            DisplayPeriod displayPeriod = displayPeriodMnager.GetDisplayPeriod(currUser);

            DateTime fromDate = json.values[0].Date;
            DateTime toDate   = json.values[json.values.Count() - 1].Date;

            var all = timeSheetManager.GetWorkHoursByUser(currUser, fromDate, toDate);

            foreach (var item in all.GroupBy(x => x.ProjectId).Select(y => y.FirstOrDefault()).ToList())
            {
                var addItem = new WorkHourOnProjecstJson();
                addItem.ProjectId = item.ProjectId;
                addItem.Title     = item.Project.Title;
                var hour = all.Where(a => a.ProjectId == item.ProjectId).Sum(d => d.Hours);
                addItem.Hour = DateUtility.ConvertToTimeSpan(hour);
                result.Add(addItem);
            }

            return(result);
        }
        public IEnumerable <WorkHourOnProjecstJson> GetThisMonthProjectsByUserID(GetThisMonthDataByUserJson json)
        {
            List <WorkHourOnProjecstJson> result = new List <WorkHourOnProjecstJson>();
            UnitOfWork       uow              = new UnitOfWork();
            UserManager      userManager      = new UserManager(uow);
            TimeSheetManager timeSheetManager = new TimeSheetManager(uow);
            //SyncWithPWA(uow);
            User User = userManager.GetByID(Guid.Parse(json.userid));
            var  all  = timeSheetManager.GetWorkHoursByUser(User.ID, json.value.Date);

            foreach (var item in all.GroupBy(x => x.ProjectId).Select(y => y.FirstOrDefault()).ToList())
            {
                var addItem = new WorkHourOnProjecstJson();
                addItem.ProjectId = item.ProjectId;
                addItem.Title     = item.Project.Title;
                var hour = all.Where(a => a.ProjectId == item.ProjectId).Sum(d => d.Hours);
                addItem.Hour = DateUtility.ConvertToTimeSpan(hour);
                result.Add(addItem);
            }
            return(result);
        }