Exemplo n.º 1
0
        public IHttpActionResult PutSemestresModel(int id, SemestresModel semestresModel)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != semestresModel.idsemestre)
            {
                return(BadRequest());
            }

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

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

            return(StatusCode(HttpStatusCode.NoContent));
        }
Exemplo n.º 2
0
        public ActionResult DeleteConfirmed(int id)
        {
            SemestresModel semestresModel = semestredatamodel.getID(Convert.ToInt32(id));

            semestresModel.states = Dominio.ObjetosValor.EntityStates.Delete;
            semestresModel.SaveChanges();
            return(RedirectToAction("Index"));
        }
Exemplo n.º 3
0
 public ActionResult Edit([Bind(Include = "idsemestre,semestre,estado,fecha_crea,fecha_modif,user_crea,user_modif")] SemestresModel semestresModel)
 {
     if (ModelState.IsValid)
     {
         semestresModel.states = Dominio.ObjetosValor.EntityStates.Update;
         semestresModel.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(semestresModel));
 }
Exemplo n.º 4
0
        public IHttpActionResult GetSemestresModel(int id)
        {
            SemestresModel semestresModel = db.SemestresModels.Find(id);

            if (semestresModel == null)
            {
                return(NotFound());
            }

            return(Ok(semestresModel));
        }
 public IHttpActionResult Post([FromBody] SemestresModel model)
 {
     if (ModelState.IsValid)
     {
         model.states = Dominio.ObjetosValor.EntityStates.Add;
         model.SaveChanges();
         return(Ok(model));
     }
     else
     {
         return(BadRequest());
     }
 }
Exemplo n.º 6
0
        // GET: Semestres/Delete/5
        public ActionResult Delete(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            SemestresModel semestresModel = semestredatamodel.getID(Convert.ToInt32(id));

            if (semestresModel == null)
            {
                return(HttpNotFound());
            }
            return(View(semestresModel));
        }
Exemplo n.º 7
0
        public IHttpActionResult DeleteSemestresModel(int id)
        {
            SemestresModel semestresModel = db.SemestresModels.Find(id);

            if (semestresModel == null)
            {
                return(NotFound());
            }

            db.SemestresModels.Remove(semestresModel);
            db.SaveChanges();

            return(Ok(semestresModel));
        }
Exemplo n.º 8
0
        public IHttpActionResult PostSemestresModel(SemestresModel semestresModel)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            semestresModel.states = Dominio.ObjetosValor.EntityStates.Add;
            semestresModel.SaveChanges();
            //db.SemestresModels.Add(semestresModel);
            //db.SaveChanges();

            return(CreatedAtRoute("DefaultApi", new { id = semestresModel.idsemestre }, semestresModel));
        }
        // PUT: api/SemestresApi/5
        public void Put(int id, [FromBody] SemestresModel model)
        {
            if (ModelState.IsValid)
            {
                SemestresModel modelseleccionado = new SemestresModel();


                var existe = modelseleccionado.getall().Count(c => c.idsemestre == id) > 0;

                if (existe)
                {
                    model.states = Dominio.ObjetosValor.EntityStates.Update;
                    model.SaveChanges();
                }
            }
        }
Exemplo n.º 10
0
        public SemestresModel Post([FromBody] SemestresModel model)
        {
            model = new SemestresModel();
            //if (ModelState.IsValid)
            //{
            //    model.states = Dominio.ObjetosValor.EntityStates.Add;
            //    model.SaveChanges();
            //    return Ok(model).ToString();
            //}
            //else
            //{
            //    return BadRequest().ToString();
            //}
            //return Ok("funciona "+model);


            //return Json<SemestresModel>(model);
            return(model);
        }
Exemplo n.º 11
0
 public SemestresController()
 {
     semestredatamodel = new SemestresModel();
 }