public async Task <IActionResult> Edit(long id, [Bind("Id,StudentId,FirstName,LastName,EnrollmentDate,AcquiredCredits,CurrentSemester,EducationLevel,ProfileImage")] Student student) { if (id != student.Id) { return(NotFound()); } if (ModelState.IsValid) { try { string uniqueFileName = UploadedFile(student); student.ProfilePicture = uniqueFileName; _context.Update(student); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!StudentExists(student.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(student)); }
public async Task <IActionResult> Edit(int id, [Bind("Id,FirstName,LastName,Degree,AcademicRank,OfficeNumber,HireDate,ProfileImage")] Teacher teacher) { if (id != teacher.Id) { return(NotFound()); } if (ModelState.IsValid) { try { string uniqueFileName = UploadedFile(teacher); teacher.ProfilePicture = uniqueFileName; _context.Update(teacher); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!TeacherExists(teacher.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(teacher)); }
public async Task <IActionResult> Edit(int id, [Bind("Id,Title,Credits,Semester,Program,EducationLevel,FirstTeacherId,SecondTeacherId")] Course course) { if (id != course.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(course); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!CourseExists(course.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["FirstTeacherId"] = new SelectList(_context.Set <Teacher>(), "Id", "FullName", course.FirstTeacherId); ViewData["SecondTeacherId"] = new SelectList(_context.Set <Teacher>(), "Id", "FullName", course.SecondTeacherId); return(View(course)); }
public async Task <IActionResult> Edit(long id, [Bind("Id,CourseId,StudentId,Semester,Year,Grade,SeminalUrl,ProjectUrl,ExamPoints,SeminalPoints,ProjectPoints,AdditionalPoints,FinishDate")] Enrollment enrollment) { if (id != enrollment.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(enrollment); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!EnrollmentExists(enrollment.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["CourseId"] = new SelectList(_context.Course, "Id", "Title", enrollment.CourseId); ViewData["StudentId"] = new SelectList(_context.Student, "Id", "FullName", enrollment.StudentId); return(View(enrollment)); }
public async Task <IActionResult> Edit(int id, [Bind("ID,Nombre,Imagen")] Pais pais, IFormFile file) { if (id != pais.ID) { return(NotFound()); } if (ModelState.IsValid) { try { if (file != null && file.Length > 0) { try { string path = Path.Combine(Directory.GetCurrentDirectory(), "wwwroot\\images\\Banderas", Path.GetFileName(file.FileName)); using (var stream = new FileStream(path, FileMode.Create)) { await file.CopyToAsync(stream); } pais.Imagen = "/images/Banderas/" + file.FileName; } catch (Exception ex) { ViewBag.Message = "ERROR:" + ex.Message.ToString(); } } else { ViewBag.Message = "You have not specified a file."; } _context.Update(pais); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!PaisExists(pais.ID)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(pais)); }
public async Task <IActionResult> Edit(int id, [Bind("ID,PaisID,Nombres,Apellido_p,Apellido_M,Lugar_Nac,Fecha_Nac,Altura,Peso,Club,Foto,Condicion,Fuerza,Velocidad,Reacción,Control_de_Balon,Anotacion,Barrida,Centros,Defensa,Marcaje,Carcateristica1,Carcateristica2")] Jugador jugador, IFormFile file) { if (id != jugador.ID) { return(NotFound()); } if (ModelState.IsValid) { try { if (file != null && file.Length > 0) { try { string path = Path.Combine(Directory.GetCurrentDirectory(), "wwwroot\\images\\Banderas", Path.GetFileName(file.FileName)); using (var stream = new FileStream(path, FileMode.Create)) { await file.CopyToAsync(stream); } jugador.Foto = "/images/Banderas/" + file.FileName; } catch (Exception ex) { ViewBag.Message = "ERROR:" + ex.Message.ToString(); } } else { ViewBag.Message = "You have not specified a file."; } _context.Update(jugador); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!JugadorExists(jugador.ID)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["PaisID"] = new SelectList(_context.Paises, "ID", "Nombre", jugador.PaisID); return(View(jugador)); }