public void SetUp()
        {
            _approvalService    = new Mock <IApprovalService>();
            _documentService    = new Mock <IDocumentService>();
            _logger             = new Mock <ILogger>();
            _approvalController = new ApprovalController(_approvalService.Object, _documentService.Object, _logger.Object);

            _approveDocumentsViewModel = new ApproveDocumentsViewModel
            {
                ApproveDocumentViewModel = new List <ApproveDocumentViewModel>
                {
                    new ApproveDocumentViewModel
                    {
                        DocumentId = "guid1",
                        Selected   = true
                    },
                    new ApproveDocumentViewModel
                    {
                        DocumentId = "guid2",
                        Selected   = false
                    }
                },
                Grid = "grid",
                Page = "1"
            };

            SetControllerContext(_approvalController);
            MockHttpContext.SetupGet(x => x.Session["CartId"]).Returns("testUser");
            MockHttpContext.SetupGet(x => x.User.Identity.Name).Returns("testUser");
            MockHttpContext.SetupGet(x => x.Session["testUser"]).Returns("testUser");
        }
Exemplo n.º 2
0
 public MaintenanceApprovalPresenter([CreateNew] ApprovalController controller, [CreateNew] SettingController settingcontroller, [CreateNew] AdminController admincontroller, [CreateNew] InventoryController inventorycontroller)
 {
     _controller          = controller;
     _settingController   = settingcontroller;
     _admincontroller     = admincontroller;
     _inventorycontroller = inventorycontroller;
 }
        public async Task UpdateApprovalStatusForAllocationLine_WhenUserDoesHavePublishFundingPermission_ThenActionAllowed()
        {
            // Arrange
            string specificationId = "abc123";

            PublishedAllocationLineResultStatusUpdateViewModel model = new PublishedAllocationLineResultStatusUpdateViewModel
            {
                Status    = AllocationLineStatusViewModel.Published,
                Providers = new List <PublishedAllocationLineResultStatusUpdateProviderViewModel>()
            };

            IAuthorizationHelper authorizationHelper = Substitute.For <IAuthorizationHelper>();

            authorizationHelper
            .DoesUserHavePermission(Arg.Any <ClaimsPrincipal>(), Arg.Is(specificationId), Arg.Is(SpecificationActionTypes.CanPublishFunding))
            .Returns(true);

            IResultsApiClient resultsClient = CreateResultsClient();

            resultsClient
            .UpdatePublishedAllocationLineStatusByBatch(Arg.Is(specificationId), Arg.Any <PublishedAllocationLineResultStatusUpdateModel>())
            .Returns(new ValidatedApiResponse <PublishedAllocationLineResultStatusUpdateResponseModel>(HttpStatusCode.OK, new PublishedAllocationLineResultStatusUpdateResponseModel()));

            ApprovalController controller = CreateApprovalController(resultsClient: resultsClient, authorizationHelper: authorizationHelper);

            // Act
            IActionResult result = await controller.UpdateApprovalStatusForAllocationLine(specificationId, model);

            // Assert
            result.Should().BeOfType <OkResult>();
        }
Exemplo n.º 4
0
 public TravelLogAttachPresenter([CreateNew] ApprovalController controller, RequestController requestController, SettingController settingController, AdminController adminController)
 {
     _controller        = controller;
     _requestController = requestController;
     _settingController = settingController;
     _adminController   = adminController;
 }
 public PaymentReimbursementApprovalPresenter([CreateNew] ApprovalController controller, RequestController requestController, SettingController settingController, AdminController adminController)
 {
     _controller        = controller;
     _requestController = requestController;
     _settingController = settingController;
     _adminController   = adminController;
 }
Exemplo n.º 6
0
 public OperationalControlApprovalPresenter([CreateNew] ApprovalController controller, RequestController requestController, SettingController settingController, AdminController adminController)
 {
     _controller        = controller;
     _requestController = requestController;
     _settingController = settingController;
     _adminController   = adminController;
 }
