public static GetCulturesResponse GetResponseFrom(this IEnumerable<Culture> data, GetRequestCultures request)
 {
     /*
                 return new GetCulturesResponse
                             {
                                 TotalNumberOfPage = NoOfResultPagesGiven(request.NumberOfResultsPerPage, data.Count()),
                                 Languages = CropCultureListToSatisfyGivenIndex(request.Index, request.NumberOfResultsPerPage, data)
                                     .Select(d => new CultureData
                                         {
                                             Id = d.Id,
                                             Code = d.Code,
                                             Name = d._localizations.Join(new[] {
                                                                 new { Index = 0, CultureId = request.CultureId },
                                                                 new { Index = 1, CultureId = CultureInfo.InvariantCulture.LCID }
                                                             }, cl => cl.CultureId, o => o.CultureId,
                                                             (cl, o) => new { Index = o.Index, Name = cl.Name })
                                                             .OrderBy(o => o.Index)
                                                             .Select(o => o.Name)
                                                             .FirstOrDefault(),
                                             Language = d.Language.ConvertToData(request.CultureId),
                                             Country = null
                                         })
                             };
     */
     return null;
 }
Beispiel #2
0
        private static GetRequestCultures GenerateCultureListRequest()
        {
            var request = new GetRequestCultures
                {
                    NumberOfResultsPerPage = 5,
                    Index = 1,
                    CultureSortBy = CultureSortBy.NameAcs
                };

            return request;
        }
        public GetCulturesResponse GetAllCulture(GetRequestCultures request)
        {
            if (!Uow.Cultures.Get(c => c.Id.Equals(request.CultureId)).Any())
                throw new CultureNotFoundException("Request culture not supported");

            var result = Uow.Cultures.Get(null, null, icl => icl._localizations, icl => icl.Language,
                                          icl => icl.Country, icl => icl.ParentCulture);

            var response = new GetCulturesResponse
            {
                Cultures = result.Select(d => new CultureData
                                     {
                                         Id = d.Id,
                                         Code = d.Code,
                                         Name = d._localizations.Join(new[]
                                                    {
                                                        new {Index = 0, CultureId = request.CultureId},
                                                        new { Index = 1, CultureId = CultureInfo.InvariantCulture.LCID }
                                                    }, cl => cl.CultureId,
                                                    o => o.CultureId, (cl, o) => new { Index = o.Index, Name = cl.Name })
                                             .OrderBy(o => o.Index)
                                             .Select(o => o.Name)
                                             .FirstOrDefault(),
                                         Language = new LanguageData
                                         {
                                             Id = d.Id,
                                             Iso2 = d.Language.Iso2,
                                             Iso3 = d.Language.Iso3,
                                             Name = d.Language.Localizations.Join(new[]
                                                    {
                                                        new {Index = 0, CultureId = request.CultureId},
                                                        new { Index = 1, CultureId = CultureInfo.InvariantCulture.LCID }
                                                    }, cl => cl.CultureId,
                                                 o => o.CultureId, (cl, o) => new { Index = o.Index, Name = cl.Name })
                                                 .OrderBy(o => o.Index)
                                                 .Select(o => o.Name)
                                                 .FirstOrDefault()
                                         },
                                         Country = new CountryData
                                         {
                                             Id = d.Id,
                                             Iso2 = d.Country.Iso2,
                                             Iso3 = d.Country.Iso3,
                                             Name = d.Country.Localizations.Join(new[]
                                                    {
                                                        new {Index = 0, CultureId = request.CultureId},
                                                        new { Index = 1, CultureId = CultureInfo.InvariantCulture.LCID }
                                                    }, cl => cl.CultureId,
                                                 o => o.CultureId, (cl, o) => new { Index = o.Index, Name = cl.Name })
                                                 .OrderBy(o => o.Index)
                                                 .Select(o => o.Name)
                                                 .FirstOrDefault()
                                         }

                                     }).OrderBy(c => c.Name)
                            .Skip((request.Index - 1) * request.NumberOfResultsPerPage)
                            .Take(request.NumberOfResultsPerPage).ToList(),
                CurrentPage = request.Index,
                TotalNumberOfPage = result.Count() / request.NumberOfResultsPerPage
            };

            return response;
        }