I am getting the model values to an action in controller and trying to pass the values to another function in another class by setting it to another object . In the line of invoking the second function, the object throws null exception. It doesnt show null in the if condition check either. Please find code below.
public ActionResult SearchBySecurity(SearchViewModel srchModel)
{
var searchDTO = new VisitorSearchDTO();
//_mapper.Map<SearchViewModel, VisitorSearchDTO>(srchModel,searchDTO);
searchDTO.VisitorFirstName = srchModel.VisitorFirstName;
searchDTO.VisitorContactNumber = srchModel.VisitorContactNumber;
searchDTO.VisitorCompany = srchModel.VisitorCompany;
searchDTO.VisitDate = srchModel.VisitDate;
if (searchDTO != null)
{
var searchResultsDTO = _searchVisitor.SearchForVisitors(searchDTO);
}
ModelState.Clear();
return View("SearchBySecurity",srchModel);