public void EditSection(Section section) { Section dbEntry = context.Sections.Find(section.Id); if (dbEntry != null) { dbEntry.Theme = section.Theme; } context.SaveChanges(); }
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(); }
// 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; }