IMPORTANT!
This forum is now archived. Click here for the New Support Forum
How to replace the hard coded demoNotification with sql server data
Quote from walid336 on March 31, 2018, 8:51 ami created a class notification.cs in the backend with repository and controller and could successfully get and post with api/notification, however,
in the notification-endpoint.service tried to replace with api but could not be applied. could you help please?
i created a class notification.cs in the backend with repository and controller and could successfully get and post with api/notification, however,
in the notification-endpoint.service tried to replace with api but could not be applied. could you help please?
Quote from Al Ve on April 1, 2018, 12:06 pmThis is so unclear and it misses a lot of information.
What's happening, what's the error message, what's your api, ...?
This is so unclear and it misses a lot of information.
What's happening, what's the error message, what's your api, ...?
Quote from walid336 on April 1, 2018, 4:07 pmin the notifications-endpoint.service i replace demoNotifications with
export class NotificationEndpoint {demoNotifications: any[];constructor (private http: HttpClient){}getNotificaitons(){constdemoNotifications=this.http.get('api/notifications').subscribe((demonotifications:any[])=>demonotifications=this.demoNotifications)returnthis.demoNotifications}when i ran the app, demoNotifications is undefined and the notifications show no data although in the back there have been data uploaded
in the notifications-endpoint.service i replace demoNotifications with
Quote from Al Ve on April 3, 2018, 10:47 amThe endpoint provides access to the api endpoint (your backend rest api). You're mixing things.
Example:
The customer controller class has a method to get all the CustomersData from the DB
There's a GET on the rest api "/api/customers"
// GET: api/values
[HttpGet]
public IActionResult Get()
{
var allCustomers = _unitOfWork.Customers.GetAllCustomersData();
return Ok(Mapper.Map<IEnumerable<CustomerViewModel>>(allCustomers));
}The endpoint service contains the urls to the backend rest api:
export class CustomerEndpoint extends EndpointFactory {
private readonly _customersUrl: string = "/api/customer";
private readonly _currentCustomerUrl: string = "/api/customer";get customersUrl() { return this.configurations.baseUrl + this._customersUrl; }
constructor(http: HttpClient, configurations: ConfigurationService, injector: Injector) {
super(http, configurations, injector);
}getCustomersEndpoint<T>(page?: number, pageSize?: number): Observable<T> {
let endpointUrl = page && pageSize ? `${this.customersUrl}/${page}/${pageSize}` : this.customersUrl;return this.http.get<T>(endpointUrl, this.getRequestHeaders())
.catch(error => {
return this.handleError(error, () => this.getCustomersEndpoint(page, pageSize));
});
}The service provides you a method to get the customers. the service uses the endpoint url
@Injectable()
export class CustomerService {constructor(
private router: Router,
private http: HttpClient,
private authService: AuthService,
private customerEndpoint: CustomerEndpoint) { }getCustomers(page?: number, pageSize?: number) {
return this.customerEndpoint.getCustomersEndpoint<Customer[]>(page, pageSize);
}You could have a customers page that when it's accessed it loads the customers data. The ts contains the service, on that service it calls the getCustomers
private loadData() {
this.alertService.startLoadingMessage();
this.loadingIndicator = true;this.customerService.getCustomers().subscribe(
results => this.onDataLoadSuccessful(results),
error => this.onDataLoadFailed(error)
);
}When it loads successfully they are assigned to the datasource
private onDataLoadSuccessful(customers: Customer[]) {
this.alertService.stopLoadingMessage();
this.loadingIndicator = false;
this.dataSource.data = customers;}
The endpoint provides access to the api endpoint (your backend rest api). You're mixing things.
Example:
The customer controller class has a method to get all the CustomersData from the DB
There's a GET on the rest api "/api/customers"
// GET: api/values
[HttpGet]
public IActionResult Get()
{
var allCustomers = _unitOfWork.Customers.GetAllCustomersData();
return Ok(Mapper.Map<IEnumerable<CustomerViewModel>>(allCustomers));
}
The endpoint service contains the urls to the backend rest api:
export class CustomerEndpoint extends EndpointFactory {
private readonly _customersUrl: string = "/api/customer";
private readonly _currentCustomerUrl: string = "/api/customer";
get customersUrl() { return this.configurations.baseUrl + this._customersUrl; }
constructor(http: HttpClient, configurations: ConfigurationService, injector: Injector) {
super(http, configurations, injector);
}
getCustomersEndpoint<T>(page?: number, pageSize?: number): Observable<T> {
let endpointUrl = page && pageSize ? `${this.customersUrl}/${page}/${pageSize}` : this.customersUrl;
return this.http.get<T>(endpointUrl, this.getRequestHeaders())
.catch(error => {
return this.handleError(error, () => this.getCustomersEndpoint(page, pageSize));
});
}
The service provides you a method to get the customers. the service uses the endpoint url
@Injectable()
export class CustomerService {
constructor(
private router: Router,
private http: HttpClient,
private authService: AuthService,
private customerEndpoint: CustomerEndpoint) { }
getCustomers(page?: number, pageSize?: number) {
return this.customerEndpoint.getCustomersEndpoint<Customer[]>(page, pageSize);
}
You could have a customers page that when it's accessed it loads the customers data. The ts contains the service, on that service it calls the getCustomers
private loadData() {
this.alertService.startLoadingMessage();
this.loadingIndicator = true;
this.customerService.getCustomers().subscribe(
results => this.onDataLoadSuccessful(results),
error => this.onDataLoadFailed(error)
);
}
When it loads successfully they are assigned to the datasource
private onDataLoadSuccessful(customers: Customer[]) {
this.alertService.stopLoadingMessage();
this.loadingIndicator = false;
this.dataSource.data = customers;
}
Quote from walid336 on April 4, 2018, 7:55 amThank you for your support,,
with this implementation notificationEndpoint still expects a data source rather than an obsevable in line
let notification=this.demoNotifications.find(val =>val.id ==notificationId);wheredemoNotifications: Notification[]the page is modified asdemoNotifications: Notification[]private readonly _notificationsUrl:string="api/notifications";getnotificationsUrl() {return this.configurations.baseUrl+this._notificationsUrl;}constructor(http: HttpClient, configurations: ConfigurationService, injector: Injector) {super(http, configurations, injector);}getNotificationsEndpoint<T>(page?:number, pageSize?:number): Observable<T> {letendpointUrl=page&&pageSize?`{this.notificationUrl}/${page}/${pageSize}`:this.notificationsUrl;returnthis.http.get<T>(endpointUrl, this.getRequestHeaders()).catch(error => {returnthis.handleError(error, () =>this.getNotificationsEndpoint(page,pageSize));});}getNotifications(page?:number, pageSize?:number){return this.getNotificationsEndpoint<Notification[]>(page,pageSize)}
Thank you for your support,,
with this implementation notificationEndpoint still expects a data source rather than an obsevable in line
demoNotifications: Notification[]private readonly _notificationsUrl:string="api/notifications";getnotificationsUrl() {return this.configurations.baseUrl+this._notificationsUrl;}constructor(http: HttpClient, configurations: ConfigurationService, injector: Injector) {super(http, configurations, injector);}getNotificationsEndpoint<T>(page?:number, pageSize?:number): Observable<T> {letendpointUrl=page&&pageSize?`{this.notificationUrl}/${page}/${pageSize}`:this.notificationsUrl;returnthis.http.get<T>(endpointUrl, this.getRequestHeaders()).catch(error => {returnthis.handleError(error, () =>this.getNotificationsEndpoint(page,pageSize));});}getNotifications(page?:number, pageSize?:number){return this.getNotificationsEndpoint<Notification[]>(page,pageSize)}
Quote from Al Ve on April 5, 2018, 9:57 amCould you zip your code, remove any passwords, user id, ip address for the connectionstring and mail if there's one and send it to alve.eben@gmail.com so I can have a look?
We're still missing informations.
Could you zip your code, remove any passwords, user id, ip address for the connectionstring and mail if there's one and send it to alve.eben@gmail.com so I can have a look?
We're still missing informations.
Quote from walid336 on April 7, 2018, 10:30 amThanks again for your support, i was trying to fix it with no luck, please see attached project, the url is api/notifications
I couldnot send the zip file to the email, it get an error not allowing zip files
I had an invitatin ot github repo
https://github.com/QadMohKuwait/Quick-App-Pro/invitations
Thanks again for your support, i was trying to fix it with no luck, please see attached project, the url is api/notifications
I couldnot send the zip file to the email, it get an error not allowing zip files
I had an invitatin ot github repo
https://github.com/QadMohKuwait/Quick-App-Pro/invitations
IMPORTANT!
This forum is now archived. Click here for the New Support Forum