Ejemplo n.º 1
0
 private void AddCultureToCategories(List <WcfHierarchicalTaxon> categories, CultureViewModel defaultCulture)
 {
     foreach (var category in categories)
     {
         category.CultureCode = defaultCulture.Culture;
     }
 }
Ejemplo n.º 2
0
 private void AddCultureToProducts(List <ProductViewModel> products, CultureViewModel defaultCulture)
 {
     foreach (var product in products)
     {
         product.CultureCode = defaultCulture.Culture;
     }
 }
Ejemplo n.º 3
0
        public ActionResult CultureChange(CultureViewModel vm)
        {
            try
            {
                var        culture       = CultureHelper.GetCulture(vm.Name);
                HttpCookie cultureCookie = Request.Cookies["_culture"];
                if (cultureCookie != null)
                {
                    cultureCookie.Value = culture;
                }
                else
                {
                    cultureCookie         = new HttpCookie("_culture");
                    cultureCookie.Value   = culture;
                    cultureCookie.Expires = DateTime.Now.AddMonths(2);
                }
                Response.Cookies.Add(cultureCookie);
                var ci = new CultureInfo(culture);
                System.Threading.Thread.CurrentThread.CurrentUICulture = ci;
                System.Threading.Thread.CurrentThread.CurrentCulture   = ci;

                return(RedirectToAction("POProfile"));
            }
            catch
            {
                return(View());
            }
        }
Ejemplo n.º 4
0
 public bool ValidateForm(CultureViewModel model)
 {
     if (string.IsNullOrEmpty(model.Name))
     {
         ModelState.AddModelError("Name", "Bu alanın doldurulması zorunludur");
     }
     return(ModelState.IsValid);
 }
Ejemplo n.º 5
0
        public ActionResult CreateOrUpdate(CultureViewModel model)
        {
            if (!ValidateForm(model))
            {
                CreateNotification(ActionResultType.Failure);
                return(View("CreateOrUpdate", model));
            }
            var cultureParams = Mapper.Map <CultureParams>(model);
            var culture       = _cultureService.CreateOrUpdate(cultureParams);

            CreateNotification(ActionResultType.Success);

            return(RedirectToAction("Update", new { culture.Id }));
        }
Ejemplo n.º 6
0
        public ActionResult Create(CultureViewModel form)
        {
            try
            {
                // TODO: Add insert logic here
                _uow.Cultures.Add(Culture.New(form.Name, form.Code, form.ISO2, form.ISO3));
                _uow.Save();

                return RedirectToAction("Index");
            }
            catch
            {
                return View();
            }
        }
        public RootModule(ICultureJsonFileReader reader, IImageDownloader imageDownloader)
        {
            Get["/"] = p => {             
                var culture = reader.Read();               
                var downloadResult = imageDownloader.Download(culture);

                var viewModel = new CultureViewModel();
                foreach (var item in culture.Items)
                {
                    if (downloadResult.DownloadedImageNames.Any(s => s == item.ImageName))
                        viewModel.AddItem(new CultureViewModelItem(item.ImageName, item.Link, item.Title, item.Description));
                }

                return View["HomeView", viewModel]; 
            };
        }
Ejemplo n.º 8
0
        public IActionResult About(string lang = "")
        {
            ViewData["Message"] = homeLocalizer["AboutText"];

            //if (!String.IsNullOrEmpty(lang))
            //{
            //    CultureInfo.CurrentCulture = new CultureInfo(lang);
            //    CultureInfo.CurrentUICulture = new CultureInfo(lang);
            //}

            CultureViewModel model = new CultureViewModel()
            {
                Culture   = CultureInfo.CurrentCulture.DisplayName,
                UICulture = CultureInfo.CurrentCulture.DisplayName
            };

            return(View(model));
        }
Ejemplo n.º 9
0
        public ActionResult Edit(Guid id, CultureViewModel form)
        {
            try
            {
                var item = _uow.Cultures.FindById(id);
                item.Name = form.Name;
                item.Code = form.Code;
                item.ISO2 = form.ISO2;
                item.ISO3 = form.ISO3;
                _uow.Save();

                return RedirectToAction("Index");
            }
            catch
            {
                return View();
            }
        }
Ejemplo n.º 10
0
        public IActionResult Contact()
        {
            var viewModel = new CultureViewModel(CultureInfo.GetCultures(CultureTypes.SpecificCultures));

            return(View(viewModel));
        }
