public async Task <IActionResult> Create([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 (ModelState.IsValid) { _context.Add(userfish); await _context.SaveChangesAsync(); 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)); }
public async Task <IActionResult> Create([Bind("FishId,FishName,LegalLength,LegalLimit,SeasonStart,SeasonEnd")] FishInfo fishInfo) { if (ModelState.IsValid) { _context.Add(fishInfo); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(fishInfo)); }
public async Task <IActionResult> Create([Bind("ProfileId,FirstName,LastName,YearsFishing,DateCreated,UserAccountId")] UserProfile userProfile) { if (ModelState.IsValid) { _context.Add(userProfile); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(userProfile)); }
public async Task<IActionResult> Create([Bind("BlogId,UserFishId,BlogTitle,Content,BlogDate")] PublicBlog publicBlog) { if (ModelState.IsValid) { _context.Add(publicBlog); await _context.SaveChangesAsync(); return RedirectToAction(nameof(Index)); } ViewData["UserFishId"] = new SelectList(_context.Userfish, "UserFishId", "UserFishId", publicBlog.UserFishId); return View(publicBlog); }