Exemplo n.º 1
0
        public JsonResult ModifyData(string id, string name, string address)
        {
            bool estado = false;

            SCHOOLEntities db = new SCHOOLEntities();

            try
            {
                Int32 id_ = Convert.ToInt32(id);

                SCH_SCHOOL sch = db.SCH_SCHOOL.Where(x => x.esc_id == id_).FirstOrDefault();
                sch.esc_id      = id_;
                sch.esc_name    = name;
                sch.esc_address = address;
                db.SaveChanges();
                estado = true;
                db.Dispose();
            }
            catch (Exception e)
            {
                estado = false;
            }


            return(Json(new { estado }, JsonRequestBehavior.AllowGet));
        }
Exemplo n.º 2
0
        public JsonResult DeleteData(string id)
        {
            bool estado = false;

            SCHOOLEntities db = new SCHOOLEntities();

            Int32 id_ = Convert.ToInt32(id);

            try
            {
                SCH_SCHOOL sch = db.SCH_SCHOOL.Where(x => x.esc_id == id_).FirstOrDefault();
                db.SCH_SCHOOL.Remove(sch);
                db.SaveChanges();
                estado = true;
                db.Dispose();
            }
            catch (Exception e)
            {
                estado = false;
            }


            return(Json(new { estado }, JsonRequestBehavior.AllowGet));
        }