emonney / QuickApp

ASP.NET Core / Angular startup project template with complete login, user and role management. Plus other useful services for Quick Application Development
https://www.ebenmonney.com/quickapp
MIT License
1.26k stars 594 forks source link

Unable to get customers #55

Closed webdev8183 closed 6 years ago

webdev8183 commented 6 years ago

This isn't really a bug, just a feature request, would it be possible to get an example of how to pull customers data out of the api? I have been struggling with this as I am fairly new to angular and need the ability to do crud against the user and products tables, and just cannot seem to figure out how to do this. So far I have started trying to build a customer-service to do it but I can't seem to get it working.. Here is what I have so far.. import { Injectable } from '@angular/core'; import { Router, NavigationExtras } from "@angular/router"; import { Http, Headers, Response } from '@angular/http'; import { Observable } from 'rxjs/Observable'; import { Subject } from 'rxjs/Subject'; import 'rxjs/add/observable/throw'; import 'rxjs/add/operator/catch'; import 'rxjs/add/operator/do'; import { AccountEndpoint } from './account-endpoint.service'; import { AuthService } from './auth.service'; import { User } from '../models/user.model'; import { Role } from '../models/role.model'; import { Permission, PermissionNames, PermissionValues } from '../models/permission.model'; import { UserEdit } from '../models/user-edit.model';

@Injectable() export class CustomerService { private readonly _usersUrl: string = "/api/customer/users"; private readonly _userByUserNameUrl: string = "/api/customer/users/username"; private readonly _currentUserUrl: string = "/api/customer/users/me"; private readonly _currentUserPreferencesUrl: string = "/api/customer/users/me/preferences"; private readonly _unblockUserUrl: string = "/api/customer/users/unblock";

//public static readonly customerAddedOperation: CustomerChangedOperation = "add";
//public static readonly customerDeletedOperation: CustomerChangedOperation = "delete";
//public static readonly customerModifiedOperation: CustomerChangedOperation = "modify";
private _customerUrl = this._usersUrl

constructor(private router: Router, private http: Http, private authService: AuthService
    ) {

}
getCustomers() {
    return this.getCustomers;
}

}

webdev8183 commented 6 years ago

I could possibly figure this out if I knew how to get the oauthbearer token out so I could use it in postman for debugging.

webdev8183 commented 6 years ago

ugh, I thought I was making headway and maybe I am, I added the following.. a customer-service.ts file.. (attaching to this post) a customer.ts file (which just maps my customer properties and exports as an interface) and I modifed customer.component.ts (also attaching)

I also added some providers and some imports to app.module.ts, to try and get all this to work.. the added imports.. import { CustomerService } from "./services/customer-service"; import { HttpClient, HttpErrorResponse,HttpHandler } from '@angular/common/http'; the added providers.. CustomerService, HttpClient, HttpHandler I tried to attach the files but apparently they don't support the filetypes so I renamed them all to text files.. in case anyone reads this.. customer - Copy.txt customers.component.txt customer-service - Copy.txt app.module - Copy.txt

ERROR in [at-loader] ./ClientApp/app/app.module.ts:76:11 TS2345: Argument of type '{ imports: (typeof BrowserModule | ModuleWithProviders | typeof BrowserAnimationsModule)[]; decla...' is not assignable to parameter of type 'NgModule'. Types of property 'providers' are incompatible. Type '(typeof AlertService | typeof ConfigurationService | typeof AppTitleService | typeof AppTranslati...' is not assignable to type 'Provider[]'. Type 'typeof AlertService | typeof ConfigurationService | typeof AppTitleService | typeof AppTranslatio...' is not assignable to type 'Provider'. Type 'typeof HttpHandler' is not assignable to type 'Provider'. Type 'typeof HttpHandler' is not assignable to type 'FactoryProvider'. Property 'provide' is missing in type 'typeof HttpHandler'.

Really would appreciate some help, trying very hard to figure this out, but with a complex app such as this my lack of knowledge is really getting in my way. any pointers appreciated. If I do manage to figure it out I will update this thread in case others want to do similar to what I am trying to do.

emonney commented 6 years ago

Customers, orders, products are placeholders/examples/fictitious pages. The app is a startup template and these business specific logic are not implemented by design.

Its recommended to take some tutorials to understand the basic topology of angular apps and how they connect to the backend/api.

webdev8183 commented 6 years ago

Thanks for the reply, I am going through courses on pluralsight as fast as I can trying to get up to speed on it. I am much more familiar with MVC than angular, so not used to working with promises and observables, I am sure I will get it eventually, I was hoping for sooner rather than later, for the time being I am trying to find a regular 9-5 gig. Since I don’t have enough clients yet to break free from the corporate grind.

From: Ebenezer Monney [mailto:notifications@github.com] Sent: Tuesday, December 5, 2017 12:34 AM To: emonney/QuickApp QuickApp@noreply.github.com Cc: Monty medwardsfl@comcast.net; Author author@noreply.github.com Subject: Re: [emonney/QuickApp] Unable to get customers (#55)

Closed #55 https://github.com/emonney/QuickApp/issues/55 .

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/emonney/QuickApp/issues/55#event-1371941658 , or mute the thread https://github.com/notifications/unsubscribe-auth/AHIvK2y6wl1JQcKu82S4NCQQ3vsymic3ks5s9NWsgaJpZM4QxvhC . https://github.com/notifications/beacon/AHIvK8JnOgEgpIMzv1_2TLtKB5RTFxRQks5s9NWsgaJpZM4QxvhC.gif