public DynamicsController(
            ILogger <DocumentController> logger,
            IOptions <AppOptions> appOptions,
            IDocumentService documentService,
            IOpportunityService opportunityService,
            IGraphClientAppContext graphClientAppContext,
            IOneDriveLinkService oneDriveLinkService,
            IConfiguration configuration,
            IDynamicsLinkService dynamicsLinkService,
            IProposalManagerClientFactory proposalManagerClientFactory) : base(logger, appOptions)
        {
            this.oneDriveLinkService          = oneDriveLinkService;
            this.graphClientAppContext        = graphClientAppContext;
            this.dynamicsLinkService          = dynamicsLinkService;
            this.opportunityService           = opportunityService;
            this.proposalManagerClientFactory = proposalManagerClientFactory;

            oneDriveConfiguration = new OneDriveConfiguration();
            configuration.Bind(OneDriveConfiguration.ConfigurationName, oneDriveConfiguration);

            dynamicsConfiguration = new Dynamics365Configuration();
            configuration.Bind(Dynamics365Configuration.ConfigurationName, dynamicsConfiguration);

            proposalManagerConfiguration = new ProposalManagerConfiguration();
            configuration.Bind(ProposalManagerConfiguration.ConfigurationName, proposalManagerConfiguration);
        }
        public When_Single_Item_Opportunity_Basket_Confirm_Delete_Opportunity_Item_Is_Loaded()
        {
            var config = new MapperConfiguration(c => c.AddMaps(typeof(OpportunityMapper).Assembly));

            var mapper = new Mapper(config);

            _opportunityService = Substitute.For <IOpportunityService>();
            _opportunityService.GetConfirmDeleteOpportunityItemAsync(1).Returns(new ConfirmDeleteOpportunityItemViewModel
            {
                OpportunityItemId = 1,
                OpportunityId     = 2,
                CompanyName       = "Company Name",
                CompanyNameAka    = "Also Known As",
                Postcode          = "PostCode",
                JobRole           = "JobRole",
                BasketItemCount   = 1,
                Placements        = 1,
            });

            var opportunityController = new OpportunityController(_opportunityService, mapper);
            var controllerWithClaims  = new ClaimsBuilder <OpportunityController>(opportunityController)
                                        .AddUserName("CreatedBy")
                                        .Build();

            _result = controllerWithClaims.GetConfirmDeleteOpportunityItemAsync(1).GetAwaiter().GetResult();
        }
예제 #3
0
        public When_Recording_Referrals_And_Employer_Details_Is_Submitted_Successfully()
        {
            _opportunityService = Substitute.For <IOpportunityService>();
            _opportunityService.IsReferralOpportunityItemAsync(OpportunityItemId).Returns(true);

            var httpContextAccessor = Substitute.For <IHttpContextAccessor>();
            var referralService     = Substitute.For <IReferralService>();

            var config = new MapperConfiguration(c =>
            {
                c.AddMaps(typeof(EmployerDtoMapper).Assembly);
                c.ConstructServicesUsing(type =>
                                         type.Name.Contains("LoggedInUserEmailResolver") ?
                                         new LoggedInUserEmailResolver <EmployerDetailsViewModel, EmployerDetailDto>(httpContextAccessor) :
                                         type.Name.Contains("LoggedInUserNameResolver") ?
                                         (object)new LoggedInUserNameResolver <EmployerDetailsViewModel, EmployerDetailDto>(httpContextAccessor) :
                                         type.Name.Contains("UtcNowResolver") ?
                                         new UtcNowResolver <EmployerDetailsViewModel, EmployerDetailDto>(new DateTimeProvider()) :
                                         null);
            });
            var mapper = new Mapper(config);

            var employerController   = new EmployerController(null, _opportunityService, referralService, mapper);
            var controllerWithClaims = new ClaimsBuilder <EmployerController>(employerController)
                                       .AddStandardUser()
                                       .AddUserName(ModifiedBy)
                                       .Build();

            httpContextAccessor.HttpContext.Returns(controllerWithClaims.HttpContext);

            _result = controllerWithClaims.SaveOpportunityEmployerDetailsAsync(_viewModel).GetAwaiter().GetResult();
        }
