Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8818733
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T05:10:47+00:00 2026-06-14T05:10:47+00:00

i have a viewmodel: public class ManageUserViewModel { public Entities.User User { get; set;

  • 0

i have a viewmodel:

public class ManageUserViewModel
{
  public Entities.User User { get; set; }
  public bool IsLockedOut { get; set; }
  public bool IsActivated { get; set; }
  public bool IsArchived { get; set; }
}

in Entities.User User i have a method:

/// 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);
}

then i have my controller:

   [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);
}

how do i get to output of GetParticipatingIncentivePrograms in my view?
I dont have code in my view yet.

thanks

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T05:10:48+00:00Added an answer on June 14, 2026 at 5:10 am

    Imho, you’d be better representing your incentive programs in your view model. In fact to have a userViewModel and then probably have a list of programs within this. Then load these within your controller

    ManageUserViewModel{
       public UserViewModel User { get; set; }
    }
    
    UserViewModel {
       public List<string> ParticipatingIncentivePrograms { get; set; }
    }
    

    It’s usually best to not load your whole domain graph into a view as you could run into several issues (N+1 db calls, accessing a closed proxy, etc). I’ve typed your programs as a simple list of names, but you might expand this to a dictionary or lookup. Again keeping the view model as light and simple as possible.

    UPDATE:

    As you can’t change the viewmodel then it looks like you must set the value, you are only calling at present. So try the following

     viewModel.User.ParticipatingIncentivePrograms = 
            viewModel.User.GetParticipatingIncentivePrograms();
    

    If there is such a collection on user or set them to something else on your view model.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Suppose you have a viewModel: public class CreatePersonViewModel { [Required] public bool HasDeliveryAddress {get;set;}
I have a viewmodel. public class RegistrationViewModel { public RegisterModel Register { get; set;
I have something like this public class ViewModel { public List<Books> Test {get; set;}
I have a ViewModel as such: public class EmployeeViewModel { Employees employee{ get; set;
I have the following ViewModel public class NewCustomerViewModel { public long CustomerId {get;set;} public
I have a ViewModel: public class Page { public int Id { get; set;
I have a simple ViewModel: public class IndexViewModel { public bool ShowWelcomeMsg { get;
I have the following ViewModel: public class ViewModel { public Address Address {get;set;} [DisplayName(State)]
I have the following ViewModel public class RecommendationModel { public List<CheckBoxItem> CheckBoxList { get;
Suppose I have ViewModel like public class AnotherViewModel { public string Name { get;

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.