Exemple #1
0
        public async Task <IActionResult> UsersActivationReport([FromBody] IssueOfEquipmentFormModel form)
        {
            var result =
                await _reportService.UsersActivationReportAsync(HttpContext.GetUser(), form);

            return(Ok(GetRequestResult(result)));
        }
Exemple #2
0
        public async Task <List <IssueOfEquipmentViewModel> > IssueOfEquipmentsReportAsync(User user, IssueOfEquipmentFormModel form)
        {
            try
            {
                var queryable = _context.EquipmentIssueSubscriptions.Include(c => c.Equipment).Include(c => c.Issue).Include(c => c.Issue.IssueDetails).Where(c => form.EquipmentIds.Contains(c.EquipmentId)).AsQueryable();

                if (form.StartTime.HasValue)
                {
                    queryable = queryable.Where(c => c.Issue.CreationDate >= form.StartTime);
                }
                if (form.EndTime.HasValue)
                {
                    queryable = queryable.Where(c => c.Issue.CreationDate <= form.EndTime);
                }

                var resp = await queryable.GroupBy(c => new { c.EquipmentId, c.Issue.IssueType }).ToListAsync();

                var issueOfEquipmentViewModels = new List <IssueOfEquipmentViewModel>();
                resp?.ForEach(c =>
                {
                    var issueOfEquipmentViewModel = new IssueOfEquipmentViewModel()
                    {
                        TotalUserDetails  = c.Select(d => d.Issue.UserId).Distinct().Count(),
                        EquipmentName     = c.FirstOrDefault().Equipment.EquipmentName,
                        TotalIssueCount   = c.Select(d => d.Issue).Distinct().Count(),
                        IssueType         = EnumHelper <IssueType> .GetDisplayValue(c.Key.IssueType),
                        TotalIssueDetails = c.Select(d => d.Issue.IssueDetails).Distinct().Count(),
                    };
                    issueOfEquipmentViewModels.Add(issueOfEquipmentViewModel);
                });

                return(issueOfEquipmentViewModels);
            }
            catch (Exception ex)
            {
                throw new ExperienceManagementGlobalException(ReportServiceErrors.UserIssuesReportError, ex);
            }
        }
Exemple #3
0
        public async Task <List <TotalIssueViewModel> > UsersActivationReportAsync(User user, IssueOfEquipmentFormModel form)
        {
            try
            {
                var eqIssue = await _context.EquipmentIssueSubscriptions.Where(c => form.EquipmentIds.Contains(c.EquipmentId)).Select(c => c.IssueId).ToListAsync();

                var queryable = _context.Issues.Include(c => c.User).Include(c => c.IssueDetails).Where(c => eqIssue.Contains(c.Id)).AsQueryable();

                if (form.StartTime.HasValue)
                {
                    queryable = queryable.Where(c => c.CreationDate >= form.StartTime);
                }
                if (form.EndTime.HasValue)
                {
                    queryable = queryable.Where(c => c.CreationDate <= form.EndTime);
                }
                var resp = await queryable.ToListAsync();

                var totalIssueViewModels = new List <TotalIssueViewModel>();

                resp?.ForEach(c =>
                {
                    var totalIssueViewModel = new TotalIssueViewModel()
                    {
                        CreationTime      = c.CreationDate.ToShortPersianDateTimeString(),
                        FullName          = c.User.FirstName + " " + c.User.LastName,
                        IssueType         = EnumHelper <IssueType> .GetDisplayValue(c.IssueType),
                        LikesCount        = c.IssueDetails.Sum(d => d.Likes),
                        Title             = c.Title,
                        TotalIssueDetails = c.IssueDetails.Count(),
                        UserName          = c.User.Username,
                    };
                    totalIssueViewModels.Add(totalIssueViewModel);
                });

                return(totalIssueViewModels);
            }
            catch (Exception ex)
            {
                throw new ExperienceManagementGlobalException(ReportServiceErrors.UserIssuesReportError, ex);
            }
        }