Ejemplo n.º 1
0
        public async Task ThenTheDismissShouldBeSaved()
        {
            //Arrange
            const string   hashedAccountId = "ABC123";
            const string   hashedUserId    = "DEF456";
            const TaskType taskType        = TaskType.LevyDeclarationDue;

            var taskTypeString = Enum.GetName(typeof(TaskType), taskType);

            //Act
            var result = await _orchestrator.DismissMonthlyReminderTask(hashedAccountId, hashedUserId, taskTypeString);

            //Assert
            Assert.AreEqual(HttpStatusCode.OK, result.Status);
            _mediator.Verify(x => x.SendAsync(It.Is <DismissMonthlyTaskReminderCommand>(command =>
                                                                                        command.HashedAccountId.Equals(hashedAccountId) &&
                                                                                        command.ExternalUserId.Equals(hashedUserId) &&
                                                                                        command.TaskType == taskType)), Times.Once);
        }
Ejemplo n.º 2
0
        public async Task <ActionResult> DismissTask(DismissTaskViewModel viewModel)
        {
            if (string.IsNullOrEmpty(OwinWrapper.GetClaimValue(ControllerConstants.UserRefClaimKeyName)))
            {
                return(RedirectToAction(ControllerConstants.IndexActionName, ControllerConstants.HomeControllerName));
            }

            var externalUserId = OwinWrapper.GetClaimValue("sub");

            _logger.Debug($"Task dismiss requested for account id '{viewModel.HashedAccountId}', user id '{externalUserId}' and task '{viewModel.TaskType}'");



            var result = await _orchestrator.DismissMonthlyReminderTask(viewModel.HashedAccountId, externalUserId, viewModel.TaskType);

            if (result.Status != HttpStatusCode.OK)
            {
                //Curently we are not telling the user of the error and are instead just logging the issue
                //The error log will be done at a lower level
                _logger.Debug($"Task dismiss requested failed for account id '{viewModel.HashedAccountId}', user id '{externalUserId}' and task '{viewModel.TaskType}'");
            }

            return(RedirectToAction("Index", "EmployerTeam"));
        }