コード例 #1
0
 public ActionResult AddDef_GenderEnd(Def_Gender Def_Gender)
 {
     if (ModelState.IsValid)
     {
         try
         {
             db.Def_Gender.Add(Def_Gender);
             db.SaveChanges();
             var Def_GenderList = JsonConvert.SerializeObject(db.Def_Gender.Select(g => new { ID = g.ID, Name = g.Name }).ToList());
             return(Json(new { action = "yes", msg = "Added", Def_GenderList = Def_GenderList }, JsonRequestBehavior.AllowGet));
         }
         catch (Exception ex)
         {
             return(Json(new { action = "no", msg = "error" }, JsonRequestBehavior.AllowGet));
         }
     }
     else
     {
         return(Json(new { action = "no", msg = "error" }, JsonRequestBehavior.AllowGet));
     }
 }
コード例 #2
0
        public ActionResult EditDef_GenderEnd(Def_Gender Def_Gender)
        {
            if (ModelState.IsValid)
            {
                try
                {
                    var ob = db.Def_Gender.Where(a => a.ID == Def_Gender.ID).FirstOrDefault();
                    ob.Name = Def_Gender.Name;
                    db.SaveChanges();

                    var Def_GenderList = JsonConvert.SerializeObject(db.Def_Gender.Select(g => new { ID = g.ID, Name = g.Name }).ToList());
                    return(Json(new { action = "yes", msg = "Editted", Def_GenderList = Def_GenderList }, JsonRequestBehavior.AllowGet));
                }
                catch (Exception ex)
                {
                    return(Json(new { action = "no", msg = "error" }, JsonRequestBehavior.AllowGet));
                }
            }
            else
            {
                return(Json(new { action = "no", msg = "error" }, JsonRequestBehavior.AllowGet));
            }
        }