コード例 #1
0
        /// <summary>Create missing mappings for a page.</summary>
        /// <return>The number of inserted mappings.</return>
        public int ProcessPage(Page page, Lang[] langs)
        {
            // don't process ignored pages
            if (page.IsIgnored) return 0;

            var maps = page.Mappings;
            var now = DateTime.UtcNow;

            var count = 0;

            // Creating the missing mappings
            foreach(var lang in langs.Where(x => !maps.Any(y => y.Code == x.Code)))
            {
                var mapping = new Mapping
                {
                    Code = lang.Code,
                    Created = now,
                    Page = page
                };
                page.Mappings.Add(mapping);
                Mappings.Create(mapping);

                count++;
            }

            return count;
        }
コード例 #2
0
 public void Create(Lang lang)
 {
     using (var trans = Session.BeginTransaction())
     {
         Session.Save(lang);
         trans.Commit();
     }
 }
コード例 #3
0
        public void Edit(long id, Lang lang)
        {
            using (var trans = Session.BeginTransaction())
            {
                var dbLang = Session.Get<Lang>(id);

                dbLang.Code = lang.Code;

                Session.Update(dbLang);
                trans.Commit();
            }
        }
コード例 #4
0
 public ActionResult Edit(long id, Lang lang)
 {
     Langs.Edit(id, lang);
     return RedirectToAction("Index");
 }