Ejemplo n.º 1
0
        public async Task ShouldRejectSuccessThrowExceptionWhenStatusIsNotRejected()
        {
            MandatoryListRejectionViewModel viewModel = new MandatoryListRejectionViewModel()
            {
                Id = "69N3QwUl%208o0yRoVEsRsYA=="
            };

            mandatoryListQueries.Setup(m => m.Find(It.IsAny <int>()))
            .Returns(() =>
            {
                return(Task.FromResult <Core.Entities.MandatoryList>(new MandatoryListDefault().GetMandatoryListWithProdcuts()));
            });
            await Assert.ThrowsAsync <BusinessRuleException>(async() => await _sut.Reject(viewModel));
        }
Ejemplo n.º 2
0
        public async Task ShouldCloseEditThrowException_When_StatusIsNotWaitingCancelRequest()
        {
            MandatoryListRejectionViewModel viewModel = new MandatoryListRejectionViewModel()
            {
                Id = "69N3QwUl%208o0yRoVEsRsYA==", RejectionReason = "rejectreason"
            };

            mandatoryListQueries.Setup(m => m.Find(It.IsAny <int>()))
            .Returns(() =>
            {
                return(Task.FromResult <Core.Entities.MandatoryList>(new MandatoryListDefault().GetMandatoryListWithStatusWaitingApprove()));
            });
            await Assert.ThrowsAsync <BusinessRuleException>(async() => await _sut.RejectDelete(viewModel));
        }
Ejemplo n.º 3
0
        public async Task ShouldRejectEditThrowExceptionWhwnRjectReasonNotSend()
        {
            MandatoryListRejectionViewModel viewModel = new MandatoryListRejectionViewModel()
            {
                Id = "69N3QwUl%208o0yRoVEsRsYA=="
            };

            mandatoryListQueries.Setup(m => m.Find(It.IsAny <int>()))
            .Returns(() =>
            {
                return(Task.FromResult <Core.Entities.MandatoryList>(new MandatoryListDefault().GetMandatoryListWithStatusApproveAndChangeRequest()));
            });
            await Assert.ThrowsAsync <BusinessRuleException>(async() => await _sut.RejectEdit(viewModel));
        }
Ejemplo n.º 4
0
        public async Task ShouldRejectSuccess()
        {
            MandatoryListRejectionViewModel viewModel = new MandatoryListRejectionViewModel()
            {
                Id = "69N3QwUl%208o0yRoVEsRsYA==", RejectionReason = "rejectreason"
            };

            mandatoryListQueries.Setup(m => m.Find(It.IsAny <int>()))
            .Returns(() =>
            {
                return(Task.FromResult <Core.Entities.MandatoryList>(new MandatoryListDefault().GetMandatoryListWithStatusWaitingApprove()));
            });
            await _sut.Reject(viewModel);

            _mandatoryListCommands.Verify(m => m.Update(It.IsAny <Core.Entities.MandatoryList>()), Times.Once);
        }
Ejemplo n.º 5
0
        public async Task <ActionResult> RejectDelete(MandatoryListRejectionViewModel viewModel)
        {
            try
            {
                await _apiClient.PostAsync("MandatoryList/RejectDelete", null, viewModel);

                return(Ok());
            }
            catch (AuthorizationException ex)
            {
                throw ex;
            }
            catch (BusinessRuleException ex)
            {
                return(JsonErrorMessage(ex.Message));
            }
            catch (Exception ex)
            {
                _logger.LogError(ex.ToString(), ex);
                return(JsonErrorMessage(Resources.SharedResources.ErrorMessages.UnexpectedError));
            }
        }
Ejemplo n.º 6
0
        public async Task RejectDelete(MandatoryListRejectionViewModel viewModel)
        {
            var entity = await _mandatoryListQueries.Find(Util.Decrypt(viewModel.Id));

            entity.RejectDelete(viewModel.RejectionReason);
            NotificationArguments NotificationArguments = new NotificationArguments
            {
                BodyEmailArgs    = new object[] { "", entity.DivisionNameAr, entity.DivisionCode },
                SubjectEmailArgs = new object[] { },
                PanelArgs        = new object[] { entity.DivisionNameAr, entity.DivisionCode },
                SMSArgs          = new object[] { entity.DivisionNameAr, entity.DivisionCode }
            };

            MainNotificationTemplateModel mainNotificationTemplateModel = new MainNotificationTemplateModel(NotificationArguments,
                                                                                                            $"MandatoryList/Details?id={viewModel.Id}",
                                                                                                            NotificationEntityType.MandatoryList,
                                                                                                            viewModel.Id.ToString());

            await _notificationAppService.SendNotificationForUsersByRoleName(NotificationOperations.MandatoryListOfficer.MandatoryListProducts.RejectDeleteMandatoryList, RoleNames.MandatoryListOfficer, mainNotificationTemplateModel);

            await _mandatoryListCommands.Update(entity);
        }
Ejemplo n.º 7
0
 public async Task Reject([FromBody] MandatoryListRejectionViewModel rejectionModel)
 {
     await _mandatoryListAppService.Reject(rejectionModel);
 }
Ejemplo n.º 8
0
 public async Task RejectDelete([FromBody] MandatoryListRejectionViewModel viewModel)
 {
     await _mandatoryListAppService.RejectDelete(viewModel);
 }