Ejemplo n.º 1
0
        public ServiceResponse <DayAnalyticsDto> StatisticTask(WatchHistoryReqDto model)
        {
            var response = new ServiceResponse <DayAnalyticsDto>();

            try
            {
                var dataAnalytics = _repository.TableNoTracking.Where(x =>
                                                                      x.CourseId == model.CourseId &&
                                                                      EntityFunctions.TruncateTime(x.DateAdded) >= EntityFunctions.TruncateTime(model.StartDate) &&
                                                                      EntityFunctions.TruncateTime(x.DateAdded) <= EntityFunctions.TruncateTime(model.EndDate)
                                                                      );

                response.List = dataAnalytics.ToList().Select(k => new { k.DateAdded.Date, k.UserId }).GroupBy(x => new { x.Date }, (key, group) => new DayAnalyticsDto
                {
                    NowDate   = key.Date,
                    CountData = group.Count(k => k.UserId.HasValue)
                }).OrderBy(x => x.NowDate).ToList();



                response.IsSuccessful = true;
                if (response.List == null)
                {
                    response.IsSuccessful     = false;
                    response.ExceptionMessage = ErrorCodes.KayitYok.Text;
                }
            }
            catch (Exception)
            {
                response.IsSuccessful     = false;
                response.ExceptionMessage = ErrorCodes.BilinmeyenHata.Text;
            }

            return(response);
        }
Ejemplo n.º 2
0
        public ServiceResponse <WatchHistoryDto> GetByDateTime(WatchHistoryReqDto model)
        {
            var response = new ServiceResponse <WatchHistoryDto>();

            try
            {
                response.List = _repository.TableNoTracking.Include(x => x.User).Where(x => x.CourseId == model.CourseId && EntityFunctions.TruncateTime(x.DateAdded) == EntityFunctions.TruncateTime(model.StartDate)).Select(m =>
                                                                                                                                                                                                                               new WatchHistoryDto
                {
                    CourseId = m.CourseId,
                    UserId   = m.UserId,
                    User     = new UserDto
                    {
                        Email     = m.User.Email,
                        FirstName = m.User.FirstName,
                        Id        = m.User.Id,
                        LastName  = m.User.LastName,
                        Password  = m.User.Password,
                        RoleId    = m.User.RoleId
                    }
                }).ToList();


                response.IsSuccessful = true;
                if (response.List == null)
                {
                    response.IsSuccessful     = false;
                    response.ExceptionMessage = ErrorCodes.KayitYok.Text;
                }
            }
            catch (Exception)
            {
                response.IsSuccessful     = false;
                response.ExceptionMessage = ErrorCodes.BilinmeyenHata.Text;
            }

            return(response);
        }
Ejemplo n.º 3
0
 public async Task <ServiceResponse <DayAnalyticsDto> > StatisticTask(WatchHistoryReqDto model)
 {
     return(_repository.StatisticTask(model));
 }
Ejemplo n.º 4
0
 public async Task <ServiceResponse <WatchHistoryDto> > GetByDateTime(WatchHistoryReqDto model)
 {
     return(_repository.GetByDateTime(model));
 }