Exemplo n.º 7
0
 public SalesController()
 {
     var dbfactory = new DatabaseFactory();
     var unitOfWork = new UnitOfWork(dbfactory);
     _salesOrderService = new SalesOrderService(new SalesOrderRepository(dbfactory),
         new SalesOrderDetailRepository(dbfactory),
         new SalesOrderApprovalRepository(dbfactory),
         new NotificationRepository(dbfactory),
         new NotificationDetailRepository(dbfactory),
         unitOfWork);
     _approvalController = new ApprovalController<SlsSalesOrderApproval, SlsSalesOrderViewModel>(_salesOrderService);
     _deliveryService = new DeliveryService(new DeliveryRepository(dbfactory), new DeliveryDetailRepository(dbfactory), unitOfWork);
     _SecCompanyService = new SecCompanyService(new SecCompanyRepository(dbfactory), unitOfWork);
     _hrmEmployeeService = new HrmEmployeeService(new HrmEmployeeRepository(dbfactory), unitOfWork);
     _officeService = new OfficeService(new OfficeRepository(dbfactory), unitOfWork);
     _DistributorService = new DistributorService(new DistributorRepository(dbfactory), unitOfWork);
     _DealerService = new DealerService(new DealerRepository(dbfactory), unitOfWork);
     _CorporateClientService = new CorporateClientService(new CorporateClientRepository(dbfactory), unitOfWork);
     _RetailerService = new RetailerService(new RetailerRepository(dbfactory), unitOfWork);
     _FreeProductService = new FreeProductService(new FreeProductRepository(dbfactory), new ChartOfProductRepository(dbfactory),
         new UnitOfMeasurementRepository(dbfactory), unitOfWork);
     _ProductService = new ChartOfProductService(new ChartOfProductRepository(dbfactory), unitOfWork);
     _UnitService = new UnitOfMeasurementService(new UnitOfMeasurementRepository(dbfactory), unitOfWork);
     _salesDiscountSettingService = new SalesDiscountSettingService(new SalesDiscountSettingRepository(dbfactory), unitOfWork);
     _PartyCreditService = new PartyCreditReportService(new InvStoreOpeningRepository(dbfactory), unitOfWork);
     _promotionalOfferService = new PromotionalOfferService(new PromotionalOfferRepository(dbfactory),
         new PromotionalOfferDetailRepository(dbfactory),
         new UnitOfWork(dbfactory));
 }
        public async Task UpdateApprovalStatusForAllocationLine_ThenCallEndpointToScheduleJob()
        {
            // Arrange
            string specificationId = "abc123";

            PublishedAllocationLineResultStatusUpdateViewModel model = new PublishedAllocationLineResultStatusUpdateViewModel
            {
                Status    = AllocationLineStatusViewModel.Approved,
                Providers = new List <PublishedAllocationLineResultStatusUpdateProviderViewModel>()
            };

            IAuthorizationHelper authorizationHelper = Substitute.For <IAuthorizationHelper>();

            authorizationHelper
            .DoesUserHavePermission(Arg.Any <ClaimsPrincipal>(), Arg.Is(specificationId), Arg.Is(SpecificationActionTypes.CanApproveFunding))
            .Returns(true);

            IResultsApiClient resultsClient = CreateResultsClient();

            ApprovalController controller = CreateApprovalController(resultsClient: resultsClient, authorizationHelper: authorizationHelper);

            // Act
            IActionResult result = await controller.UpdateApprovalStatusForAllocationLine(specificationId, model);

            // Assert
            result.Should().BeOfType <OkResult>();

            await resultsClient
            .Received(1)
            .UpdatePublishedAllocationLineStatus(Arg.Is(specificationId), Arg.Any <PublishedAllocationLineResultStatusUpdateModel>());
        }
 public void SetUp()
 {
     _autoSubstitute = AutoSubstituteContainer.Create();
     _controller = _autoSubstitute.GetController<ApprovalController>();
     _dataCollectionRepository = _autoSubstitute.Resolve<IDataCollectionRepository>();
     _hashCodeRepository = _autoSubstitute.Resolve<IDataCollectionHashCodeRepository>();
     _lookup = _autoSubstitute.Resolve<ICurtinUserService>();
     _bus = _autoSubstitute.Resolve<IBus>();
     _projectRepository = _autoSubstitute.Resolve<IProjectRepository>();
 }
