Пример #1
0
        // GET: Language
        public ActionResult Index()
        {
            var model = new LanguageCreateViewModel();
            SqlConnectionCommon.Open();
            var data = SqlConnectionCommon.Query<Language>("LanguageGetAll", new { culture = string.Empty }, commandType: CommandType.StoredProcedure);
            SqlConnectionCommon.Close();

            model.Languages = data.ToList();
            return View(model);
        }
Пример #2
0
        public ActionResult Create()
        {
            var model = new LanguageCreateViewModel();
            SqlConnectionCommon.Open();
            var languageSystems = SqlConnectionCommon.Query<string>("LanguageSystem", commandType: CommandType.StoredProcedure).ToList();
            SqlConnectionCommon.Close();

            model.Languages = languageSystems.Select(languageSystem => new Language { LCIDForLocale = languageSystem }).ToList();
            return View(model);
        }
Пример #3
0
        public ActionResult LanguageInsertUpdate(LanguageCreateViewModel model)
        {
            SqlConnectionCommon.Open();
            var userId = User.Identity.Name;
            // Insert Language
            if (!string.IsNullOrEmpty(model.LanguageCode))
            {
                SqlConnectionCommon.Query<int>("LanguageInsertUpdate", new
                {
                    model.Id,
                    model.Locale,
                    model.LanguageCode,
                    model.LCIDString,
                    model.LCIDDecimal,
                    model.LCIDHexadecimal,
                    model.Codepage,
                    model.Tooltip,
                    LCIDForLocale = model.LCIDString
                }, commandType: CommandType.StoredProcedure);
            }
            // Update Language
            foreach (var item in model.Languages)
            {
                if (!string.IsNullOrEmpty(item.Locale))
                {
                    SqlConnectionCommon.Query<int>("LanguageInsertUpdate", new
                    {
                        item.Id,
                        item.Locale,
                        model.LanguageCode,
                        model.LCIDString,
                        model.LCIDDecimal,
                        model.LCIDHexadecimal,
                        model.Codepage,
                        item.Tooltip,
                        item.LCIDForLocale
                    }, commandType: CommandType.StoredProcedure);
                }
            }
            SqlConnectionCommon.Close();

            //return Json(new { result = 1 });
            return Redirect("/language");
        }
Пример #4
0
        public ActionResult Edit(int id)
        {
            var model = new LanguageCreateViewModel();
            SqlConnectionCommon.Open();
            var languages = SqlConnectionCommon.Query<Language>("LanguageGetAll", new { culture = "en" }, commandType: CommandType.StoredProcedure).ToList();
            var editLanguage = SqlConnectionCommon.Query<Language>("LanguageByCode", new { code = id }, commandType: CommandType.StoredProcedure).ToList();

            SqlConnectionCommon.Close();
            if (languages.Count != 0)
            {
                var newLanguages = languages.Where(p => editLanguage.All(p2 => p2.LCIDForLocale != p.LCIDForLocale));

                editLanguage.AddRange(newLanguages.Select(newLanguage => new Language
                {
                    LCIDForLocale = newLanguage.LCIDForLocale
                }));
            }

            model.Languages = editLanguage;
            return View(model);
        }