예제 #4
0
        public When_Employer_Consent_Is_Loaded()
        {
            var config          = new MapperConfiguration(c => c.AddMaps(typeof(EmployerDtoMapper).Assembly));
            var referralService = Substitute.For <IReferralService>();
            var mapper          = new Mapper(config);

            _employerService = Substitute.For <IEmployerService>();
            _employerService.GetOpportunityEmployerDetailAsync(Arg.Any <int>(), Arg.Any <int>()).Returns(new EmployerDetailsViewModel
            {
                OpportunityId     = 1,
                OpportunityItemId = 2,
                CompanyName       = "CompanyName",
                AlsoKnownAs       = "CompanyNameAka",
                PrimaryContact    = "EmployerContact",
                Phone             = "EmployerContactPhone",
                Email             = "EmployerContactEmail"
            });

            _opportunityService = Substitute.For <IOpportunityService>();
            _opportunityService.GetReferredOpportunityItemCountAsync(1).Returns(10);

            var employerController = new EmployerController(_employerService, _opportunityService, referralService, mapper);

            _result = employerController.GetEmployerConsentAsync(1, 2).GetAwaiter().GetResult();
        }
예제 #5
0
 public CallLogController(
     ICallCategoryService CallCategoryService,
     ICallStatusService CallStatusService,
     ICallTypeService CallTypeService,
     ICustomerService CustomerService,
     ICallEmotionService CallEmotionService,
     ICallLogService CallLogService,
     IEntityReferenceService EntityReferenceService,
     IAppUserService AppUserService,
     ICustomerLeadService CustomerLeadService,
     IContactService ContactService,
     ICompanyService CompanyService,
     IOrganizationService OrganizationService,
     IOpportunityService OpportunityService,
     ICurrentContext CurrentContext
     , IHttpContextAccessor httpContextAccessor, DataContext _DataContext
     ) : base(httpContextAccessor, _DataContext)
 {
     this.CallCategoryService    = CallCategoryService;
     this.CallStatusService      = CallStatusService;
     this.CallTypeService        = CallTypeService;
     this.CustomerService        = CustomerService;
     this.CallEmotionService     = CallEmotionService;
     this.CallLogService         = CallLogService;
     this.EntityReferenceService = EntityReferenceService;
     this.AppUserService         = AppUserService;
     this.CustomerLeadService    = CustomerLeadService;
     this.ContactService         = ContactService;
     this.CompanyService         = CompanyService;
     this.OrganizationService    = OrganizationService;
     this.OpportunityService     = OpportunityService;
     this.CurrentContext         = CurrentContext;
 }
        public When_Opportunity_Controller_Save_ProvisionGap_Update_Opportunity()
        {
            const int opportunityId = 1;

            _opportunityService = Substitute.For <IOpportunityService>();
            _opportunityService.IsNewProvisionGapAsync(opportunityId).Returns(false);

            var httpContextAccessor = Substitute.For <IHttpContextAccessor>();

            var config = new MapperConfiguration(c =>
            {
                c.AddMaps(typeof(EmployerDtoMapper).Assembly);
                c.ConstructServicesUsing(type =>
                                         type.Name.Contains("LoggedInUserEmailResolver") ?
                                         new LoggedInUserEmailResolver <SaveProvisionGapViewModel, OpportunityDto>(httpContextAccessor) :
                                         type.Name.Contains("LoggedInUserNameResolver") ?
                                         (object)new LoggedInUserNameResolver <SaveProvisionGapViewModel, OpportunityDto>(httpContextAccessor) :
                                         type.Name.Contains("UtcNowResolver") ?
                                         new UtcNowResolver <SaveProvisionGapViewModel, OpportunityDto>(new DateTimeProvider()) :
                                         null);
            });
            var mapper = new Mapper(config);

            var opportunityController = new OpportunityController(_opportunityService, mapper);
            var controllerWithClaims  = new ClaimsBuilder <OpportunityController>(opportunityController)
                                        .AddUserName(UserName)
                                        .AddEmail(Email)
                                        .Build();

            httpContextAccessor.HttpContext.Returns(controllerWithClaims.HttpContext);

            _result = controllerWithClaims.SaveProvisionGapAsync(new SaveProvisionGapViewModel {
                SearchResultProviderCount = 0, SelectedRouteId = 1, Postcode = "cv12wt", SearchRadius = 10
            }).GetAwaiter().GetResult();
        }
