나는 뷰 모델을 가지고 어떻게 출력합니까ViewModel에서 메서드에 액세스하는 방법?
[HttpGet]
public ActionResult UserDetails(int id)
{
var user = ZincService.GetUserForId(id);
if (user == null || user.Customer.CustomerId != CurrentCustomer.CustomerId)
return DataNotFound();
ManageUserViewModel viewModel = new ManageUserViewModel();
viewModel.User = user;
viewModel.IsLockedOut = MembershipService.IsUserLocked(user.Email);
viewModel.IsActivated = user.DateTimeActivated.HasValue && MembershipService.IsUserApproved(user.Email);
viewModel.IsArchived = user.IsArchived;
viewModel.User.GetParticipatingIncentivePrograms();
return View(viewModel);
}
:
/// Gets the incentive programs that this user is participating in.
public IEnumerable<IncentiveProgram> GetParticipatingIncentivePrograms()
{
return Node.ParticipatingIncentivePrograms
.Where(x => x.PublishingState == PublishingState.Live
&& DateTime.UtcNow.Date >= x.DateStart && DateTime.UtcNow.Date <= x.DateEnd);
}
그때 난 내 컨트롤러가 :
Entities.User 사용자의public class ManageUserViewModel
{
public Entities.User User { get; set; }
public bool IsLockedOut { get; set; }
public bool IsActivated { get; set; }
public bool IsArchived { get; set; }
}
내가하는 방법이 내보기에 GetParticipatingIncentivePrograms 중? 아직 내보기에 코드가 없습니다.
감사합니다.
이 코드가 다른 사람이 작성했으며 아키텍처를 변경할 수 없다는 점을 두려워합니다. –