Ejemplo n.º 11
0
 public JsonNetResult SetCulture(CultureViewModel newCulture)
 {
     return(SetCultureWithString(newCulture.Culture));
 }
Ejemplo n.º 12
0
        public ActionResult Create()
        {
            var model = new CultureViewModel();

            return(View("CreateOrUpdate", model));
        }
Ejemplo n.º 13
0
        public void InitSWCms()
        {
            SiocCmsContext        context        = null;
            SiocCmsAccountContext accountContext = null;
            IDbContextTransaction transaction    = null;

            try
            {
                if (InitConnectionString())
                {
                    context        = new SiocCmsContext();
                    accountContext = new SiocCmsAccountContext();
                    context.Database.Migrate();
                    accountContext.Database.Migrate();
                    transaction = context.Database.BeginTransaction();

                    var getConnectionString = BEParameterViewModel.Repository.GetSingleModel(
                        c => c.Name == SWCmsConstants.ConfigurationKeyword.ConnectionString,
                        _context: context, _transaction: transaction);

                    if (!getConnectionString.IsSucceed)
                    {
                        BEParameterViewModel cnn = new BEParameterViewModel()
                        {
                            Name        = SWCmsConstants.ConfigurationKeyword.ConnectionString,
                            Value       = ConnectionString,
                            Description = SWCmsConstants.ConfigurationType.System
                        };
                        cnn.SaveModel(_context: context, _transaction: transaction);
                    }

                    // EN-US
                    var getCulture = CultureViewModel.Repository.GetSingleModel(
                        c => c.Specificulture == "en-us",
                        _context: context,
                        _transaction: transaction);

                    if (!getCulture.IsSucceed)
                    {
                        CultureViewModel cultureViewModel = new CultureViewModel()
                        {
                            Specificulture = "en-us",
                            FullName       = "United States",
                            Description    = "United States",
                            Icon           = "flag-icon-us",
                            Alias          = "US"
                        };
                        cultureViewModel.SaveModel(_context: context, _transaction: transaction);
                    }

                    // VI-VN
                    getCulture = CultureViewModel.Repository.GetSingleModel(
                        c => c.Specificulture == "vi-vn",
                        _context: context,
                        _transaction: transaction);

                    if (!getCulture.IsSucceed)
                    {
                        CultureViewModel cultureViewModel = new CultureViewModel()
                        {
                            Specificulture = "vi-vn",
                            FullName       = "Vietnam",
                            Description    = "Việt Nam",
                            Icon           = "flag-icon-vn",
                            Alias          = "VN"
                        };
                        cultureViewModel.SaveModel(_context: context, _transaction: transaction);
                    }

                    var getPosition = BEPositionViewModel.Repository.GetModelList(_context: context, _transaction: transaction);
                    if (!getPosition.IsSucceed || getPosition.Data.Count == 0)
                    {
                        BEPositionViewModel p = new BEPositionViewModel()
                        {
                            Description = nameof(SWCmsConstants.CatePosition.Top)
                        };
                        p.SaveModel(_context: context, _transaction: transaction);
                        p = new BEPositionViewModel()
                        {
                            Description = nameof(SWCmsConstants.CatePosition.Left)
                        };
                        p.SaveModel(_context: context, _transaction: transaction);
                        p = new BEPositionViewModel()
                        {
                            Description = nameof(SWCmsConstants.CatePosition.Footer)
                        };
                        p.SaveModel(_context: context, _transaction: transaction);
                    }
                    var getThemes = BEThemeViewModel.Repository.GetModelList(_context: context, _transaction: transaction);
                    if (getThemes.IsSucceed)
                    {
                        foreach (var theme in getThemes.Data)
                        {
                            string folderPath = CommonHelper.GetFullPath(new string[]
                            {
                                SWCmsConstants.Parameters.TemplatesFolder,
                                theme.Name
                            });

                            var delFolder = FileRepository.Instance.DeleteFolder(folderPath);

                            foreach (var item in theme.Templates)
                            {
                                try
                                {
                                    item.SaveModel(true, _context: context, _transaction: transaction);
                                }
                                catch { }
                            }
                        }
                    }
                    GlobalLanguageService.Instance.RefreshCultures(context, transaction);
                    InitConfigurations(context, transaction);
                    transaction.Commit();
                    IsInit = true;
                }
            }
            catch // TODO: Add more specific exeption types instead of Exception only
            {
                IsInit = false;
                transaction?.Rollback();
            }
            finally
            {
                context?.Dispose();
                accountContext?.Dispose();
            }
        }