public IActionResult ModifyStudentData(ModifyStudentDataRequest request) { var s = db.Student.Find(request.IndexNumber); if (s == null) { return(BadRequest("Student o indeksie " + request.IndexNumber + " nie istnieje")); } else { s.FirstName = request.FirstName; s.LastName = request.LastName; s.BirthDate = request.BirthDate; s.IdEnrollment = request.IdEnrollment; db.SaveChanges(); return(Ok(s)); } }
public void modifyStudentData(ModifyStudentDataRequest req) { var newStudent = new Student { IndexNumber = req.IndexNumber, FirstName = req.FirstName, LastName = req.LastName, BirthDate = req.BirthDate, Password = req.Password }; _context.Attach(newStudent); _context.Entry(newStudent).Property("FirstName").IsModified = true; _context.Entry(newStudent).Property("LastName").IsModified = true; _context.Entry(newStudent).Property("BirthDate").IsModified = true; _context.Entry(newStudent).Property("Password").IsModified = true; _context.SaveChanges(); }
public IActionResult ModifyStudent(ModifyStudentDataRequest req) { _service.modifyStudentData(req); return(Ok()); }