public void EditSection(Section section)
        {
            Section dbEntry = context.Sections.Find(section.Id);

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

            context.SaveChanges();
        }
Esempio n. 2
0
 public ActionResult CreateSection(Section section)
 {
     if (SectionIsValid(ref section))
     {
         sections.CreateSection(section);
         return RedirectToAction("ShowListOfTopic");
     }
     else
     {
         return View(section);
     }
 }
 public void CreateSection(Section section)
 {
     context.Sections.Add(section);
     context.SaveChanges();
 }
Esempio n. 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;
        }