0

我有一个传入参数的方法,所有参数都保存一个值,但是当我将它们分配给我的 viewModel 时,其中一个变为空,不知道为什么:

[HttpPost]
    [ValidateInput(false)]
    public ActionResult Create(VisitViewModel viewModel, Guid[] associatedCasesSelected, Guid[] selectedParties)
    {
        if (!ModelState.IsValid)
        {
            viewModel.Time = _timeEntryHelper.Value;
            AddLookupsToViewModel(viewModel);
            return View(viewModel);
        }
        var visitEntry = Mapper.Map<VisitViewModel, VisitEntry>(viewModel);
        visitEntry.VisitDate = _timeEntryHelper.AddTimeToDate(visitEntry.VisitDate);
        visitEntry.UserId = _currentUser.UserId;
        visitEntry.OfficeId = _currentUser.OfficeId;
        viewModel.AssociatedCasesSelected = associatedCasesSelected;
        viewModel.PartiesSelected = selectedParties;
        try
        {
            _visitEntryService.Create(visitEntry, associatedCasesSelected, selectedParties);
            this.FlashInfo(string.Format(Message.ConfirmationMessageCreate, Resources.Entities.Visit.EntityName));
        }
        catch (RulesException ex)
        {
            ex.CopyTo(ModelState);
        }
        if (ModelState.IsValid)
            return RedirectToAction("Edit", "Case", new { caseId = viewModel.CaseId });
        AddLookupsToViewModel(viewModel);
        return View(viewModel);
    }

这是行:

viewModel.PartiesSelected = selectedParties;

selectedParties 应该保持一个值,但是当我将其分配给partySelected 时-它在调试时显示了PartiesSelected = null;

这是在我的 viewModel 中选择的party:

public IList<Guid> PartiesSelected { get; set; }
4

0 回答 0