예제 #1
0
        public async Task <BasexResponse <ICollection <DonePracticeNotificationResponse> > > GetByDateAsync(int userId)
        {
            try
            {
                var list     = new Collection <DonePracticeNotificationResponse>();
                var response = await _donePracticeDal.GetByUserIdWithGivenPracticeAsync(userId);

                var filterResponse = response.Where(dp =>
                                                    (dp.CreationTime.AddSeconds(Math.Pow(2, dp.TotalDonePractice))
                                                     <= DateTime.UtcNow));
                foreach (var item in filterResponse)
                {
                    list.Add(new DonePracticeNotificationResponse
                    {
                        GivenPracticeId = item.GivenPracticeId,
                        Level           = item.GivenPractice.Level,
                        ProgrammingType = item.GivenPractice.ProgrammingType.Description(),
                        Title           = item.GivenPractice.Title
                    });
                }

                return(new BasexResponse <ICollection <DonePracticeNotificationResponse> >(list));
            }
            catch (Exception ex)
            {
                return(new BasexResponse <ICollection <DonePracticeNotificationResponse> >(ex.Message));
            }
        }
        private async Task <ICollection <DonePracticeNotificationResponse> > GetDuePracticesAsync(int userId)
        {
            var list     = new Collection <DonePracticeNotificationResponse>();
            var response = await _donePracticeDal.GetByUserIdWithGivenPracticeAsync(userId);

            var filterResponse = response.Where(dp =>
                                                (dp.CreationTime.AddSeconds(Math.Pow(2, dp.TotalDonePractice))
                                                 <= DateTime.UtcNow));

            foreach (var item in filterResponse)
            {
                list.Add(new DonePracticeNotificationResponse
                {
                    GivenPracticeId = item.GivenPracticeId,
                    Level           = item.GivenPractice.Level,
                    ProgrammingType = item.GivenPractice.ProgrammingType.Description(),
                    Title           = item.GivenPractice.Title,
                    Date            = item.CreationTime.AddSeconds(Math.Pow(2, item.TotalDonePractice))//ne zamandan sonra yapılması gerekiyor
                });
            }
            return(list);
        }