public async Task <IActionResult> Edit(int id, [Bind("ReviewID,Name,Rating,ReviewText,MobileID,ReviewDate")] MobileReview mobileReview) { if (id != mobileReview.ReviewID) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(mobileReview); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!MobileReviewExists(mobileReview.ReviewID)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["MobileID"] = new SelectList(_context.Mobiles, "MobileID", "MobileName", mobileReview.MobileID); return(View(mobileReview)); }
public async Task <IActionResult> Create([Bind("ReviewID,Name,Rating,ReviewText,MobileID,ReviewDate")] MobileReview mobileReview) { if (ModelState.IsValid) { _context.Add(mobileReview); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewData["MobileID"] = new SelectList(_context.Mobiles, "MobileID", "MobileName", mobileReview.MobileID); return(View(mobileReview)); }