I am creating an MVC application where I am sending an email to JIRA. I initially had it working like this:

In the controller:

Public Function SubmitIssue(<Bind(Include:="IssueID,IssueSummary,IssueDescription")>
issuetable As IssueTable) As ActionResult

mail.Subject = issuetable.IssueSummary
Dim body As String = issuetable.IssueDescription

In the view:

@ModelType IssueTable

@Html.EditorFor(Function(model) model.IssueSummary)
@Html.EditorFor(Function(model) model.IssueDescription)

This initially worked but I needed to have multiple tables to send data so I created a viewModel like this:

Public Class ViewModel
    Public proTableList As List(Of ProjectType)
    Public cTableList As List(Of ClientTable)
    Public proTable As ProjectType
    Public iTable As IssueTable
End Class

In the view I displayed information like this:

@ModelType IssueTracker.ViewModel

@Html.EditorFor(Function(model) model.iTable.IssueSummary)
@Html.EditorFor(Function(model) model.iTable.IssueDescription)

Now the problem lies in my in the controller because the way I am trying to populate the description and summary like this I get a null error:

Public Function SubmitIssue(<Bind(Include:="IssueID,IssueSummary,IssueDescription")>
test As IssueTracker.ViewModel.ClientUserProjectIssue) As ActionResult

mail.Subject = test.iTable.IssueSummary
Dim body As String = test.iTable.IssueDescription

This is not the correct way to get a value into a variable / email by using a viewModel, does anyone know how I can do this correctly? (Can be explained using c# or vba as I can code in both but for this project I had to code using vba)

Related posts

Recent Viewed