0

I have created a simple form on the Asp.net boiler template project. I have a total of three fields In Table 1

  1. Product name
  2. Quantity

In Table2

  1. Tags with product List

I wanted to store third field data in another table in the database. but I'm confused as I'm a beginner. The product name and quantity is working fine. Can someone please guide me? Why data in the 2nd table is stored as null?

(1) This is chips code ( from priming)

(2) This is my class code (in which all three data members exist

(3) This is my Product list class code for storing chips

(4) This is database table of Product

(5) This is Database table of Product list class

This is new attached image

Error Image

import {Component,Injector,OnInit,EventEmitter,Output,} from '@angular/core';
import { finalize } from 'rxjs/operators';
import { BsModalRef } from 'ngx-bootstrap/modal';
import * as _ from 'lodash';
import { AppComponentBase } from '@shared/app-component-base';
import {
ProductServiceProxy,
ProductDto,
Product_listDto,
Product_listServiceProxy
} from '@shared/service-proxies/service-proxies';

@Component({
templateUrl: 'create-product.component.html'
})
export class CreateProductComponent extends AppComponentBase
implements OnInit {
saving = false;
product = new ProductDto();

@Output() onSave = new EventEmitter<any>();

constructor(
 injector: Injector,
 private _productService: ProductServiceProxy,
 public bsModalRef: BsModalRef
) {
super(injector);
}

ngOnInit(): void {
}

save(): void {
this.saving = true;
console.log("input",this.product)
const product = new ProductDto();
product.init(this.product);

this._productService
  .create(product)
  .pipe(
    finalize(() => {
      this.saving = false;
    })
  )
  .subscribe(() => {
    this.notify.info(this.l('SavedSuccessfully'));
    this.bsModalRef.hide();
    this.onSave.emit();
  });
}
}

1 Answers1

0

Your p-chip returns a string array but your back end requiring a object of product_list.you need to pass the a `product_list' object array to the backend.

save(): void {
    this.saving = true;
    console.log("input",this.product)
    let productList = [...this.product.productList];
    this.product.productList = productList.map(item=>{
        return {
            Id: 0,
            Name: item
        }
    });
    const product = new ProductDto();
    product.init(this.product);
 }