コード例 #1
0
        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));
            }
        }
コード例 #2
0
        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();
        }
コード例 #3
0
 public IActionResult ModifyStudent(ModifyStudentDataRequest req)
 {
     _service.modifyStudentData(req);
     return(Ok());
 }