public ActionResult Delete(int id) { Student std = stdRepo.GetById(id); std.IsActive = false; stdRepo.Edit(std); //stdRepo.Delete(id); return(RedirectToAction("StudentList", "AdminStudent")); }
// GET: Student/Edit/5 public async Task <IActionResult> Edit(string id) { if (id == null) { return(NotFound()); } var studentModel = await _context.Edit(id); if (studentModel == null) { return(NotFound()); } return(View(studentModel)); }
public void Execute() { Console.Clear(); Console.WriteLine("Edit Student GPA"); StudentRepo repo = new StudentRepo(Settings.FilePath); List <Student> students = repo.List(); ConsoleIO.PrintPickList(students); Console.WriteLine(); int index = ConsoleIO.GetStudentIndexFromUser("Which student you like to edit?", students.Count()); index--; Console.WriteLine(); //string.Format() allows for substitution strings just like Console.WriteLine(), but for variables and method parameters students[index].GPA = ConsoleIO.GetRequiredDecimalFromUser (string.Format("Enter the new GPA for {0} {1}", students[index].FirstName, students[index].LastName)); repo.Edit(students[index], index); Console.WriteLine("GPA updated"); Console.WriteLine("Press any key to continue..."); Console.ReadKey(); }
public void EditStudent(Models.Student.EditViewModel evmStudent) { Student student = new Student(); student.RollNumber = evmStudent.RollNumber; student.Name = evmStudent.Name; student.CGPI = evmStudent.CGPI; student.Location = evmStudent.Location; student.DateOfBirth = evmStudent.DateOfBirth; repo.Edit(student); }
public void CanEdit() { StudentRepo repo = new StudentRepo(_filePath); List <Student> students = repo.List(); Student editedStudent = students[0]; editedStudent.GPA = 3.0M; repo.Edit(editedStudent, 0); Assert.AreEqual(4, students.Count); students = repo.List(); Student check = students[0]; Assert.AreEqual("Joe", check.FirstName); Assert.AreEqual("Smith", check.LastName); Assert.AreEqual("Computer Science", check.Major); Assert.AreEqual(3.0M, check.GPA); }