public ActionResult Index(ErrorCriteriaPostModel postModel) { var viewModel = new ErrorPageViewModel { ErrorsViewModel = new ErrorCriteriaViewModel { Action = "index", Controller = "errors" } }; var applications = Core.GetApplications(); var pagingRequest = GetSinglePagingRequest(); if (applications.PagingStatus.TotalItems > 0) { var request = new GetApplicationErrorsRequest { ApplicationId = CurrentApplication.IfPoss(a => a.Id), Paging = pagingRequest, Query = postModel.Query, OrganisationId = Core.AppContext.CurrentUser.OrganisationId, }; if (postModel.DateRange.IsNotNullOrEmpty()) { string[] dates = postModel.DateRange.Split('|'); DateTime startDate; DateTime endDate; if (DateTime.TryParse(dates[0], out startDate) && DateTime.TryParse(dates[1], out endDate)) { request.StartDate = startDate; request.EndDate = endDate; viewModel.ErrorsViewModel.DateRange = "{0} - {1}".FormatWith(startDate.ToString("MMMM d, yyyy"), endDate.ToString("MMMM d, yyyy")); } } var errors = _getApplicationErrorsQuery.Invoke(request); viewModel.ErrorsViewModel.Paging = _pagingViewModelGenerator.Generate(PagingConstants.DefaultPagingId, errors.Errors.PagingStatus, pagingRequest); viewModel.ErrorsViewModel.Errors = errors.Errors.Items.Select(e => new ErrorInstanceViewModel { Error = e, //IsGetMethod = e.ContextData.ContainsKey("Request.HttpMethod") && e.ContextData["Request.HttpMethod"].ToLowerInvariant() == "get" }).ToList(); } else { ErrorNotification(Resources.Application.No_Applications); return(Redirect(Url.AddApplication())); } return(View(viewModel)); }
public ActionResult Errors(ErrorCriteriaPostModel postModel) { var paging = GetSinglePagingRequest(); var model = GetErrorsViewModel(postModel, paging, _getExtraDataKeysForIssueQuery.Invoke(new GetExtraDataKeysForIssueRequest() { IssueId = postModel.Id }).Keys); return(PartialView("Errors/ErrorItems", model)); }
private ErrorCriteriaViewModel GetErrorsViewModel(ErrorCriteriaPostModel postModel, PageRequestWithSort paging, List <string> extraDataKeys) { var request = new GetApplicationErrorsRequest { OrganisationId = Core.AppContext.CurrentUser.OrganisationId, IssueId = postModel.Id, Paging = paging, }; if (postModel.DateRange.IsNotNullOrEmpty()) { string[] dates = postModel.DateRange.Split('|'); DateTime startDate; DateTime endDate; if (DateTime.TryParse(dates[0], out startDate) && DateTime.TryParse(dates[1], out endDate)) { request.StartDate = startDate; request.EndDate = endDate.AddDays(1).AddMinutes(-1); } } var errors = _getApplicationErrorsQuery.Invoke(request).Errors; var model = new ErrorCriteriaViewModel { Action = "errors", Controller = "issue", DateRange = postModel.DateRange, Paging = _pagingViewModelGenerator.Generate(PagingConstants.DefaultPagingId, errors.PagingStatus, paging), Errors = errors.Items.Select(e => new ErrorInstanceViewModel { Error = e, HideIssues = true, PropertiesEligibleForRules = extraDataKeys, //IsGetMethod = e.ContextData.ContainsKey("Request.HttpMethod") && e.ContextData["Request.HttpMethod"].ToLowerInvariant() == "get" }).ToList(), HideIssues = true, Id = postModel.Id, Sort = paging.Sort, SortDescending = paging.SortDescending, }; model.Paging.Tab = IssueTab.Details.ToString(); return(model); }