public ActionResult Merge(MergeIssuesViewModel viewModel) { var leftIssue = _getIssueQuery.Invoke(new GetIssueRequest { IssueId = viewModel.LeftIssueId, CurrentUser = Core.AppContext.CurrentUser }).Issue; var rightIssue = _getIssueQuery.Invoke(new GetIssueRequest { IssueId = viewModel.RightIssueId, CurrentUser = Core.AppContext.CurrentUser }).Issue; viewModel.RightIssueName = rightIssue.Name; viewModel.RightIssueStatus = Resources.IssueResources.ResourceManager.GetString("IssueStatus_{0}".FormatWith(rightIssue.Status)); viewModel.LeftIssueName = leftIssue.Name; viewModel.LeftIssueStatus = Resources.IssueResources.ResourceManager.GetString("IssueStatus_{0}".FormatWith(leftIssue.Status)); return(View(viewModel)); }
public ActivityViewModelBase GetActivityViewModel(int pageNumber) { var curentApplication = CurrentApplication; var applicationId = curentApplication == null ? null : curentApplication.Id; var issueMemoizer = new LocalMemoizer <string, Issue>(id => _getIssueQuery.Invoke(new GetIssueRequest { CurrentUser = Core.AppContext.CurrentUser, IssueId = id }).Issue); var users = Core.GetUsers(); var applications = Core.GetApplications(); var activity = _getActivityLogQuery.Invoke(new GetActivityLogRequest { Paging = new PageRequestWithSort(pageNumber, 20), ApplicationId = applicationId }).Log; var selectedApplication = applicationId.IsNotNullOrEmpty() ? applications.Items.FirstOrDefault(a => a.FriendlyId == applicationId.GetFriendlyId()) : null; var items = activity.Items.Select(h => { var user = users.Items.FirstOrDefault(u => u.Id == h.UserId); return(new IssueHistoryItemViewModel { Message = h.GetMessage(users.Items, issueMemoizer, GetIssueLink), VerbalTime = h.DateAddedUtc.ToVerbalTimeSinceUtc(Core.AppContext.CurrentUser.ActiveOrganisation.TimezoneId, true), UserEmail = user != null ? user.Email : string.Empty, Username = user != null ? user.FullName : string.Empty, SystemMessage = h.SystemMessage, IssueLink = issueMemoizer.Get(h.IssueId).IfPoss(i => "<a href=\"{0}\">{1}</a>".FormatWith(Url.Issue(i.Id), i.Name), "DELETED"), IssueId = IdHelper.GetFriendlyId(h.IssueId), }); }); var model = new ActivityViewModelBase { Paging = activity.PagingStatus, Items = items, Applications = applications.Items, SelectedApplicationId = selectedApplication == null ? null : selectedApplication.FriendlyId, SelectedApplicationName = selectedApplication == null ? null : selectedApplication.Name, UrlGetter = GetFeedUrl }; return(model); }
private IssueViewModel GetViewModel(IssueErrorsPostModel postModel, PageRequestWithSort paging, bool useSystemUser = false) { var issue = _getIssueQuery.Invoke(new GetIssueRequest { IssueId = postModel.Id, CurrentUser = useSystemUser ? Errordite.Core.Domain.Organisation.User.System() : Core.AppContext.CurrentUser }).Issue; if (issue == null) { return(null); } var users = Core.GetUsers(); var applications = Core.GetApplications(); var assignedUser = users.Items.FirstOrDefault(u => u.Id == issue.UserId); //if the assigned user has been deleted, update it to the current user if (assignedUser == null) { var updateIssue = Core.Session.Raven.Load <Issue>(issue.Id); updateIssue.UserId = Core.AppContext.CurrentUser.Id; assignedUser = Core.AppContext.CurrentUser; } int ii = 0; var extraDataKeys = _getExtraDataKeysForIssueQuery.Invoke(new GetExtraDataKeysForIssueRequest { IssueId = issue.Id, }).Keys ?? new List <string>(); var ruleViewModels = issue.Rules.OfType <PropertyMatchRule>().Select(r => new RuleViewModel { ErrorProperty = r.ErrorProperty, StringOperator = r.StringOperator, Value = r.Value, Index = ii++, Properties = _configuration.GetRuleProperties(r.ErrorProperty) .Union(extraDataKeys.Select(k => new SelectListItem { Selected = r.ErrorProperty == k, Text = k, Value = k })), }).ToList(); var updateViewModel = new UpdateIssueViewModel { ApplicationId = issue.ApplicationId, Rules = ruleViewModels, Name = issue.Name, AdjustmentName = GetAdjustmentRejectsName(issue.Name), IssueId = issue.Id, Users = users.Items.ToSelectList(u => u.Id, u => "{0} {1}".FormatWith(u.FirstName, u.LastName), sortListBy: SortSelectListBy.Text, selected: u => u.Id == issue.UserId), Statuses = issue.Status.ToSelectedList(IssueResources.ResourceManager, false, issue.Status == IssueStatus.Unacknowledged ? IssueStatus.Acknowledged.ToString() : issue.Status.ToString()), UserId = issue.UserId, Status = issue.Status == IssueStatus.Unacknowledged ? IssueStatus.Acknowledged : issue.Status, NotifyFrequency = issue.NotifyFrequency, Reference = issue.Reference, NotificationFrequencies = FrequencyHours, Comment = null }; var viewModel = new IssueViewModel { Details = new IssueDetailsViewModel { ApplicationId = issue.ApplicationId, OrganisationId = issue.OrganisationId, ErrorCount = issue.ErrorCount, LastErrorUtc = issue.LastErrorUtc, FirstErrorUtc = issue.CreatedOnUtc, UserName = assignedUser == null ? string.Empty : assignedUser.FullName, ApplicationName = applications.Items.First(a => a.Id == issue.ApplicationId).Name, ErrorLimitStatus = IssueResources.ResourceManager.GetString("ErrorLimitStatus_{0}".FormatWith(issue.LimitStatus)), TestIssue = issue.TestIssue, IssueId = issue.Id, Status = issue.Status, NotifyFrequency = issue.NotifyFrequency, Reference = issue.Reference }, Errors = GetErrorsViewModel(postModel, paging, extraDataKeys), Update = updateViewModel, Tab = postModel.Tab, PublicUrl = "{0}/issue/public?token={1}".FormatWith( _configuration.SiteBaseUrl, _encryptor.Encrypt("{0}|{1}|{2}".FormatWith( Core.AppContext.CurrentUser.ActiveOrganisation.FriendlyId, issue.FriendlyId, Core.AppContext.CurrentUser.ActiveOrganisation.ApiKeySalt)).Base64Encode()) }; //dont let users set an issue to unacknowledged if (issue.Status != IssueStatus.Unacknowledged) { var statuses = viewModel.Update.Statuses.ToList(); statuses.Remove(viewModel.Update.Statuses.First(s => s.Value == IssueStatus.Unacknowledged.ToString())); viewModel.Update.Statuses = statuses; } return(viewModel); }