/// <summary> /// 添加或修改菜单 /// </summary> /// <param name="model"></param> /// <param name="appid"></param> /// <returns></returns> public ActionResult Save(MenuInputDto model, string appid) { model.ParentId = model.ParentId == 0 ? null : model.ParentId; if (string.IsNullOrEmpty(model.IconUrl) || !model.IconUrl.Contains("/")) { model.IconUrl = null; } Menu m = MenuBll.GetById(model.Id); if (m == null) { if (!string.IsNullOrEmpty(appid) && ClientAppBll.Any(a => a.AppId.Equals(appid))) { ClientApp app = ClientAppBll.GetFirstEntity(a => a.AppId.Equals(appid)); app.Menus.Add(model.Mapper <Menu>()); bool saved = ClientAppBll.UpdateEntitySaved(app); return(ResultData(null, saved, saved ? "添加成功" : "添加失败")); } var menu = MenuBll.AddEntitySaved(model.Mapper <Menu>()); return(menu != null?ResultData(menu, true, "添加成功") : ResultData(null, false, "添加失败")); } Mapper.Map(model, m); bool b = MenuBll.UpdateEntitySaved(m); return(ResultData(null, b, b ? "修改成功" : "修改失败")); }