예제 #7
0
        public When_Recording_Referrals_And_Check_Answers_Is_Submitted_Successfully()
        {
            var httpContextAccessor = Substitute.For <IHttpContextAccessor>();

            var config = new MapperConfiguration(c =>
            {
                c.AddMaps(typeof(CheckAnswersDtoMapper).Assembly);
                c.ConstructServicesUsing(type =>
                                         type.Name.Contains("LoggedInUserEmailResolver") ?
                                         new LoggedInUserEmailResolver <CheckAnswersViewModel, CheckAnswersDto>(httpContextAccessor) :
                                         type.Name.Contains("LoggedInUserNameResolver") ?
                                         (object)new LoggedInUserNameResolver <CheckAnswersViewModel, CheckAnswersDto>(httpContextAccessor) :
                                         type.Name.Contains("UtcNowResolver") ?
                                         new UtcNowResolver <CheckAnswersViewModel, CheckAnswersDto>(new DateTimeProvider()) :
                                         null);
            });

            var mapper = new Mapper(config);

            _opportunityService = Substitute.For <IOpportunityService>();

            var opportunityController = new OpportunityController(_opportunityService, mapper);
            var controllerWithClaims  = new ClaimsBuilder <OpportunityController>(opportunityController)
                                        .AddUserName(ModifiedBy)
                                        .Build();

            httpContextAccessor.HttpContext.Returns(controllerWithClaims.HttpContext);

            _result = controllerWithClaims.SaveCheckAnswers(OpportunityId, OpportunityItemId).GetAwaiter().GetResult();
        }
 public OpportunityProximityController(IRoutePathService routePathService, IOpportunityProximityService opportunityProximityService, IOpportunityService opportunityService, ILocationService locationService)
 {
     _opportunityProximityService = opportunityProximityService;
     _routePathService            = routePathService;
     _opportunityService          = opportunityService;
     _locationService             = locationService;
 }
        public When_Opportunity_Basket_Is_Loaded_With_Referrals()
        {
            var config = new MapperConfiguration(c => c.AddMaps(typeof(OpportunityMapper).Assembly));

            var mapper = new Mapper(config);

            _opportunityService = Substitute.For <IOpportunityService>();
            _opportunityService.GetOpportunityBasketAsync(1).Returns(new OpportunityBasketViewModel
            {
                OpportunityId     = 1,
                CompanyName       = "Company Name",
                CompanyNameAka    = "Also Known As",
                ProvisionGapItems = null,
                ReferralItems     = new List <BasketReferralItemViewModel>
                {
                    new BasketReferralItemViewModel
                    {
                        OpportunityType   = "Referral",
                        OpportunityItemId = 5
                    }
                }
            });

            var opportunityController = new OpportunityController(_opportunityService, mapper);
            var controllerWithClaims  = new ClaimsBuilder <OpportunityController>(opportunityController)
                                        .AddUserName("CreatedBy")
                                        .Build();

            _result = controllerWithClaims.GetOpportunityBasketAsync(1, 0).GetAwaiter().GetResult();
        }
