public ServiceResult Edit(RoleAddAndEditModel model) { var sysRole = GetByRoleId(model.SysRoleId); sysRole.RoleName = model.RoleName; _skyChenContext.SysRole.Update(sysRole); var result = _skyChenContext.SaveChanges() > 0; return(result ? ServiceResult.IsSuccess("编辑成功!") : ServiceResult.IsFailed("编辑失败!")); }
public ServiceResult Add(RoleAddAndEditModel model) { if (IsExist(model.RoleName)) { return(ServiceResult.IsFailed("已存在该角色名!")); } var sysUserId = GuidHelper.NewOrder().ToString("N"); var sysUser = new SysRole { CreateDateTime = DateTime.Now, RoleStatus = (int)ERoleStatus.On, SysRoleId = sysUserId, RoleName = model.RoleName }; _skyChenContext.SysRole.Add(sysUser); var result = _skyChenContext.SaveChanges() > 0; return(result ? ServiceResult.IsSuccess("添加成功!") : ServiceResult.IsFailed("添加失败!")); }