I have 2 respective tables in my MVC5 Application involving Member Dues:

[MemberDues] -- [Id], [Year], [Display], [Amount]

[MemberDuesReceived] -- [Id], [MemberDuesId], [MemberOrgId], [PaidByUserId], [TransactionId], [Paid], [DatePaid], [PaymentMethod], [PayPalPaymentId], [PayPalPayerId], [PayPalPaymentState]

For the MemberDuesManageController I am trying to create a ViewDuesPaidMembers() method where I return a list of all the MemberOrgs who have paid their dues. Now, I can get the current MemberDues.[Id] by passing my Model Id from a button on my Index View, and searching the database: MemberDues memberDues = await db.MemberDues.FindAsync(id);

What I'm unsure of is how I use this MemberDues.[Id] to search the MemberDuesReceived table and return a list of all the MemberDuesReceived.[MemberOrgId] with a [Paid] value of True within my ActionResult.

Below is what I have thus far. Can anyone provide an example of how I can return the appropriate list of MemberOrgs from the other table?

public async Task<ActionResult> ViewDuesPaidMembers(int id)
        {
            MemberDues memberDues = await db.MemberDues.FindAsync(id);
            return null;
        }

EDIT:

Taking into account Jonesy's suggestion I now have:

 public async Task<ActionResult> DuesPaidMembers(int id)
        {
            MemberDues memberDues = await db.MemberDues.FindAsync(id);
            var duesPaidList = db.MemberDuesReceived.Where(mdr => mdr.MemberDuesId == id && mdr.Paid).ToList();
            return View(duesPaidList);
        }

What I'm trying to figure out now is how to set up my Button so that it will use the new controller method DuesPaidMembers() and redirect to view DuesPaidMember.cshtml to display my list of paid MemberOrgs:

<a href="MembersDuesManage/DuesPaidMembers/@item.Id" class="btn btn-default btn-sm noDecoration"><span class="glyphicon glyphicon-list-alt"></span>  View Paid</a>

Currently my button takes me to http://localhost:15160/Admin/MembersDuesManage/DuesPaidMembers/1, with a message of: "The resource cannot be found."

Related posts

Recent Viewed