예제 #10
0
        public When_Placement_Information_Loaded()
        {
            var dto = new PlacementInformationSaveDto
            {
                OpportunityId       = OpportunityId,
                OpportunityItemId   = OpportunityItemId,
                JobRole             = JobRole,
                OpportunityType     = OpportunityType.Referral,
                CompanyName         = CompanyName,
                CompanyNameAka      = CompanyNameAka,
                PlacementsKnown     = PlacementsKnown,
                Placements          = Placements,
                NoSuitableStudent   = true,
                HadBadExperience    = true,
                ProvidersTooFarAway = true
            };

            var config = new MapperConfiguration(c => c.AddMaps(typeof(PlacementInformationSaveDtoMapper).Assembly));
            var mapper = new Mapper(config);

            _opportunityService = Substitute.For <IOpportunityService>();
            _opportunityService.GetPlacementInformationAsync(OpportunityItemId).Returns(dto);

            var opportunityController = new OpportunityController(_opportunityService, mapper);

            _result = opportunityController.GetPlacementInformationAsync(OpportunityItemId).GetAwaiter().GetResult();
        }
예제 #11
0
 public ServeService(IContactService contactService,
                     IContactRelationshipService contactRelationshipService,
                     IOpportunityService opportunityService,
                     MinistryPlatform.Translation.Services.Interfaces.IEventService eventService,
                     IParticipantService participantService,
                     IGroupParticipantService groupParticipantService,
                     IGroupService groupService,
                     ICommunicationService communicationService,
                     IAuthenticationService authenticationService,
                     IConfigurationWrapper configurationWrapper,
                     IApiUserService apiUserService,
                     IResponseService responseService)
 {
     _contactService = contactService;
     _contactRelationshipService = contactRelationshipService;
     _opportunityService = opportunityService;
     _eventService = eventService;
     _participantService = participantService;
     _groupParticipantService = groupParticipantService;
     _groupService = groupService;
     _communicationService = communicationService;
     _authenticationService = authenticationService;
     _configurationWrapper = configurationWrapper;
     _apiUserService = apiUserService;
     _responseService = responseService;
 }
 public OpportunityFormController(OpportunityForm instance)
 {
     this.frmOpportunity  = instance;
     this.srvOrganization = SamsaraAppContext.Resolve <IOrganizationService>();
     Assert.IsNotNull(this.srvOrganization);
     this.srvBidder = SamsaraAppContext.Resolve <IBidderService>();
     Assert.IsNotNull(this.srvBidder);
     this.srvDependency = SamsaraAppContext.Resolve <IDependencyService>();
     Assert.IsNotNull(this.srvDependency);
     this.srvEndUser = SamsaraAppContext.Resolve <IEndUserService>();
     Assert.IsNotNull(this.srvEndUser);
     this.srvAsesor = SamsaraAppContext.Resolve <IAsesorService>();
     Assert.IsNotNull(this.srvAsesor);
     this.srvTender = SamsaraAppContext.Resolve <ITenderService>();
     Assert.IsNotNull(this.srvTender);
     this.srvOpportunity = SamsaraAppContext.Resolve <IOpportunityService>();
     Assert.IsNotNull(this.srvOpportunity);
     this.srvOpportunityType = SamsaraAppContext.Resolve <IOpportunityTypeService>();
     Assert.IsNotNull(this.srvOpportunityType);
     this.srvOpportunityStatus = SamsaraAppContext.Resolve <IOpportunityStatusService>();
     Assert.IsNotNull(this.srvOpportunityStatus);
     this.srvManufacturer = SamsaraAppContext.Resolve <IManufacturerService>();
     Assert.IsNotNull(this.srvManufacturer);
     this.srvOpportunityLog = SamsaraAppContext.Resolve <IOpportunityLogService>();
     Assert.IsNotNull(this.srvOpportunityLog);
     this.InitializeFormControls();
 }
예제 #13
0
 public OpportunityForm()
 {
     InitializeComponent();
     this.ctrlOpportunityForm = new OpportunityFormController(this);
     this.srvOpportunity      = SamsaraAppContext.Resolve <IOpportunityService>();
     Assert.IsNotNull(this.srvOpportunity);
 }
