Ejemplo n.º 1
0
 public JsonResult Create(FormCollection col)
 {
     try
     {
         Guid           id    = Tool.String2Guid(col["GUID"]);
         VEGETABLESTYPE model = new VEGETABLESTYPE();
         if (id == Guid.Empty)
         {
             model.GUID           = Guid.NewGuid();
             model.CREATEDATETIME = DateTime.Now;
             FillModel(ref model, col);
             DbContext.VEGETABLESTYPE.Add(model);
         }
         else
         {
             model = DbContext.VEGETABLESTYPE.FirstOrDefault(n => n.GUID == id);
             FillModel(ref model, col);
             DbContext.Entry(model).State = EntityState.Modified;
         }
         DbContext.SaveChanges();
         return(new JsonM().ToJson(true, MsgHelper.SaveSuccess));
     }
     catch (Exception ex)
     {
         return(new JsonM().ToJson(false, MsgHelper.SaveFail, ex.Message));
     }
 }
Ejemplo n.º 2
0
        public JsonResult Find(string q_id = "")
        {
            Guid           id    = Tool.String2Guid(q_id);
            VEGETABLESTYPE model = DbContext.VEGETABLESTYPE.FirstOrDefault(m => m.GUID == id);

            return(new JsonM().ToJson(true, "'", model));
        }
Ejemplo n.º 3
0
        private void FillModel(ref VEGETABLESTYPE m, FormCollection col)
        {
            m.PARENTTYPEID   = Tool.String2Guid(col["parentID"]);
            m.VEGETABLESNAME = col["VEGETABLESNAME"];
            m.SEQUENCE       = Tool.String2Decimal(col["SEQUENCE"]);
            m.CREATEUSERID   = null;
            m.CREATEUSERNAME = null;

            m.ISDELETED = 0;
        }
Ejemplo n.º 4
0
 public ActionResult Delete(string q_id = "")
 {
     try
     {
         Guid           id    = Tool.String2Guid(q_id);
         VEGETABLESTYPE model = DbContext.VEGETABLESTYPE.FirstOrDefault(m => m.GUID == id);
         if (model == null)
         {
             return(new JsonM().ToJson(true, "当前数据已删除"));
         }
         model.ISDELETED = 1;
         DbContext.Entry(model).State = EntityState.Modified;
         DbContext.SaveChanges();
         return(new JsonM().ToJson(true, MsgHelper.DeleteSuccess));
     }
     catch (Exception ex)
     {
         return(new JsonM().ToJson(false, MsgHelper.DeleteFail, ex.Message));
     }
 }