Ejemplo n.º 1
0
        public ApiResponse <GetLanguagesResponse, ApiData> GetLanguages(string applicationId, Dictionary <string, DateTime> requestedLanguages)
        {
            var serializedLanguages = _languageIntegration.GetLanguages(applicationId, requestedLanguages);
            var languages           = new Dictionary <string, JObject>();

            foreach (var lang in serializedLanguages)
            {
                var parsedLang       = JObject.Parse(lang.Value);
                var parseLangVersion = parsedLang["Version"].Value <DateTime>();

                if (!requestedLanguages.ContainsKey(lang.Key))
                {
                    continue;
                }
                if (requestedLanguages[lang.Key] < parseLangVersion)
                {
                    languages.Add(lang.Key, parsedLang);
                }
            }

            var respVm = new GetLanguagesResponse
            {
                Languages = languages
            };

            var apiResp = new ApiResponse <GetLanguagesResponse, ApiData>
            {
                BusinessMetadata = MapperHelper.SetResponseProperties(null, DataSource.Language),
                ResponseData     = respVm
            };

            return(apiResp);
        }
Ejemplo n.º 2
0
        public GetLanguagesResponse GetLanguages(GetLanguagesRequest request = null)
        {
            var response = new GetLanguagesResponse();

            try
            {
                response.Languages = this.unitOfWork.LanguageRepository.Get(q => q
                    .Where(x => x.Active)
                    .OrderBy(x => x.LocalName)
                    .Select(x => new LanguageDto
                    {
                        Id = x.Id,
                        LanguageCode = x.LanguageCode,
                        Name = x.LocalName
                    })
                );

                response.Status = StatusCode.OK;
            }
            catch (Exception ex)
            {
                this.exceptionHandler.HandleException(ex);
                response.Status = StatusCode.InternalServerError;
            }

            return response;
        }
Ejemplo n.º 3
0
        public async Task<GetLanguagesResponse> GetLanguagesAsync(GetLanguagesRequest request)
        {
            var response = new GetLanguagesResponse();

            try
            {
                response.Languages = await this.unitOfWork.LanguageRepository.GetAsync(q => q
                    .Where(x => x.IsSupported)
                    .OrderBy(x => x.LocalName)
                    .Select(x => new LanguageDto
                    {
                        Id = x.Id,
                        LanguageCode = x.LanguageCode,
                        Name = x.LocalName,
                        Region = x.LocalRegionName
                    })
                );

                response.Status = StatusCode.OK;
            }
            catch (Exception ex)
            {
                this.exceptionHandler.HandleException(ex);
                response.Status = StatusCode.InternalServerError;
            }

            return response;
        }
Ejemplo n.º 4
0
        public GetLanguagesResponse GetAllLanguageRegions()
        {
            var response = new GetLanguagesResponse();

            try
            {
                var cultures  = CultureInfo.GetCultures(CultureTypes.SpecificCultures);
                var languages = cultures
                                .OrderBy(x => x.NativeName)
                                .Select(x => new LanguageDto
                {
                    IsoCode    = x.Name,
                    Name       = x.EnglishName,
                    NativeName = x.NativeName
                }).ToList();

                response.Languages = languages;
                response.Success   = true;
            }
            catch (Exception ex)
            {
                this.exceptionHandler.HandleException(ex);
                response.Message = Resources.Common.InternalServerError;
            }

            return(response);
        }
Ejemplo n.º 5
0
 /// <summary>
 /// Return the default language and the supported languages of your service
 /// </summary>
 /// <returns> GetLanguagesResponse object</returns>
 /// <param name="request"> GetLanguagesRequest object</param>
 /// <param name='jsonRpcCallId'>
 /// The json rpc call identifier. This is a string generated by the client, which can be used to correlate the response to the request. Max length is 256 characters. A JSON-RPC id must be generated on a per call invocation basis. The Rogerthat platform uses the id of the call to store the call result for a certain amount of time so that if something fails during the communication, the same call (having the same JSON-RPC id) can be resent to the Rogerthat service, allowing to fetch the result, without actually executing the call again. This avoids annoying problems such as duplicate delivery of messages.
 /// 
 /// You should use a different JSON-RPC id for every call you make.
 /// 
 /// In case of an intermittent failure such as a network connectivity problem, you can retry the same call using the same JSON-RPC id, without running the risk of duplicate execution of your call (e.g. duplicate message delivery).
 /// </param>
 public GetLanguagesResponse GetLanguages(GetLanguagesRequest request, string jsonRpcCallId)
 {
     GetLanguagesResponse result = new GetLanguagesResponse();
     WireRequest(0, jsonRpcCallId, "system.get_languages", (writer) =>
         {
             request.Write(writer, false);
         }, (reader) =>
         {
             result.Read(reader);
         }
     );
     return result;
 }