예제 #14
0
 public ProposalsController(UserManager <User> userManager, IProposalService proposals, IOpportunityService opportunities, IAccountService accounts)
 {
     this.userManager   = userManager;
     this.proposals     = proposals;
     this.opportunities = opportunities;
     this.accounts      = accounts;
 }
예제 #15
0
        internal IFacadeUpdateResult <OpportunityData> SaveOpportunity(OpportunityDto dto)
        {
            ArgumentValidator.IsNotNull("dto", dto);

            FacadeUpdateResult <OpportunityData> result = new FacadeUpdateResult <OpportunityData>();
            IOpportunityService service  = UnitOfWork.GetService <IOpportunityService>();
            Opportunity         instance = RetrieveOrNew <OpportunityData, Opportunity, IOpportunityService>(result.ValidationResult, dto.Id);

            if (result.IsSuccessful)
            {
                instance.Name           = dto.Name;
                instance.Description    = dto.Description;
                instance.ContactId      = dto.ContactId;
                instance.CustomerId     = dto.CustomerId;
                instance.ProductId      = dto.ProductId;
                instance.EstimateAmount = dto.EstimateAmount;

                var saveQuery = service.Save(instance);

                result.AttachResult(instance.RetrieveData <OpportunityData>());
                result.Merge(saveQuery);
            }

            return(result);
        }
예제 #16
0
        /// <summary>
        /// Create an opportunity
        /// </summary>
        /// <param name="ownerPartyId"></param>
        /// <param name="orgExternalRef"></param>
        /// <param name="contactExternalRef"></param>
        /// <param name="name"></param>
        /// <returns></returns>
        public long?CreateOpportunity(long?ownerPartyId, long?orgExternalRef, long?contactExternalRef, string name)
        {
            IOpportunityService service = OpportunityService.GetService();
            OpportunityModel    model   = new OpportunityModel();

            model.Name = name;

            if (orgExternalRef != null)
            {
                model.TargetPartyId          = (long)orgExternalRef;
                model.TargetPartyIdSpecified = true;
            }

            model.OwnerResourcePartyId          = (long)ownerPartyId;
            model.OwnerResourcePartyIdSpecified = true;
            model.KeyContactId          = contactExternalRef;
            model.KeyContactIdSpecified = true;

            OpportunityResourceModel resourceModel = new OpportunityResourceModel();

            resourceModel.OwnerFlag           = true;
            resourceModel.OwnerFlagSpecified  = true;
            resourceModel.ResourceId          = (long)ownerPartyId;
            resourceModel.ResourceIdSpecified = true;

            model.OpportunityResourceModel = resourceModel;

            OpportunityModel result = service.CreateOpportunity(model);

            if (result != null && result.OpportunityId != null)
            {
                return(result.OpportunityId);
            }
            return(null);
        }
예제 #17
0
        public When_Opportunity_Controller_SaveSelectedOpportunities_Is_Called_With_No_Selected_Referrals()
        {
            _opportunityService = Substitute.For <IOpportunityService>();
            _opportunityService.GetOpportunityBasketAsync(1)
            .Returns(new OpportunityBasketViewModel());

            var config = new MapperConfiguration(c => c.AddMaps(typeof(EmployerDtoMapper).Assembly));
            var mapper = new Mapper(config);

            _opportunityController = new OpportunityController(_opportunityService, mapper);

            var controllerWithClaims = new ClaimsBuilder <OpportunityController>(_opportunityController).Build();

            _result = controllerWithClaims.SaveSelectedOpportunitiesAsync(new ContinueOpportunityViewModel
            {
                OpportunityId       = 1,
                SubmitAction        = "SaveSelectedOpportunities",
                SelectedOpportunity = new List <SelectedOpportunityItemViewModel>
                {
                    new SelectedOpportunityItemViewModel
                    {
                        IsSelected      = false,
                        OpportunityType = OpportunityType.Referral.ToString()
                    }
                }
            }).GetAwaiter().GetResult();
        }
 public OpportunityResponseSaveRequestValidator(IOpportunityService opportunityService)
 {
     RuleFor(u => u.OpportunityId)
     .NotEmpty()
     .MustAsync(async(or, c) => {
         return(await opportunityService.GetById(or, false) != null);
     }).WithMessage("{PropertyName} does not exist.");
 }
