Ejemplo n.º 1
0
        public ActionResult Details(int id)
        {
            var request = new GetLanguageDetailRequest
            {
                Id = id,
                CultureId = CultureInfo.GetCultureInfo("vi-VN").LCID
            };

            var response = _globalizationSettings.GetLanguageDetail(request);

            return View(response.Data);
        }
Ejemplo n.º 2
0
        public GetLanguageDetailResponse GetLanguageDetail(GetLanguageDetailRequest detailRequest)
        {
            var response = new GetLanguageDetailResponse();
            // Include statement need to deep enough to cover all information return
            var cul = Uow.Languages.Get(c => c.Id == detailRequest.Id, null, o => o.Localizations.Select(c => c.Culture._localizations)).SingleOrDefault();
            if (cul != null)
                response.Data = new LanguageData
                {
                    Id = cul.Id,
                    Iso2 = cul.Iso2,
                    Iso3 = cul.Iso3,
                    Name = cul.Localizations.Join(new[]
                                                    {
                                                        new {Index = 0, CultureId = detailRequest.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(),
                    Localizations = cul.Localizations.Select(c => new LanguageLocalizedData
                    {
                        Id = c.LanguageId,
                        CultureId = c.CultureId,
                        CultureName = c.Culture._localizations.Join(new[]
                                                        {
                                                            new { Index = 0, CultureId = detailRequest.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(),
                        Name = c.Name
                    })
                };

            return response;
        }