예제 #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;
        }