예제 #1
0
        public IHttpActionResult PutCurso(int id, Curso curso)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != curso.ID)
            {
                return(BadRequest());
            }

            db.Entry(curso).State = EntityState.Modified;

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!CursoExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
예제 #2
0
        public async Task <IActionResult> PutAddress(int id, Address address)
        {
            if (id != address.AddressId)
            {
                return(BadRequest());
            }

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

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

            return(NoContent());
        }
예제 #3
0
        public async Task <IActionResult> PutStudent(int id, Student student)
        {
            if (id != student.StudentId)
            {
                return(BadRequest());
            }

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

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

            return(NoContent());
        }
예제 #4
0
        public async Task <IActionResult> PutPhone(int id, Phone phone)
        {
            if (id != phone.PhoneId)
            {
                return(BadRequest());
            }

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

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

            return(NoContent());
        }
예제 #5
0
        public async Task <IActionResult> PutEmail(int id, Email email)
        {
            if (id != email.EmailId)
            {
                return(BadRequest());
            }

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

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

            return(NoContent());
        }
예제 #6
0
        // POST: api/Estudiante
        public bool Post(string Nombre, string Apellido, DateTime FechaEnrolamiento, int id)
        {
            var e = new Estudiante
            {
                ID                = id,
                Nombre            = Nombre,
                Apellido          = Apellido,
                FechaEnrolamiento = Convert.ToDateTime(FechaEnrolamiento)
            };

            db.Estudiantes.Attach(e);
            db.Configuration.ValidateOnSaveEnabled = true;
            db.Entry(e).State = System.Data.Entity.EntityState.Modified;
            return(db.SaveChanges() > 0);
        }
예제 #7
0
 //EDICION DEL CURSO
 public IActionResult Edit(Alumno alumno)
 {
     ViewBag.Fecha = DateTime.Now;
     //va a funcionar si nuestro modelo es valido, de lo contrario te manda a la misma vista
     if (ModelState.IsValid)
     {
         _context.Entry(alumno).State = EntityState.Modified;
         _context.SaveChanges();
         return(View("Index", alumno));
     }
     else
     {
         return(View(alumno));
     }
 }