예제 #19
0
 public ActivitiesController(IActivityService activityService, ICampaignService campaignService, ICompanyService companyService, IContactService contactService, IOpportunityService opportunityService)
 {
     this.activityService    = activityService;
     this.campaignService    = campaignService;
     this.companyService     = companyService;
     this.contactService     = contactService;
     this.opportunityService = opportunityService;
 }
 public OpportunityController(
     ILogger <OpportunityController> logger,
     IOptions <AppOptions> appOptions,
     IOpportunityService opportunityService) : base(logger, appOptions)
 {
     Guard.Against.Null(opportunityService, nameof(opportunityService));
     _opportunityService = opportunityService;
 }
예제 #21
0
 public OpportunitiesController(IOpportunityService opportunityService, ICampaignSourceService campaignSourceService, ICompanyService companyService, IContactService contactService, ILeadSourceService leadSourceService, ICampaignService campaignService)
 {
     this.opportunityService    = opportunityService;
     this.campaignSourceService = campaignSourceService;
     this.companyService        = companyService;
     this.contactService        = contactService;
     this.leadSourceService     = leadSourceService;
     this.campaignService       = campaignService;
 }
 public AccountController()
 {
     _accountService = new AccountService(new ModelStateWrapper(this.ModelState));
     _userService = new UserService(new ModelStateWrapper(this.ModelState));
     _sectorService = new IndustrialSectorService(new ModelStateWrapper(this.ModelState));
     _taskService = new TaskService(new ModelStateWrapper(this.ModelState));
     _contactService = new ContactService(new ModelStateWrapper(this.ModelState));
     _opportunityService = new OpportunityService(new ModelStateWrapper(this.ModelState));
 }
예제 #23
0
        public When_Navigation_Controller_SaveEmployerOpportunity_Is_Called()
        {
            _opportunityService = Substitute.For <IOpportunityService>();
            var backLinkService = Substitute.For <INavigationService>();

            var navigationController = new NavigationController(_opportunityService, backLinkService);

            _result = navigationController.SaveEmployerOpportunityAsync(1).GetAwaiter().GetResult();
        }
예제 #24
0
        public When_Back_Component_Is_Loaded_With_Saved_Opportunities()
        {
            _opportunityService = Substitute.For <IOpportunityService>();
            _opportunityService.GetSavedOpportunityItemCountAsync(1).Returns(2);

            var viewComponent = new BackViewComponent(_opportunityService);

            _result = viewComponent.InvokeAsync(1, 2).GetAwaiter().GetResult();
        }
예제 #25
0
 public AccountController()
 {
     _accountService     = new AccountService(new ModelStateWrapper(this.ModelState));
     _userService        = new UserService(new ModelStateWrapper(this.ModelState));
     _sectorService      = new IndustrialSectorService(new ModelStateWrapper(this.ModelState));
     _taskService        = new TaskService(new ModelStateWrapper(this.ModelState));
     _contactService     = new ContactService(new ModelStateWrapper(this.ModelState));
     _opportunityService = new OpportunityService(new ModelStateWrapper(this.ModelState));
 }
 public EmployerController(IEmployerService employerService,
                           IOpportunityService opportunityService,
                           IReferralService referralService,
                           IMapper mapper)
 {
     _employerService    = employerService;
     _opportunityService = opportunityService;
     _referralService    = referralService;
     _mapper             = mapper;
 }
