public async Task <IActionResult> Edit(int id, [Bind("AdvertiserID,FirstName,LastName,PhoneNumber,EmailAddress,CompanyID")] Advertiser advertiser) { if (id != advertiser.AdvertiserID) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(advertiser); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!AdvertiserExists(advertiser.AdvertiserID)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } //ViewData["CompanyID"] = new SelectList(_context.Companies, "CompanyID", "CompanyID", advertiser.CompanyID); PopulateCompanyDropDownList(advertiser.CompanyID); return(View(advertiser)); }
public async Task <IActionResult> Edit(int id, [Bind("CompanyID,CompanyName")] Company company) { if (id != company.CompanyID) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(company); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!CompanyExists(company.CompanyID)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(company)); }
public async Task <IActionResult> Edit(int id, [Bind("EventCategoryID,EventCategoryLogo,CategoryName")] EventCategory eventCategory) { if (id != eventCategory.EventCategoryID) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(eventCategory); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!EventCategoryExists(eventCategory.EventCategoryID)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(eventCategory)); }
public async Task <IActionResult> Edit(int id, [Bind("EventID,EventName,EventLocation,Date,Description,EventLogo,Promotional,EventCategoryID,AdvertiserID")] Event @event) { if (id != @event.EventID) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(@event); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!EventExists(@event.EventID)) { return(NotFound()); } else { throw; } } //if (@event.EventCategoryID.HasValue) //{ // int CategoryID = @event.EventCategoryID.Value; // return RedirectToAction("IndexCustomized","Events", new { id = CategoryID }); //} //else { return(RedirectToAction(nameof(Index))); } } ViewData["AdvertiserID"] = new SelectList(_context.Advertisers, "AdvertiserID", "AdvertiserID", @event.AdvertiserID); return(View(@event)); }