Ejemplo n.º 1
0
        /// <summary>
        /// Retrieve a specific Border.
        /// 1- Check consistancy
        ///     1.2- Create Task on GetBorder's repository action
        ///     1.3- Return Result action with no more processing
        /// 2- Throw Exception if consistancy is KO.
        /// </summary>
        /// <param name="borderID">a BorderID to retrieve.</param>
        /// <returns>The border with ID.
        /// Throw MemberAccessException if repository is null.</returns>
        public async Task <HRBorder> GetBorderAsync(String borderID)
        {
            HRBorder retour = null;

            //1-
            if (_bordersRepository != null)
            {
                //1.2-
                using (Task <HRBorder> bordersTask = _bordersRepository.GetAsync(borderID))
                {
                    await bordersTask;
                    //1.3-
                    retour = bordersTask.Result;
                }
            }
            //2-
            else
            {
                if (_logger != null)
                {
                    _logger.LogError("_bordersRepository is null in HRCoreBordersServices");
                }
                throw new MemberAccessException();
            }
            return(retour);
        }
        /// <summary>
        /// 1- If reposiory is available
        //  1.1- Launch asynchronous GetCountries on repository
        //  1.2- Give back thread availability waiting for result
        //  1.3- Get back result when wee get it.
        //  2- Else, return basic Exception in this very first version
        /// </summary>
        /// <param name="id">the ISO2 or ISO23 code</param>
        /// <returns>The corresponding Countries. Can throw MemberAccessException if repository is null.</returns>
        public async Task <HRCountry> GetCountryAsync(String id = null)
        {
            HRCountry retour = null;

            //1-
            if (_countryRepository != null)
            {
                //1.1-
                using (Task <HRCountry> countryTask = _countryRepository.GetAsync(id))
                {
                    //1.2-
                    await countryTask;
                    //1.3-
                    retour = countryTask.Result;
                }
            }
            else
            {
                if (_logger != null)
                {
                    _logger.LogError("_repository is null in CoreCountriesService:GetCountryAsync");
                }
                //2-
                throw new MemberAccessException("CoreCountriesService initialization failed..");
            }
            return(retour);
        }
 /// <summary>
 /// Retrieve a specific Border.
 /// 1- Check consistancy
 ///     1.2- Create Task on GetBorder's repository action
 ///     1.3- Return Result action with no more processing
 /// 2- Throw Exception if consistancy is KO.
 /// </summary>
 /// <param name="borderID">a BorderID to retrieve.</param>
 /// <returns>The border with ID.
 /// Throw MemberAccessException if repository is null.</returns>
 public async Task <HRBorder> GetBorderAsync(String borderID)
 {
     //1-
     if (_bordersRepository != null)
     {
         //1.2-
         Task <HRBorder> bordersTask = _bordersRepository.GetAsync(borderID);
         await           bordersTask;
         //1.3-
         return(bordersTask.Result);
     }
     //2-
     else
     {
         throw new MemberAccessException();
     }
 }
Ejemplo n.º 4
0
 /// <summary>
 /// 1- If reposiory is available
 //  1.1- Launch asynchronous GetCountries on repository
 //  1.2- Give back thread availability waiting for result
 //  1.3- Get back result when wee get it.
 //  2- Else, return basic Exception in this very first version
 /// </summary>
 /// <param name="id">the MondoDB ID (hexadecimal)</param>
 /// <returns>The corresponding Countries. Can throw MemberAccessException if repository is null.</returns>
 public async Task <HRCountry> GetCountryAsync(String id = null)
 {
     //1-
     if (_repository != null)
     {
         //1.1-
         Task <HRCountry> countryTask = _repository.GetAsync(id);
         //1.2-
         HRCountry retour = await countryTask;
         //1.3-
         return(retour);
     }
     else
     {
         //2-
         throw new MemberAccessException("CoreCountriesService initialization failed..");
     }
 }