// GET: Admin/LawContents public async Task <IActionResult> Index() { List <LawContent> items = new List <LawContent>(); items = await _context.LawContents.ToListAsync(); if (items.Count == 0) { var agb = new LawContent { ID = 1, HtmlContent = "<strong>AGB hier anpassen</strong>", SiteType = (int)LawContentEnum.TAC, Titel = "AGB" }; var wbl = new LawContent { ID = 2, HtmlContent = "<strong>Wiederrufsbelerung hier anpassen</strong>", SiteType = (int)LawContentEnum.CAL, Titel = "Wiederrufsbelerung" }; var dsgvo = new LawContent { ID = 3, HtmlContent = "<strong>Datenschuterklärung hier anpassen</strong>", SiteType = (int)LawContentEnum.PPO, Titel = "Datenschuterklärung" }; var impressum = new LawContent { ID = 4, HtmlContent = "<strong>Impressum hier anpassen</strong>", SiteType = (int)LawContentEnum.IMP, Titel = "Impressum" }; _context.Add(agb); _context.Add(wbl); _context.Add(dsgvo); _context.Add(impressum); await _context.SaveChangesAsync(); items = await _context.LawContents.ToListAsync(); } return(View(items)); }
public async Task <IActionResult> Edit(int id, [Bind("ID,SiteType,Titel,HtmlContent")] LawContent lawContent) { if (id != lawContent.ID) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(lawContent); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!LawContentExists(lawContent.ID)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(lawContent)); }
public async Task <IActionResult> Create([Bind("ID,SiteType,Titel,HtmlContent")] LawContent lawContent) { if (ModelState.IsValid) { _context.Add(lawContent); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(lawContent)); }