/// <summary> /// 新增\修改 /// </summary> /// <param name="Dto"></param> /// <returns></returns> public async Task <Guid> SaveAsync(Sys_MenuDto Dto) { var model = Dto.Model; var functionIds = Dto.FunctionIds; model = await this.InsertOrUpdateAsync(model); // await dbMenuFunction.DeleteAsync(w => w.MenuFunction_MenuID == model.Menu_ID); if (functionIds.Count > 0) { var _Sys_MenuFunctionList = await dbMenuFunction.ToListAsync(w => w.MenuFunction_MenuID == model.Menu_ID); foreach (var item in functionIds) { var _Sys_MenuFunction = _Sys_MenuFunctionList.FirstOrDefault(w => w.MenuFunction_FunctionID == item); var menufuncModel = new Sys_MenuFunction(); menufuncModel.MenuFunction_ID = _Sys_MenuFunction == null?Guid.NewGuid() : _Sys_MenuFunction.MenuFunction_ID; menufuncModel.MenuFunction_FunctionID = item; menufuncModel.MenuFunction_MenuID = model.Menu_ID; await dbMenuFunction.InsertAsync(menufuncModel); } } return(model.Menu_ID); }
/// <summary> /// 删除 /// </summary> /// <param name="Ids"></param> /// <returns></returns> public async Task <int> DeleteAsync(List <Guid> Ids) { await dbRoleMenuFunction.DeleteAsync(w => Ids.Contains(w.RoleMenuFunction_MenuID)); await dbMenuFunction.DeleteAsync(w => Ids.Contains(w.MenuFunction_MenuID)); await this.DeleteAsync(w => Ids.Contains(w.Menu_ID)); return(1); }
/// <summary> /// 新增\修改 /// </summary> /// <param name="Dto"></param> /// <returns></returns> public async Task <Guid> SaveAsync(Sys_UserDto Dto) { var model = Dto.Model; var roleIds = Dto.RoleIds; if (string.IsNullOrWhiteSpace(model.User_Pwd)) { MessageBox.Show("密码不能为空!"); } if (model.User_ID == Guid.Empty) { model.User_Pwd = string.IsNullOrWhiteSpace(model.User_Pwd) ? "123" : model.User_Pwd; //Tools.MD5Encrypt("123"); model = await this.InsertAsync(model); } else { await this.UpdateByIdAsync(model); } //变更用户角色 if (roleIds.Count > 0) { var _Sys_UserRoleList = await dbUserRole.ToListAsync(w => w.UserRole_UserID == model.User_ID); await dbUserRole.DeleteAsync(w => w.UserRole_UserID == model.User_ID); foreach (var item in roleIds) { var _Sys_UserRole = _Sys_UserRoleList.FirstOrDefault(w => w.UserRole_RoleID == item); var userRoleModel = new Sys_UserRole(); userRoleModel.UserRole_ID = _Sys_UserRole == null?Guid.NewGuid() : _Sys_UserRole.UserRole_ID; userRoleModel.UserRole_RoleID = item; userRoleModel.UserRole_UserID = model.User_ID; await dbUserRole.InsertAsync(userRoleModel); } } return(model.User_ID); }