Exemple #1
0
        public JsonResult Issues()
        {
            var userEmail          = _accountRepository.FindById(User.Identity.GetUserId()).Email;
            var issueTypes         = _issueBusiness.GetIssueTypesForDeveloper(userEmail).ToArray();
            var fiveIssues         = _issueBusiness.GetFiveLatestErrorIssusByIssueTypes(issueTypes).ToArray();
            var selectedIssueTypes = fiveIssues.SelectMany(x => issueTypes.Where(y => y.Issues.Contains(x))).Distinct().ToArray();

            var list = new List <object>();

            foreach (var issueType in selectedIssueTypes)
            {
                foreach (var issue in fiveIssues)
                {
                    if (issueType.Issues.Any(x => x.Id == issue.Id))
                    {
                        var version     = _applicationVersionBusiness.GetApplicationVersionByIssue(issue.Id);
                        var application = _initiativeBusiness.GetApplicationByVersion(version.Id);
                        list.Add(new
                        {
                            IssueTypeName      = issueType.ExceptionTypeName,
                            IssueTypeLevel     = issueType.IssueLevel.ToString(),
                            IssueTimeAgo       = issue.ServerTime.ToLocalTime().ToTimeAgo(),
                            IssueTime          = issue.ServerTime.ToLocalTime().ToDateTimeString(),
                            IssueVisible       = issue.VisibleToUser.ToString(),
                            IssueTypeTicket    = issueType.Ticket,
                            IssueTicket        = issue.Ticket,
                            ApplicationVersion = version.Id,
                            ApplicationName    = application.Name,
                            InitativeId        = _initiativeBusiness.GetInitiativeByApplication(application.Id).Id.ToString(),
                        });
                    }
                }
            }

            var response = Json(list, JsonRequestBehavior.AllowGet);

            return(response);
        }