public IActionResult UpdateStudentDetails(int id, [FromBody] StudentRequest studentRequest) { StudentInfo studentInfo = _context.StudentInfo.FirstOrDefault(student => student.Id == id); studentInfo.FirstName = studentRequest.FirstName; studentInfo.LastName = studentRequest.LastName; _context.StudentInfo.Update(studentInfo); _context.SaveChanges(); return(Ok(studentInfo)); }
public IActionResult UpdateStudentDetails(int id, [FromBody] StudentRequest studentRequest) { StudentInfo studentInfo = _context.StudentInfo.FirstOrDefault(student => student.Id == FirstName); studentInfo.FirstName = studentRequest.FirstName; studentInfo.LastName = studentRequest.LastName; studentInfo.Address = studentRequest.Address; studentInfo.City = studentRequest.City; _context.SaveChanges(); return(Ok("Student Updated")); }
public IActionResult AddStudents([FromBody] StudentRequest studentRequest) { StudentInfo studentInfo = new StudentInfo() { FirstName = studentRequest.FirstName, LastName = studentRequest.LastName, Address = studentRequest.Address, City = studentRequest.City }; _context.StudentInfo.Add(studentInfo); _context.SaveChanges(); return(Ok("Student Added")); }