コード例 #1
0
        public void EditSection(Section section)
        {
            Section dbEntry = context.Sections.Find(section.Id);

            if (dbEntry != null)
            {
                dbEntry.Theme = section.Theme;
            }

            context.SaveChanges();
        }
コード例 #2
0
 public ActionResult CreateSection(Section section)
 {
     if (SectionIsValid(ref section))
     {
         sections.CreateSection(section);
         return RedirectToAction("ShowListOfTopic");
     }
     else
     {
         return View(section);
     }
 }
コード例 #3
0
 public void CreateSection(Section section)
 {
     context.Sections.Add(section);
     context.SaveChanges();
 }
コード例 #4
0
        // Checking section.
        //
        private bool SectionIsValid(ref Section section)
        {
            if (section.Theme == null)
                section.Theme = "";

            if (section.Theme.Length == 0)
                ModelState.AddModelError("Theme", "Название раздела пустое");

            if (section.Theme.Length > 40)
                ModelState.AddModelError("Theme", "Название раздела слишком длинное");

            return ModelState.IsValid;
        }