import { Component, EventEmitter, OnInit, Output } from '@angular/core'; import { finalize } from 'rxjs'; import { NotifyService } from 'abp-ng2-module'; import { BsModalRef } from 'ngx-bootstrap/modal'; import { AdminServiceServiceProxy, CategorySubDto, ResultDto } from '@shared/service-proxies/service-proxies'; @Component({ selector: 'app-help2-subcat', templateUrl: './help2-subcat.component.html', }) export class Help2SubcatComponent implements OnInit{ constructor( private _adminService: AdminServiceServiceProxy, public bsModalRef: BsModalRef, public notify: NotifyService ) { } saving = false; data: CategorySubDto; Name: string; Description: string; Code: string; ImageUrl: string | undefined; CategoryTypeId: number | undefined; selectedMasterId: number; @Output() onSave = new EventEmitter(); ngOnInit(): void { if(!this.data.id) { this.data.name = this.Name; this.data.code = this.Code; this.data.description = this.Description; this.data.imageUrl = this.ImageUrl; this.data.categoryTypeId = this.CategoryTypeId; this.data.masterCategoryId = this.selectedMasterId } } save() { this.saving = true; this._adminService.setCategorySub(this.data) .pipe( finalize(() => { //finishedCallback(); }) ) .subscribe((result: ResultDto) => { if (result.success) { this.notify.success("İşlem Başarılı"); this.saving = false; this.bsModalRef.hide(); this.onSave.emit(); } }, () => { this.saving = false; } ); } } ------------------------------ export class CategorySubDto implements ICategorySubDto { id: number; masterCategoryId: number | undefined; name: string | undefined; code: string | undefined; description: string | undefined; imageUrl: string | undefined; categoryTypeId: number | undefined; constructor(data?: ICategorySubDto) { if (data) { for (var property in data) { if (data.hasOwnProperty(property)) (this)[property] = (data)[property]; } } } init(_data?: any) { if (_data) { this.id = _data["id"]; this.masterCategoryId = _data["masterCategoryId"]; this.name = _data["name"]; this.code = _data["code"]; this.description = _data["description"]; this.imageUrl = _data["imageUrl"]; this.categoryTypeId = _data["categoryTypeId"]; } } static fromJS(data: any): CategorySubDto { data = typeof data === 'object' ? data : {}; let result = new CategorySubDto(); result.init(data); return result; } toJSON(data?: any) { data = typeof data === 'object' ? data : {}; data["id"] = this.id; data["masterCategoryId"] = this.masterCategoryId; data["name"] = this.name; data["code"] = this.code; data["description"] = this.description; data["imageUrl"] = this.imageUrl; data["categoryTypeId"] = this.categoryTypeId; return data; } clone(): CategorySubDto { const json = this.toJSON(); let result = new CategorySubDto(); result.init(json); return result; } } export interface ICategorySubDto { id: number; masterCategoryId: number | undefined; name: string | undefined; } ------------------------------
-------------------------