Пример #1
0
        public ActionResult Create()
        {
            var plan = new PLANES();

            plan.EstatusList = new SelectList(_db.ESTATUS.ToList(), "Id", "Estatus1");
            return(View(plan));
        }
Пример #2
0
        public IHttpActionResult PostPLANES(PLANES pLANES)
        {
            pLANES.FECHAMOD = DateTime.Now;
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            db.PLANES.Add(pLANES);

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateException)
            {
                if (PLANESExists(pLANES.IDPLAN))
                {
                    return(Conflict());
                }
                else
                {
                    throw;
                }
            }

            return(CreatedAtRoute("DefaultApi", new { id = pLANES.IDPLAN }, pLANES));
        }
Пример #3
0
        public IHttpActionResult PutPLANES(int id, PLANES pLANES)
        {
            pLANES.FECHAMOD = DateTime.Now;
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != pLANES.IDPLAN)
            {
                return(BadRequest());
            }

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

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

            return(StatusCode(HttpStatusCode.NoContent));
        }
Пример #4
0
        public IHttpActionResult GetPLANES(int id)
        {
            PLANES pLANES = db.PLANES.Find(id);

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

            return(Ok(pLANES));
        }
Пример #5
0
        public ActionResult Edit(PLANES plan)
        {
            if (!ModelState.IsValid)
            {
                return(RedirectToAction(nameof(Index)));
            }

            _db.Entry(plan).State = EntityState.Modified;
            _db.SaveChanges();

            return(RedirectToAction(nameof(Index)));
        }
Пример #6
0
        public ActionResult Create(PLANES plan)
        {
            if (!ModelState.IsValid)
            {
                return(RedirectToAction(nameof(Index)));
            }

            _db.PLANES.Add(plan);
            _db.SaveChanges();

            return(RedirectToAction(nameof(Index)));
        }
Пример #7
0
        public IHttpActionResult DeletePLANES(int id)
        {
            PLANES pLANES = db.PLANES.Find(id);

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

            db.PLANES.Remove(pLANES);
            db.SaveChanges();

            return(Ok(pLANES));
        }