Esempio n. 1
0
        public HttpResponseMessage All([FromBody] AllLookupRequest req)
        {
            var allLookupResponse = _lookupBusiness.All(req);

            var statusCode = allLookupResponse.ApiErrors == null ? HttpStatusCode.OK : HttpStatusCode.PartialContent;

            var response = Request.CreateResponse(statusCode, allLookupResponse);

            return(response);
        }
Esempio n. 2
0
        public AcApiResponse <AllLookupResponse, ApiData> All(AllLookupRequest req)
        {
            var respVm = new AllLookupResponse();
            int?flags  = null;

            var apiErrors = new Dictionary <string, string>();

            if (req.GetAllFieldsRequested)
            {
                try
                {
                    var fields = GetAllFields(req.GetAllFieldsReq);
                    respVm.GetAllFieldsResponse = fields.ResponseData;

                    flags = respVm.GetAllFieldsResponse?.Payload?.Flags;
                }
                catch (Exception e)
                {
                    apiErrors.Add("GetAllFields", e.Message);
                }
            }

            if (req.EnumerationsRequested)
            {
                try
                {
                    var enumerations = GetEnumerations(req.EnumerationReq);
                    respVm.GetEnumerationsResponse = enumerations.ResponseData;

                    flags = respVm.GetEnumerationsResponse?.Payload?.Flags;
                }
                catch (Exception e)
                {
                    apiErrors.Add("Enumerations", e.Message);
                }
            }

            if (req.ProfileRequested)
            {
                try
                {
                    var profile = _profileBusiness.Profile(req.ProfileReq);
                    respVm.ProfileResponse = profile.ResponseData;

                    flags = respVm.ProfileResponse?.Payload?.Flags;
                }
                catch (Exception e)
                {
                    apiErrors.Add("Profile", e.Message);
                }
            }

            if (req.CurrenciesRequested)
            {
                try
                {
                    var getCurrencyInfoResponse = GetCurrencyInfo(req.GetCurrencyInfoReq ?? new GetCurrencyInfoRequest());
                    respVm.GetCurrencyInfoResponse = getCurrencyInfoResponse.ResponseData;

                    flags = respVm.GetCurrencyInfoResponse?.Payload?.Flags;
                }
                catch (Exception e)
                {
                    apiErrors.Add("Currencies", e.Message);
                }
            }

            if (req.CountriesRequested)
            {
                try
                {
                    var getCountryInfoResponse = GetCountryInfo(req.GetCountryInfoReq ?? new GetCountryInfoRequest());
                    respVm.GetCountryInfoResponse = getCountryInfoResponse.ResponseData;

                    flags = respVm.GetCountryInfoResponse?.Payload?.Flags;
                }
                catch (Exception e)
                {
                    apiErrors.Add("Countries", e.Message);
                }
            }

            if (req.CountrySubdivisionsRequested)
            {
                try
                {
                    var getCountrySubdivisionResponse =
                        GetCountrySubdivision(req.GetCountrySubdivisionReq ?? new GetCountrySubdivisionRequest());
                    respVm.GetCountrySubdivisionResponse = getCountrySubdivisionResponse.ResponseData;

                    flags = respVm.GetCountrySubdivisionResponse?.Payload?.Flags;
                }
                catch (Exception e)
                {
                    apiErrors.Add("CountrySubdivisions", e.Message);
                }
            }

            if (req.IndustriesRequested)
            {
                try
                {
                    var industryResponse = Industry(req.IndustryRequestReq ?? new IndustryRequest());
                    respVm.IndustryResponse = industryResponse.ResponseData;

                    flags = respVm.IndustryResponse?.Payload?.Flags;
                }
                catch (Exception e)
                {
                    apiErrors.Add("Industries", e.Message);
                }
            }

            var apiResp = new AcApiResponse <AllLookupResponse, ApiData>
            {
                BusinessMetadata = MapperHelper.SetResponseProperties(flags, DataSource.Lookup),
                ResponseData     = respVm,
                ApiErrors        = apiErrors.Any() ? apiErrors : null
            };

            return(apiResp);
        }