public async Task <IActionResult> Add(List <string> Texts, string Link) { List <Language> languages = await db.Languages.ToListAsync(); if (Checker.CheckList(Texts)) { Noti noti = new Noti(); noti.Link = Link; db.Noti.Add(noti); for (int i = 0; i < languages.Count; i++) { NotiLanguage notiLanguage = new NotiLanguage(); notiLanguage.Text = Texts[i]; notiLanguage.LanguageId = languages[i].Id; notiLanguage.NotiId = noti.Id; db.NotiLanguage.Add(notiLanguage); } await db.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } else { ModelState.AddModelError("", "Fill all Blanks"); return(View()); } }
public IActionResult Index() { Checker.CheckLangId(HttpContext, db, "adminLangId").Wait(); HttpContext.SetCurrentPage("Index", "Noti"); int langId = HttpContext.GetLanguage("adminLangId"); NotiLanguage notiLanguage = db.NotiLanguage.Include(nl => nl.Noti).FirstOrDefault(nl => nl.LanguageId == langId); return(View(notiLanguage)); }