Exemplo n.º 10
0
 public void SetUp()
 {
     _autoSubstitute           = AutoSubstituteContainer.Create();
     _controller               = _autoSubstitute.GetController <ApprovalController>();
     _dataCollectionRepository = _autoSubstitute.Resolve <IDataCollectionRepository>();
     _hashCodeRepository       = _autoSubstitute.Resolve <IDataCollectionHashCodeRepository>();
     _lookup            = _autoSubstitute.Resolve <ICurtinUserService>();
     _bus               = _autoSubstitute.Resolve <IBus>();
     _projectRepository = _autoSubstitute.Resolve <IProjectRepository>();
 }
        /// <summary>
        /// Show a single SR summary with all available next actions
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public ActionResult ShowServiceRequest(int id)
        {
            ServiceRequestStateChangeModel model = ServiceRequestSummaryHelper.CreateStateChangeModel(_portfolioService, UserId, _serviceRequestController, id);

            if (model.ServiceRequestModel == null)
            {
                return(View("ConfirmServiceRequestStateChange", model));
            }

            //check for an sr approval
            IApprovalController approvalController = new ApprovalController();

            try
            {
                model.ServiceRequestModel.Approval = approvalController.GetApprovalForServiceRequest(UserId, id);
            }
            catch (Exception) { }
            //resolve display names to Guids
            //requestees
            if (model.ServiceRequestModel.ServiceRequest.RequestedForGuids != null)
            {
                List <string> displayNames = new List <string>();
                foreach (var userGuidstring in model.ServiceRequestModel.ServiceRequest.RequestedForGuids.Split(','))
                {
                    if (userGuidstring != "")                       //get names from ad
                    {
                        try
                        {
                            displayNames.Add(_userManager.GetDisplayName(Guid.Parse(userGuidstring)));
                        }
                        catch (Exception)
                        {
                            displayNames.Add("Name not found");
                        }
                    }
                }
                model.ServiceRequestModel.RequesteeDisplayNames = displayNames.OrderBy(x => x);
            }
            //requestor
            try
            {
                model.ServiceRequestModel.RequestorDisplayName = _userManager.GetDisplayName(_userManager.GetUser(UserId, model.ServiceRequestModel.Requestor).AdGuid);
            }
            catch (Exception)
            {
                model.ServiceRequestModel.RequestorDisplayName = "Name not found";
            }
            // business logic
            model.CanEditServiceRequest = _requestManager.UserCanEditRequest(UserId, model.ServiceRequestModel.ServiceRequest.Id);
            model.CanEditServiceRequest = _requestManager.UserCanEditRequest(UserId, model.ServiceRequestModel.ServiceRequest.Id);
            model.AvailableStates       = _requestManager.ValidStates(UserId, id);
            return(View("ConfirmServiceRequestStateChange", model));
        }
Exemplo n.º 12
0
 public static IMapper GetMapper(this ApprovalController account)
 {
     return((new MapperConfiguration(cfg =>
     {
         cfg.CreateMap <ApprovalDocumentViewModel, ApprovalDocumentDTO>();
         cfg.CreateMap <ApprovalDocumentDTO, ApprovalDocumentViewModel>();
         cfg.CreateMap <DocumentDTO, DocumentViewModel>();
         cfg.CreateMap <DocumentViewModel, DocumentDTO>();
         cfg.CreateMap <LogsDTO, LogsViewModel>();
         cfg.CreateMap <LogsViewModel, LogsDTO>();
         cfg.CreateMap <DatasetFieldDTO, FieldDatasetViewModel>();
         cfg.CreateMap <FieldDatasetViewModel, DatasetFieldDTO>();
     })).CreateMapper());
 }