예제 #27
0
 public AccountController(IAccountService service, IUserService userService, IIndustrialSectorService sectorService,
                          ITaskService taskService, IContactService contactService, IOpportunityService opportunityService)
 {
     _accountService     = service;
     _userService        = userService;
     _sectorService      = sectorService;
     _taskService        = taskService;
     _contactService     = contactService;
     _opportunityService = opportunityService;
 }
 public AccountController(IAccountService service, IUserService userService, IIndustrialSectorService sectorService,
                          ITaskService taskService, IContactService contactService, IOpportunityService opportunityService)
 {
     _accountService = service;
     _userService = userService;
     _sectorService = sectorService;
     _taskService = taskService;
     _contactService = contactService;
     _opportunityService = opportunityService;
 }
예제 #29
0
 public OpportunityResponseBusiness(ILookupService lookupService, IFileService fileService, INotifyService notifyService, IKeyValueService keyValueService, IOpportunityResponseService opportunityResponseService, IOpportunityService opportunityService, IMapper mapper)
 {
     _lookupService              = lookupService;
     _fileService                = fileService;
     _notifyService              = notifyService;
     _keyValueService            = keyValueService;
     _opportunityResponseService = opportunityResponseService;
     _opportunityService         = opportunityService;
     _mapper = mapper;
 }
 public ContextController(
     ILogger <ContextController> logger,
     IOptions <AppOptions> appOptions,
     IContextService contextService,
     IOpportunityService opportunityService) : base(logger, appOptions)
 {
     Guard.Against.Null(contextService, nameof(contextService));
     Guard.Against.Null(opportunityService, nameof(opportunityService));
     _contextService     = contextService;
     _opportunityService = opportunityService;
 }
        public When_OpportunityProximity_Controller_Index_Is_Loaded()
        {
            var proximityOpportunityService = Substitute.For <IOpportunityProximityService>();
            var locationService             = Substitute.For <ILocationService>();
            var routeService = Substitute.For <IRoutePathService>();

            _opportunityService = Substitute.For <IOpportunityService>();

            var opportunityProximityController = new OpportunityProximityController(routeService, proximityOpportunityService, _opportunityService, locationService);

            _result = opportunityProximityController.Index().GetAwaiter().GetResult();
        }
예제 #32
0
        public OpportunityTestFixture()
        {
            var loggerRepository = new Logger <OpportunityRepository>(new NullLoggerFactory());
            var loggerOpportunityItemRepository = new Logger <GenericRepository <OpportunityItem> >(new NullLoggerFactory());
            var loggerProvisionGapRepository    = new Logger <GenericRepository <ProvisionGap> >(new NullLoggerFactory());
            var loggerReferralRepository        = new Logger <GenericRepository <Referral> >(new NullLoggerFactory());

            MatchingDbContext = new TestConfiguration().GetDbContext();

            var opportunityRepository     = new OpportunityRepository(loggerRepository, MatchingDbContext);
            var opportunityItemRepository = new GenericRepository <OpportunityItem>(loggerOpportunityItemRepository, MatchingDbContext);
            var provisionGapRepository    = new GenericRepository <ProvisionGap>(loggerProvisionGapRepository, MatchingDbContext);
            var referralRepository        = new GenericRepository <Referral>(loggerReferralRepository, MatchingDbContext);

            var googleMapsApiClient             = Substitute.For <IGoogleMapApiClient>();
            var opportunityPipelineReportWriter = Substitute.For <IFileWriter <OpportunityReportDto> >();
            var dateTimeProvider = Substitute.For <IDateTimeProvider>();

            var httpContextAccessor = Substitute.For <IHttpContextAccessor>();

            httpContextAccessor.HttpContext.Returns(new DefaultHttpContext
            {
                User = new ClaimsPrincipal(new ClaimsIdentity(new[]
                {
                    new Claim(ClaimTypes.GivenName, "adminUserName")
                }))
            });

            var config = new MapperConfiguration(c =>
            {
                c.AddMaps(typeof(OpportunityMapper).Assembly);
                c.ConstructServicesUsing(type =>
                                         type.Name.Contains("LoggedInUserEmailResolver") ?
                                         new LoggedInUserEmailResolver <OpportunityDto, Domain.Models.Opportunity>(httpContextAccessor) :
                                         type.Name.Contains("LoggedInUserNameResolver") ?
                                         (object)new LoggedInUserNameResolver <OpportunityDto, Domain.Models.Opportunity>(httpContextAccessor) :
                                         type.Name.Contains("UtcNowResolver") ?
                                         new UtcNowResolver <OpportunityDto, Domain.Models.Opportunity>(new DateTimeProvider()) :
                                         null);
            });
            var mapper = new Mapper(config);

            OpportunityService = new OpportunityService(
                mapper,
                opportunityRepository,
                opportunityItemRepository,
                provisionGapRepository,
                referralRepository,
                googleMapsApiClient,
                opportunityPipelineReportWriter,
                dateTimeProvider);
        }
        public When_Opportunity_Controller_Delete_Referral()
        {
            var config = new MapperConfiguration(c => c.AddMaps(typeof(CheckAnswersDtoMapper).Assembly));
            var mapper = new Mapper(config);

            _opportunityService = Substitute.For <IOpportunityService>();

            var opportunityController = new OpportunityController(_opportunityService, mapper);
            var controllerWithClaims  = new ClaimsBuilder <OpportunityController>(opportunityController)
                                        .AddUserName("CreatedBy")
                                        .Build();

            _result = controllerWithClaims.DeleteReferralAsync(ReferralIdToDelete, OpportunityItemId).GetAwaiter().GetResult();
        }
 public OpportunityController(IOpportunityService opportunityService)
 {
     _opportunityService = opportunityService;
 }
 public OpportunityController()
 {
     _opportunityService = new OpportunityService(new ModelStateWrapper(this.ModelState));
     _userService = new UserService(new ModelStateWrapper(this.ModelState));
     _accountService = new AccountService(new ModelStateWrapper(this.ModelState));
 }
 public OpportunityController(IOpportunityService service, IUserService userService, IAccountService accountService)
 {
     _opportunityService = service;
     _userService = userService;
     _accountService = accountService;
 }
