我有一個名爲TicketsController.vb控制器,具有動作結果:我可以比在控制器的一個「細節」的ActionResult更多?
'
' GET: /Tickets/Details/5
Public Function Details(ByVal id As Integer) As ActionResult
ViewData("OpenTixCount") = ticketRepository.countOpenTickets.Count()
ViewData("UrgentTixCount") = ticketRepository.countUrgentTickets.Count()
ViewData("HighTixCount") = ticketRepository.countHighTickets.Count()
ViewData("NormalTixCount") = ticketRepository.countNormalTickets.Count()
ViewData("LowTixCount") = ticketRepository.countLowTickets.Count()
Dim ticket As hdCall = ticketRepository.GetTicket(id)
If ticket Is Nothing Then
Return View("NotFound")
Else
ViewData("MyTicketID") = ticket.CallID
ViewData("UserThatLogged") = ticket.hdUser.RealName
ViewData("CustomerName") = ticket.hdCustomer.CustomerName
ViewData("TimeLogged") = ticket.loggedOn.ToLongDateString & " " & ticket.loggedOn.ToLongTimeString
ViewData("CustomerID") = ticket.CustomerID
ViewData("CustomerEmail") = ticket.hdCustomer.Email
Dim custID As Integer = ticket.CustomerID
Dim TicketsForCustomer = ticketRepository.GetTicketsForThisCustomer(custID).Count()
ViewData("TicketsForCustomerCount") = TicketsForCustomer
Dim dataContext As New CustomerServicesDataContext
ViewData("TicketStatus") = New SelectList(dataContext.hdStatus, "StatusID", "Status", ticket.StatusID)
ViewData("TicketType") = New SelectList(dataContext.hdCategories, "CategoryID", "Title", ticket.CategoryID)
ViewData("TicketPriority") = New SelectList(dataContext.hdPriorities, "PriorityID", "Priority", ticket.PriorityID)
ViewData("CompanyType") = New SelectList(dataContext.hdCompanies, "CompanyID", "Company", ticket.CompanyID)
ViewData("CallDetails") = ticket.CallDetails
End If
Return View(ticket)
End Function
我還添加了另一個叫做客戶,其目的是通過搶客戶ID門票的列表。我使用的是做到這一點的代碼是:
'
'GET: /Tickets/Customer/1
Public Function Customer(ByVal custID As Integer) As ActionResult
ViewData("OpenTixCount") = ticketRepository.countOpenTickets.Count()
ViewData("UrgentTixCount") = ticketRepository.countUrgentTickets.Count()
ViewData("HighTixCount") = ticketRepository.countHighTickets.Count()
ViewData("NormalTixCount") = ticketRepository.countNormalTickets.Count()
ViewData("LowTixCount") = ticketRepository.countLowTickets.Count()
Dim cust As hdCustomer = customerRepository.GetCustomerDetails(custID)
Dim tickets = ticketRepository.FindAllTicketsForThisCustomer(custID)
ViewData("CustomerName") = cust.CustomerName
ViewData("CustomerEmail") = cust.Email
Dim TicketsForCustomer = ticketRepository.GetTicketsForThisCustomer(custID).Count()
ViewData("TicketsForCustomerCount") = TicketsForCustomer
Return View(tickets)
End Function
然而,當我訪問/票/客戶/ 1例如網頁,我收到錯誤:
The parameters dictionary contains a null entry for parameter 'custID' of non-nullable type 'System.Int32' for method 'System.Web.Mvc.ActionResult Customer(Int32)' in 'CustomerServicesHelpdesk.TicketsController'. To make a parameter optional its type should be either a reference type or a Nullable type. Parameter name: parameters
我「M不太肯定我要去哪裏錯了這裏,但不可能是因爲我有2個ActionResults尋找類似的路線?
感謝您提前提供任何幫助。