Exemplo n.º 13
0
        public DamageController()
        {
            var dbfactory = new DatabaseFactory();
            _DamageService = new DamageService(new InvDamageRepository(dbfactory),
                new NotificationRepository(dbfactory),
                new NotificationDetailRepository(dbfactory),
                new InvDamageApprovalRepository(dbfactory), new UnitOfWork(dbfactory));
            _approvalController = new ApprovalController<InvDamageApproval, InvDamage>(_DamageService);

            _SecCompanyService = new SecCompanyService(new SecCompanyRepository(dbfactory), new UnitOfWork(dbfactory));
            _DamageDetailService = new DamageDetailService(new InvDamageDetailRepository(dbfactory), new UnitOfWork(dbfactory));

            //approval controller - to control all approvals
        }
 public RequisitionController()
 {
     var dbfactory = new DatabaseFactory();
     _RequisitionService = new RequisitionService(new RequisitionRepository(dbfactory),
         new RequisitionApprovalRepository(dbfactory),
         new NotificationRepository(dbfactory), new NotificationDetailRepository(dbfactory),
         new UnitOfWork(dbfactory));
     _SecCompanyService = new SecCompanyService(new SecCompanyRepository(dbfactory), new UnitOfWork(dbfactory));
     _officeService = new OfficeService(new OfficeRepository(dbfactory), new UnitOfWork(dbfactory));
     _hrmEmployeeService = new HrmEmployeeService(new HrmEmployeeRepository(dbfactory), new UnitOfWork(dbfactory));
     _RequisitionDetailService = new RequisitionDetailService(new RequisitionDetailRepository(dbfactory), new UnitOfWork(dbfactory));
     //approval controller - to control all approvals
     _approvalController = new ApprovalController<InvRequisitionApproval, InvRequisitionViewModel>(_RequisitionService);
 }
 //
 // GET: /Sales/RouteSetup/
 public RouteSetupController()
 {
     var dbfactory = new DatabaseFactory();
     var unitOfWork = new UnitOfWork(dbfactory);
     _service = new RouteSetupService(new RouteSetupRepository(dbfactory),
         new RouteSetupDetailRepository(dbfactory), new UnitOfWork(dbfactory));
     _routePlanService = new RoutePlanService(new RoutePlanRepository(dbfactory), new RoutePlanDetailRepository(dbfactory),
         new RoutePlanApprovalRepository(dbfactory), new NotificationRepository(dbfactory),
         new NotificationDetailRepository(dbfactory), new UnitOfWork(dbfactory));
     _approvalController = new ApprovalController<SlsRoutePlanApproval, SlsRoutePlan>(_routePlanService);
     _distributorservice = new DistributorService(new DistributorRepository(dbfactory), unitOfWork);
     _retailerservice = new RetailerService(new RetailerRepository(dbfactory), unitOfWork);
     _delearservice = new DealerService(new DealerRepository(dbfactory), unitOfWork);
     _corporateclientservice = new CorporateClientService(new CorporateClientRepository(dbfactory), unitOfWork);
 }
        public async Task PublishedProviderProfile_CallsSucceed_ReturnsOK()
        {
            //Arrange
            var resultsApiClient    = Substitute.For <IResultsApiClient>();
            var specsApiClient      = Substitute.For <ISpecsApiClient>();
            var mapper              = Substitute.For <IMapper>();
            var authorizationHelper = Substitute.For <IAuthorizationHelper>();

            var callContent  = new PublishedProviderProfile[] { };
            var callResult   = new ApiResponse <IEnumerable <PublishedProviderProfile> >(HttpStatusCode.OK, callContent);
            var mappedResult = new[] { new PublishedProviderProfileViewModel() };

            resultsApiClient
            .GetPublishedProviderProfile(Arg.Any <string>(), Arg.Any <string>(), Arg.Any <string>())
            .Returns(callResult);

            mapper
            .Map <IEnumerable <PublishedProviderProfileViewModel> >(callResult.Content)
            .Returns(mappedResult);

            var controller = new ApprovalController(resultsApiClient, specsApiClient, mapper, authorizationHelper);

            var providerId      = "p";
            var specificationId = "s";
            var fundingStreamId = "f";

            //Act
            var result = await controller.PublishedProviderProfile(providerId, specificationId, fundingStreamId);

            //Assert
            await resultsApiClient
            .Received(1)
            .GetPublishedProviderProfile(providerId, specificationId, fundingStreamId);

            mapper
            .Received(1)
            .Map <IEnumerable <PublishedProviderProfileViewModel> >(callContent);

            result
            .Should()
            .BeOfType(typeof(OkObjectResult));

            var value = (result as OkObjectResult).Value;

            value.Should().Be(mappedResult);
        }
 public CorporateSalesController()
 {
     var dbfactory = new DatabaseFactory();
     _service = new CorporateSalesService(new CorporateSalesRepository(dbfactory), new CorporateSalesDetailRepository(dbfactory),
         new CorporateSalesApprovalRepository(dbfactory), new NotificationRepository(dbfactory), new NotificationDetailRepository(dbfactory),
         new UnitOfWork(dbfactory));
     _approvalController = new ApprovalController<SlsCorporateSalesApproval, SlsCorporateSalesApplication>(_service);
     _SecCompanyService = new SecCompanyService(new SecCompanyRepository(dbfactory), new UnitOfWork(dbfactory));
     _officeService = new OfficeService(new OfficeRepository(dbfactory), new UnitOfWork(dbfactory));
     _hrmEmployeeService = new HrmEmployeeService(new HrmEmployeeRepository(dbfactory), new UnitOfWork(dbfactory));
     _CorporateClientService = new CorporateClientService(new CorporateClientRepository(dbfactory), new UnitOfWork(dbfactory));
     _salesOrderService = new SalesOrderService(new SalesOrderRepository(dbfactory),
         new SalesOrderDetailRepository(dbfactory),
         new SalesOrderApprovalRepository(dbfactory),
         new NotificationRepository(dbfactory),
         new NotificationDetailRepository(dbfactory),
         new UnitOfWork(dbfactory));
 }
        public async Task RefreshPublishedResults_WhenUserDoesNotHaveRefreshFundingPermission_ThenReturn403()
        {
            // Arrange
            string specificationId = "abc123";

            IAuthorizationHelper authorizationHelper = Substitute.For <IAuthorizationHelper>();

            authorizationHelper
            .DoesUserHavePermission(Arg.Any <ClaimsPrincipal>(), Arg.Is(specificationId), Arg.Is(SpecificationActionTypes.CanRefreshFunding))
            .Returns(false);

            ApprovalController controller = CreateApprovalController(authorizationHelper: authorizationHelper);

            // Act
            IActionResult result = await controller.RefreshPublishedResults(specificationId);

            // Assert
            result.Should().BeOfType <ForbidResult>();
        }
        public void PublishedProviderProfile_MissingData_Errors(string providerId, string specificationId, string fundingStreamId, string parameterName)
        {
            //Arrange
            var resultsApiClient    = Substitute.For <IResultsApiClient>();
            var specsApiClient      = Substitute.For <ISpecsApiClient>();
            var mapper              = Substitute.For <IMapper>();
            var authorizationHelper = Substitute.For <IAuthorizationHelper>();

            var controller = new ApprovalController(resultsApiClient, specsApiClient, mapper, authorizationHelper);

            //Act
            Func <Task> action = async() =>
                                 await controller.PublishedProviderProfile(providerId, specificationId, fundingStreamId);

            //Assert
            action
            .Should().Throw <ArgumentNullException>()
            .WithMessage($"Value cannot be null.{Environment.NewLine}Parameter name: {parameterName}");

            resultsApiClient.Received(0).GetPublishedProviderResults(Arg.Any <string>(), Arg.Any <string>(), Arg.Any <string>());
            mapper.Received(0).Map <IEnumerable <PublishedProviderProfileViewModel> >(Arg.Any <IEnumerable <PublishedProviderProfile> >());
        }
        public async Task PublishedProviderProfile_ClientCallFails_ReturnsError(HttpStatusCode statusCode, Type actionResultType)
        {
            //Arrange
            var resultsApiClient    = Substitute.For <IResultsApiClient>();
            var specsApiClient      = Substitute.For <ISpecsApiClient>();
            var mapper              = Substitute.For <IMapper>();
            var authorizationHelper = Substitute.For <IAuthorizationHelper>();

            var callResult = new ApiResponse <IEnumerable <PublishedProviderProfile> >(statusCode);

            resultsApiClient
            .GetPublishedProviderProfile(Arg.Any <string>(), Arg.Any <string>(), Arg.Any <string>())
            .Returns(callResult);

            var controller = new ApprovalController(resultsApiClient, specsApiClient, mapper, authorizationHelper);

            var providerId      = "p";
            var specificationId = "s";
            var fundingStreamId = "f";

            //Act
            var result = await controller.PublishedProviderProfile(providerId, specificationId, fundingStreamId);

            //Assert
            await resultsApiClient
            .Received(1)
            .GetPublishedProviderProfile(providerId, specificationId, fundingStreamId);

            mapper
            .Received(0)
            .Map <IEnumerable <PublishedProviderProfileViewModel> >(Arg.Any <IEnumerable <PublishedProviderProfile> >());

            result
            .Should()
            .BeOfType(actionResultType);
        }
        public async Task RefreshPublishedResults_WhenUserDoesHaveRefreshFundingPermission_ThenActionAllowed()
        {
            // Arrange
            string specificationId = "abc123";

            IAuthorizationHelper authorizationHelper = Substitute.For <IAuthorizationHelper>();

            authorizationHelper
            .DoesUserHavePermission(Arg.Any <ClaimsPrincipal>(), Arg.Is(specificationId), Arg.Is(SpecificationActionTypes.CanRefreshFunding))
            .Returns(true);

            ISpecsApiClient specsClient = CreateSpecsClient();

            specsClient.RefreshPublishedResults(Arg.Is(specificationId))
            .Returns(new ApiResponse <SpecificationCalculationExecutionStatusModel>(HttpStatusCode.OK, new SpecificationCalculationExecutionStatusModel()));

            ApprovalController controller = CreateApprovalController(specsClient: specsClient, authorizationHelper: authorizationHelper);

            // Act
            IActionResult result = await controller.RefreshPublishedResults(specificationId);

            // Assert
            result.Should().BeOfType <OkObjectResult>();
        }
        public async Task UpdateApprovalStatusForAllocationLine_WhenUserDoesNotHaveApproveFundingPermission_ThenReturn403()
        {
            // Arrange
            string specificationId = "abc123";

            PublishedAllocationLineResultStatusUpdateViewModel model = new PublishedAllocationLineResultStatusUpdateViewModel
            {
                Status = AllocationLineStatusViewModel.Approved
            };

            IAuthorizationHelper authorizationHelper = Substitute.For <IAuthorizationHelper>();

            authorizationHelper
            .DoesUserHavePermission(Arg.Any <ClaimsPrincipal>(), Arg.Is(specificationId), Arg.Is(SpecificationActionTypes.CanApproveFunding))
            .Returns(false);

            ApprovalController controller = CreateApprovalController(authorizationHelper: authorizationHelper);

            // Act
            IActionResult result = await controller.UpdateApprovalStatusForAllocationLine(specificationId, model);

            // Assert
            result.Should().BeOfType <ForbidResult>();
        }
Exemplo n.º 23
0
 public SoleVendorApprovalPresenter([CreateNew] ApprovalController controller, [CreateNew] SettingController settingcontroller, [CreateNew] AdminController admincontroller)
 {
     _controller        = controller;
     _settingController = settingcontroller;
     _admincontroller   = admincontroller;
 }
 public PurchaseApprovalDetailPresenter([CreateNew] ApprovalController controller, [CreateNew] Setting.SettingController settingcontroller, [CreateNew] AdminController admincontroller)
 {
     _controller        = controller;
     _settingcontroller = settingcontroller;
     _admincontroller   = admincontroller;
 }