コード例 #1
0
 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));
 }
コード例 #2
0
        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));
        }