public async Task <IResultModel> BindBtn(MenuButtonBindModel model) { if (!await _menuRepository.ExistsAsync(m => m.Id == model.MenuId)) { return(ResultModel.Failed("菜单不存在")); } try { _dbContext.Db.BeginTran(); await _menuButtonRepository.DeleteAsync(m => m.MenuId == model.MenuId, _dbContext.Db); model.Buttons.ForEach(m => { m.MenuId = model.MenuId; }); await _menuButtonRepository.InsertRangeAsync(model.Buttons, _dbContext.Db); _dbContext.Db.CommitTran(); } catch (Exception ex) { _dbContext.Db.RollbackTran(); return(ResultModel.Failed(ex.Message)); } return(ResultModel.Success()); }
public Task <IResultModel> BindBtn(MenuButtonBindModel model) { return(_service.BindBtn(model)); }