public IActionResult UploadPic(int id) { var viewModel = new StudentPictureViewModel { ProfileImage = null, student = null, }; return(View(viewModel)); }
public IActionResult UploadPic(double?id) { var vm = new StudentPictureViewModel { Student = null, ProfileImage = null }; return(View(vm)); }
public async Task <IActionResult> UploadPic(double?id, IFormFile iff) { var vm = new StudentPictureViewModel { Student = await _context.Student.FindAsync(id), ProfileImage = iff }; string uniqueFileName = UploadedFile(vm.ProfileImage); vm.Student.ProfilePicture = uniqueFileName; _context.Update(vm.Student); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); }