예제 #37
0
 /// <summary>
 /// Initializes a new instance of the <see cref="CompanyController"/> class.
 /// </summary>
 /// <param name="loggerService">The logger service.</param>
 /// <param name="crmManagerService">The CRM manager service.</param>
 /// <param name="userService">The user service.</param>
 /// <param name="noteService">The note service.</param>
 /// <param name="commonService">The common service.</param>
 /// <param name="youfferMessageService">The youffer message service.</param>
 /// <param name="oppService">The opp service.</param>
 /// <param name="youfferContactService">The youffer contact service.</param>
 /// <param name="youfferLeadService">The youffer lead service.</param>
 /// <param name="youfferFeedbackService">The youffer feedback service.</param>
 /// <param name="mapperFactory">The Mapper Factory</param>
 /// <param name="youfferNoteService">The youffer note service.</param>
 /// <param name="youfferInterestService"> The youffer interest service </param>
 /// <param name="pushMessageService">The push message service</param>
 public CompanyController(ILoggerService loggerService, ICRMManagerService crmManagerService, IUserService userService, INoteService noteService, ICommonService commonService, IYoufferMessageService youfferMessageService, IOpportunityService oppService, IYoufferContactService youfferContactService, IYoufferLeadService youfferLeadService, IYoufferFeedbackService youfferFeedbackService, IMapperFactory mapperFactory, IYoufferNoteService youfferNoteService, IYoufferInterestService youfferInterestService, IPushMessageService pushMessageService)
     : base(loggerService)
 {
     this.mapperFactory = mapperFactory;
     this.crmManagerService = crmManagerService;
     this.userService = userService;
     this.noteService = noteService;
     this.commonService = commonService;
     this.youfferMessageService = youfferMessageService;
     this.oppService = oppService;
     this.youfferContactService = youfferContactService;
     this.youfferLeadService = youfferLeadService;
     this.youfferFeedbackService = youfferFeedbackService;
     this.youfferNoteService = youfferNoteService;
     this.youfferInterestService = youfferInterestService;
     this.pushMessageService = pushMessageService;
 }