public async Task HandleAsync(IMessageContext context, IncidentReOpened message)
        {
            int?accountId;

            try
            {
                if (context.Principal.IsInRole(CoderrRoles.System))
                {
                    accountId = null;
                }
                else
                {
                    accountId = context.Principal.GetAccountId();
                }
            }
            catch (Exception ex)
            {
                ex.Data["Principal"] = context.Principal.ToFriendlyString();
                throw;
            }

            var e = new HistoryEntry(message.IncidentId, accountId, IncidentState.ReOpened)
            {
                ApplicationVersion = message.ApplicationVersion
            };
            await _repository.CreateAsync(e);
        }
 public async Task HandleAsync(IMessageContext context, IncidentClosed message)
 {
     var entry = new HistoryEntry(message.IncidentId, message.ClosedById, IncidentState.Closed)
     {
         ApplicationVersion = message.ApplicationVersion
     };
     await _repository.CreateAsync(entry);
 }
 public async Task HandleAsync(IMessageContext context, IncidentCreated message)
 {
     var entry = new HistoryEntry(message.IncidentId, null, IncidentState.New)
     {
         ApplicationVersion = message.ApplicationVersion
     };
     await _historyRepository.CreateAsync(entry);
 }
        public async Task HandleAsync(IMessageContext context, IncidentAssigned message)
        {
            //var entries = await _repository.GetByIncidentId(message.IncidentId);

            //// Include the version to make it easier to fetch information
            //// that should be shown (to give the user a hint on version difference between created and assigned states)
            //var version = entries.Where(x => x.ApplicationVersion != null).Select(x => x.ApplicationVersion)
            //    .LastOrDefault();

            var entry = new HistoryEntry(message.IncidentId, message.AssignedById, IncidentState.Active);
            await _repository.CreateAsync(entry);
        }
Exemple #5
0
        public async Task CreateAsync(UserAction action, string description)
        {
            var user = await GetCurrentUser();

            var history = new History
            {
                Action      = action,
                DateTime    = DateTime.Now.ToUniversalTime(),
                Description = description,
                UserId      = user.Id,
                UserEmail   = user.Email,
                UserName    = user.Name,
                UserRole    = user.Role,
                UserAddress = user.Address
            };

            await _historyRepository.CreateAsync(history);
        }
        public async Task HandleAsync(IMessageContext context, IncidentReOpened message)
        {
            int?accountId;

            if (context.Principal.IsInRole(CoderrRoles.System))
            {
                accountId = null;
            }
            else
            {
                accountId = context.Principal.GetAccountId();
            }


            var e = new HistoryEntry(message.IncidentId, accountId, IncidentState.ReOpened)
            {
                ApplicationVersion = message.ApplicationVersion
            };
            await _repository.CreateAsync(e);
        }
        public async Task <Issue> UpdateAsync(Issue issue, User updater)
        {
            var pristineIssue = await GetByIdAsync(issue.Id);

            if (pristineIssue == null)
            {
                throw new NotFoundException();
            }

            var changes       = GetIssueChanges(pristineIssue, issue);
            var historyEntity = new Data.Histories.History
            {
                IssueId   = pristineIssue.Id,
                UpdaterId = updater.Id,
                Date      = DateTime.Now,
                Changes   = changes.Select(_mapper.Map <Data.Histories.HistoryChange>).ToList(),
            };

            await _historyRepository.CreateAsync(historyEntity);

            var history = _mapper.Map <History>(historyEntity);

            if (pristineIssue.Histories == null)
            {
                issue.Histories = new List <History>();
            }
            else
            {
                issue.Histories = pristineIssue.Histories;
            }
            issue.Histories.Add(history);

            var updatedIssueEntity = _mapper.Map <Data.Issues.Issue>(issue);
            await _issueRepository.UpdateAsync(updatedIssueEntity);

            return(_mapper.Map(updatedIssueEntity, issue));
        }
Exemple #8
0
 public async Task HandleAsync(IMessageContext context, IncidentIgnored message)
 {
     var entry = new HistoryEntry(message.IncidentId, message.AccountId, IncidentState.Ignored);
     await _repository.CreateAsync(entry);
 }