示例#1
0
        /// <summary>
        /// Search Country by id.
        /// </summary>
        /// <param name="request">The Country Request Pivot to retrive.</param>
        /// <returns>Country Response Pivot response.</returns>
        public CountryResponsePivot FindCountries(CountryRequestPivot request)
        {
            if (request == null)
            {
                throw new ArgumentNullException(nameof(request));
            }
            List <CountryPivot> results = new List <CountryPivot>();
            CountryPivot        result  = new CountryPivot();

            switch (request.FindCountryPivot)
            {
            case FindCountryPivot.CountryId:
                result = _unitOfWork.CountryRepository.GetById(request.CountryPivot.CountryId)?.ToPivot();
                break;

            case FindCountryPivot.CountryCode:
                result = _unitOfWork.CountryRepository.Get(c => c.CountryCode == request.CountryPivot.CountryCode).FirstOrDefault().ToPivot();
                break;

            case FindCountryPivot.CountryShortName:
                result = _unitOfWork.CountryRepository.Get(c => c.CountryShortName == request.CountryPivot.CountryShortName).FirstOrDefault().ToPivot();
                break;
            }
            return(new CountryResponsePivot
            {
                CountryPivotList = results,
                CountryPivot = result
            });
        }
示例#2
0
 /// <summary>
 ///    From Country Pivot To Country Dto.
 /// </summary>
 /// <param name="countryPivot">country pivot to assemble.</param>
 /// <returns>CountryDto result.</returns>
 public static CountryDto ToDto(this CountryPivot countryPivot)
 {
     if (countryPivot == null)
     {
         return(null);
     }
     return(new CountryDto
     {
         CountryShortName = countryPivot.CountryShortName,
         CountryImage = countryPivot.CountryImage,
         CountryCode = countryPivot.CountryCode,
         CountryId = countryPivot.CountryId
     });
 }