Ejemplo n.º 1
0
        public ActionResult Edit(ModuleElementEdit moduleElementEdit)
        {
            ModuleElement moduleElement = ModuleElementServices
                                          .LoadFirst(r => r.ID == moduleElementEdit.ID.Value);

            if (moduleElement == null)
            {
                return(NotFound(new Result
                {
                    State = 0,
                    Message = "修改的角色不存在"
                }));
            }
            moduleElement = Mapper.Map(moduleElementEdit, moduleElement);
            if (ModuleElementServices.EditEntity(moduleElement))
            {
                return(Ok(new Result
                {
                    State = 1,
                    Message = "修改成功"
                }));
            }
            else
            {
                return(BadRequest(new Result
                {
                    State = 0,
                    Message = "修改失败"
                }));
            }
        }
 public ActionResult Edit(ModuleElementEdit moduleElementEdit)
 {
     if (ModelState.IsValid)
     {
         ModuleElement moduleElement = ModuleElementServices
                                       .LoadFirst(r => r.ID == moduleElementEdit.ID.Value);
         if (moduleElement == null)
         {
             return(Json(new Result
             {
                 State = 0,
                 Message = "修改的角色不存在"
             }));
         }
         moduleElement = Mapper.Map(moduleElementEdit, moduleElement);
         if (ModuleElementServices.EditEntity(moduleElement))
         {
             return(Json(new Result
             {
                 State = 1,
                 Message = "修改成功"
             }));
         }
         else
         {
             return(Json(new Result
             {
                 State = 0,
                 Message = "修改失败"
             }));
         }
     }
     else
     {
         IEnumerable <object> errors = ModelStateToJson();
         return(Json(new Result <object>
         {
             State = 0,
             Message = "错误",
             Data = errors
         }));
     }
 }