Ejemplo n.º 1
0
        public async Task <IActionResult> PutStudent([FromRoute] long id, [FromBody] Student student)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != student.Id)
            {
                return(BadRequest());
            }

            _context.Entry(student).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!StudentExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
Ejemplo n.º 2
0
 public ActionResult Edit(Student student)
 {
     if (ModelState.IsValid)
     {
         db.Entry(student).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("StudentList"));
     }
     return(View(student));
 }
 public ActionResult Edit([Bind(Include = "Id,Name")] Administrator administrator)
 {
     if (ModelState.IsValid)
     {
         db.Entry(administrator).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(administrator));
 }
Ejemplo n.º 4
0
 public ActionResult Edit([Bind(Include = "TeacherID,FirstName,LastName,Qualification,Email,PhoneNumber,Gender")] Teacher teacher)
 {
     if (ModelState.IsValid)
     {
         db.Entry(teacher).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("TeacherList"));
     }
     return(View(teacher));
 }