Пример #1
0
        public ActionResult Edit(int id)
        {
            var culture = System.Threading.Thread.CurrentThread.CurrentUICulture.Name.ToLowerInvariant();
            
            var model = new PageContentCreateViewModel();
            SqlConnectionCommon.Open();
            var languages = SqlConnectionCommon.Query<Language>("LanguageGetAll", new { culture = string.Empty }, commandType: CommandType.StoredProcedure).ToList();
            var contents = SqlConnectionCommon.Query<PageContent>("PageContentByCode", new { code = id }, commandType: CommandType.StoredProcedure).ToList();

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

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

            model.Items = contents;
            model.Code = id;
            model.Type = contents.First().Type;
            return View(model);
        }
Пример #2
0
        public ActionResult Create()
        {
            var culture = System.Threading.Thread.CurrentThread.CurrentUICulture.Name.ToLowerInvariant();
            var model = new PageContentCreateViewModel();
            SqlConnectionCommon.Open();
            var data = SqlConnectionCommon.Query<Language>("LanguageGetAll", new { culture = string.Empty }, commandType: CommandType.StoredProcedure);
            SqlConnectionCommon.Close();

            var languages = data.ToList();
            model.Items = languages.Select(language => new PageContent { Language = language.LCIDForLocale }).ToList();
            model.Code = GetNewCode();
            return View(model);
        }
Пример #3
0
        public ActionResult ContentInsertUpdate(PageContentCreateViewModel model)
        {
            SqlConnectionCommon.Open();
            var userId = User.Identity.Name;
            // Insert - Update PageContent
            foreach (var item in model.Items)
            {
                item.Code = model.Code;
                item.Type = model.Type;
                item.ContentPlainText = item.Content;
                item.ModifiedUserId = userId;
                SqlConnectionCommon.Query<int>("PageContentInsertUpdate", new
                {
                    item.Id,
                    item.ProgrammeType,
                    item.Type,
                    item.Content,
                    item.ContentPlainText,
                    item.Tooltip,
                    item.Code,
                    item.Language,
                    item.ModifiedUserId
                }, commandType: CommandType.StoredProcedure);
            }
            SqlConnectionCommon.Close();

            //return Json(new {result = 1});
            return Redirect("/text") ;
        }