public ActionResult Create(Student student) { // if (String.IsNullOrEmpty(student.Name)) // { // ModelState.AddModelError(nameof(student.Name), "The name is Required"); // } if (ModelState.IsValid) { db.Add(student); return(RedirectToAction("Index")); } return(View()); }
public IActionResult AddPost(StudentAdd studentAdd) { Student student = new Student(); Console.WriteLine("Dodaje123 studenta123"); student.FirstName = studentAdd.FirstName; student.LastName = studentAdd.LastName; student.ID = studentAdd.StudentID; student.TranscriptNumber = studentAdd.TranscriptNumber; JArray courseArray = JArray.Parse(studentAdd.JsonString); List <Course> courses = courseArray.ToObject <List <Course> >(); _studentData.Add(student, courses); return(RedirectToAction("Students", "Student")); }
public ActionResult Create(Student student) { if (db.GetAllStudentIndexes().Contains(student.IndexNumber)) { TempData["Message"] = "Student with that index number already exists!"; return(RedirectToAction("Create")); } if (ModelState.IsValid) { db.Add(student); TempData["Message"] = "You have saved the student!"; return(RedirectToAction("Details", new { id = student.StudentId })); } return(View()); }
public IActionResult OnPost() { if (!ModelState.IsValid) { Skills = htmlHelper.GetEnumSelectList <Skill>(); return(Page()); } if (Student.Id > 0) { studentData.Update(Student); } else { studentData.Add(Student); } studentData.Commit(); return(RedirectToPage("./Detail", new { studentId = Student.Id })); }
public IActionResult OnPost() { if (!ModelState.IsValid) { Quotas = htmlHelper.GetEnumSelectList <Quota>(); Departments = htmlHelper.GetEnumSelectList <Department>(); return(Page()); } if (Student.Id > 0) { studentData.Update(Student); } else { studentData.Add(Student); } studentData.Commit(); TempData["Message"] = "Student saved!"; return(RedirectToPage("./Detail", new { studentId = Student.Id })); }
public IActionResult AddStudent(StudentEditModel model) { if (ModelState.IsValid) { var newStudent = new Student(); newStudent.StudentName = model.StudentName; if (_studentData.GetAll().Count() > 0) { newStudent.Id = _studentData.GetAll().Max(m => m.Id) + 1; } else { newStudent.Id = 1; } newStudent = _studentData.Add(newStudent); return(RedirectToAction(nameof(Index))); } else { return(View()); } }
public void Add(StudentEntity student) { studentData.Add(student); }