public async Task <IActionResult> Edit(int id, [Bind("ID,MagazineTitle,MagazineCoverImage")] CompanyMagazine companyMagazine) { if (id != companyMagazine.ID) { return(NotFound()); } companyMagazine.CompanyID = HttpContext.Session.GetInt32("CompanyID") ?? -1; if (ModelState.IsValid) { try { _context.Update(companyMagazine); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!CompanyMagazineExists(companyMagazine.ID)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(companyMagazine)); }
public async Task <IActionResult> Create([Bind("ID,MagazineTitle,MagazineCoverImage")] CompanyMagazine companyMagazine) { companyMagazine.CompanyID = HttpContext.Session.GetInt32("CompanyID") ?? -1; if (ModelState.IsValid) { _context.Add(companyMagazine); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(companyMagazine)); }