我试图将选定的奖项和选定的法官传递给控制者
vm.assignJudge = function (array, index, judge, award) {
judgeService
.assignJudgeToAward(vm.judges,{ awardId: award.id, userId: judge.id })
.success(function (e) {
toastr.success("Judge assigned!", "Success!");
vm.selectedAward = {};
vm.selectedJudge = {};
});
};
以下是视图的html
<tbody>
<tr role="row" ng-repeat="judge in vm.judges track by judge.id">
<td>
<div class="md-checkbox checkbox-inline">
<input name="judge{{judge.id}}" type="checkbox" ng-model="judge.isSelected" id="judge{{judge.id}}" ng-if="judge" class="md-checkbox" ng-change="vm.selectJudge($index,judge,vm.judges)">
<label for="judge{{judge.id}}">
<span class="inc"></span>
<span class="check"></span>
<span class="box"></span>
</label>
</div>
</td>
<td>
<a>
{{judge.id}}
</a>
</td>
<td>
<a>
{{judge.name}}
</a>
</td>
<td class="text-center">
<i class="fa fa-check" ng-if="judge.isInvitationAccepted"></i>
</td>
<td ng-repeat="award in vm.awards track by award.id">
<div class="md-checkbox checkbox-inline">
<input name="award{{award.id}}" type="checkbox" ng-model="award.isSelected" id="award{{award.id}}" ng-if="award" class="md-checkbox" ng-change="vm.selectAward($index,award,vm.awards)">
<label for="award{{award.id}}">
<span class="inc"></span>
<span class="check"></span>
<span class="box"></span>
</label>
</div>
{{award.name}}
<td>
</td>
</tr>
</tbody>
我正在使用模块零,这是方法代码
public void AssignJudgeToAward(AssignJudgeToAwardInput input)
{
UserAward assignJudgeToAward = _userAwardRepository.FirstOrDefault(a => a.Id == input.UserId);
assignJudgeToAward.Award.Id = input.AwardId;
assignJudgeToAward.User.Id = input.UserId;
_userAwardRepository.InsertOrUpdate(assignJudgeToAward);
_unitOfWorkManager.Current.SaveChanges();
}
我做错了什么?
这是在控制器中调用方法的代码。
<a ng-really-click="vm.assignJudge(judgeGroup.judgeItems, awardGroup.awardItems, $index, vm.selectedAward, vm.selectedJudge)" ng-class="{'disabled': !vm.selectedJudge.id}">
<i></i> Assign Judge
</a>
以下是指派裁判授予职能
vm.assignSelectJudgeToAward = function (position, judge, judges, award, awards) {
angular.forEach(judges, awards, function (currentJudge, currentAward, index) {
if (position !== index) {
currentJudge.isSelected = false;
currentAward.isSelected = false;
} else {
if (currentJudge.id && vm.selectedJudge.id === currentJudge.id && currentAward.id && vm.selectedAward.id === currentAward.id) {
vm.selectedJudge = {};
vm.selectedAward = {};
} else {
vm.selectedJudge = currentJudge;
vm.selectedAward = currentAward;
currentJudge.isSelected = true;
currentAward.isSelected = true;
}
}
});
};
我没有得到错误,我没有得到任何东西。
此代码的目标是将新记录插入名为UserAward的组合表中。