Company logo
  • Jobs
  • Bootcamp
  • About Us
  • For professionals
    • Home
    • Jobs
    • Courses
    • Questions
    • Teachers
    • Bootcamp
  • For business
    • Home
    • Our process
    • Plans
    • Assessments
    • Payroll
    • Blog
    • Calculator

0

56
Views
Angular GET Method Null Reference

In my app, I'm trying to display a list of elements. For this, I have to make a get call with 2 parameters to back-end. I get a Null Reference in Visual Studio when I open the page. Here is the code. So far I've done this, but I don't know how to solve the error. What should I do to fix it?

Service TS:

getWorkItemStockTransactionList(filter: IFilter): Observable<IStockTransaction[]> {
    return this._httpOrder.get('Order/GetWorkItemStockTransactionList/'+ filter);
}

TS:

  transactionList: IStockTransaction[] = [];

  private _selectedWorkItem: IWorkItem;
  Filter: IFilter;
  @Input()
  set StockTransaction(prm: IWorkItem) {
      if (this._selectedWorkItem != prm) {
          this._selectedWorkItem = prm;
                  
          this.dataSource = new MatTableDataSource(this.transactionList);        
          this.getWorkItemStockTransactionList((this._selectedWorkItem.Product.ProductId) , (this.Order.OrderId));
      }
  }
  @Input() Order: IOrder;
   getWorkItemStockTransactionList(productId , orderId) {
    this._orderService
        .getWorkItemStockTransactionList(this.Filter)
        .subscribe((response: IStockTransaction[]) => {
            this.dataSource = new MatTableDataSource(response);
            this.transactionList = response;
        });
  }

Back-end:

        [HttpGet]
            public List<DtoStockTransaction> GetWorkItemStockTransactionList(DTOFilter dTOFilter)
            {
                return StockSpProvider.GetWorkItemStockTransactionList(dTOFilter);
            }
    
            public static List<DtoStockTransaction> GetWorkItemStockTransactionList(DTOFilter prm)
            {
//this is where I get the error
                SqlParameter[] parameters = new SqlParameter[]
                {
                    new SqlParameter("@ProductId",prm.Product.ProductId),
                    new SqlParameter("@OrderId",prm.Order.OrderId)
                };
    ...
    }
7 months ago ยท Juan Pablo Isaza
Answer question
Find remote jobs