Example #1
0
        /// <summary>
        /// Fetch the post code for Basic Search.
        /// </summary>
        /// <param name="searchText">Text to search</param>
        /// <param name="userUnit">Guid</param>
        /// <returns>
        /// Task
        /// </returns>
        public async Task <IEnumerable <PostcodeDTO> > GetPostcodeUnitForBasicSearch(string searchText, Guid userUnit)
        {
            string methodName = typeof(UnitLocationBusinessService) + "." + nameof(GetPostcodeUnitForBasicSearch);

            using (loggingHelper.RMTraceManager.StartTrace("Business.GetPostcodeUnitForBasicSearch"))
            {
                loggingHelper.LogMethodEntry(methodName, LoggerTraceConstants.UnitManagerAPIPriority, LoggerTraceConstants.UnitManagerBusinessServiceMethodEntryEventId);

                // reference data value for Postcode with Category - Postcode Type
                Guid postcodeTypeGUID           = unitManagerIntegrationService.GetReferenceDataGuId(PostCodeType, PostCodeTypeCategory.Postcode.GetDescription()).Result;
                SearchInputDataDto searchInputs = new SearchInputDataDto
                {
                    SearchText         = searchText,
                    UserUnitLocationId = userUnit,
                    PostcodeTypeGUID   = postcodeTypeGUID,
                    SearchResultCount  = SearchResultCount
                };

                var postcodeUnits = await postCodeDataService.GetPostcodeUnitForBasicSearch(searchInputs).ConfigureAwait(false);

                List <PostcodeDTO> postCodeList = postcodeUnits.Select(x => new PostcodeDTO
                {
                    PostcodeUnit = x.PostcodeUnit
                }).ToList();

                loggingHelper.LogMethodExit(methodName, LoggerTraceConstants.UnitManagerAPIPriority, LoggerTraceConstants.UnitManagerBusinessServiceMethodExitEventId);
                return(postCodeList);
            }
        }
        public async Task Test_FetchPostCodeUnitForBasicSearchValid()
        {
            var actualResult = await testCandidate.GetPostcodeUnitForBasicSearch(searchInputDataDto);

            Assert.IsNotNull(actualResult);
            Assert.IsTrue(actualResult.ToList().Count == 1);
        }