public async Task <IActionResult> Edit(int id, [Bind("FishId,FishName,LegalLength,LegalLimit,SeasonStart,SeasonEnd")] FishInfo fishInfo) { if (id != fishInfo.FishId) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(fishInfo); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!FishInfoExists(fishInfo.FishId)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(fishInfo)); }
public async Task <IActionResult> Edit(int id, [Bind("ProfileId,FirstName,LastName,YearsFishing,DateCreated,UserAccountId")] UserProfile userProfile) { if (id != userProfile.ProfileId) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(userProfile); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!UserProfileExists(userProfile.ProfileId)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(userProfile)); }
public async Task<IActionResult> Edit(int id, [Bind("BlogId,UserFishId,BlogTitle,Content,BlogDate")] PublicBlog publicBlog) { if (id != publicBlog.BlogId) { return NotFound(); } if (ModelState.IsValid) { try { _context.Update(publicBlog); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!PublicBlogExists(publicBlog.BlogId)) { return NotFound(); } else { throw; } } return RedirectToAction(nameof(Index)); } ViewData["UserFishId"] = new SelectList(_context.Userfish, "UserFishId", "FishLength", publicBlog.UserFishId); return View(publicBlog); }
public async Task <IActionResult> Edit(int id, [Bind("UserFishId,UserAccountId,FishName,FishLength,UserFishPhotoPath,CatchDate")] Userfish userfish, IFormFile FilePhoto) { if (FilePhoto.Length > 0) { string photoPath = _webroot.WebRootPath + "\\userPhoto\\"; var filename = Path.GetFileName(FilePhoto.FileName); using (var stream = System.IO.File.Create(photoPath + filename)) { await FilePhoto.CopyToAsync(stream); userfish.UserFishPhotoPath = filename; } } if (id != userfish.UserFishId) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(userfish); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!UserfishExists(userfish.UserFishId)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["FishName"] = new SelectList(_context.FishInfo, "FishName", "FishName", userfish.FishName); //ViewData["UserAccountId"] = new SelectList(_context.UserProfile, "UserAccountId", "FirstName", userfish.UserAccountId); return(View(userfish)); }