<repo_name>carrielord/FeedTheNeedAngular<file_sep>/src/app/component/postingdetail/postingdetail.component.ts
import { Component, OnInit } from '@angular/core';
import { PostingService } from '../../services/posting.service';
import { MatTableDataSource } from '@angular/material';
import { Posting } from '../../models/posting';
import { ActivatedRoute } from '@angular/router';
import { User } from '../../models/user';

@Component({
  selector: 'app-postingdetail',
  templateUrl: './postingdetail.component.html',
  styleUrls: ['./postingdetail.component.css']
})
export class PostingdetailComponent implements OnInit {

  posting: Posting;
  user: User;

  constructor(private _postingService: PostingService, private _activatedRoute: ActivatedRoute) { }

  columnNames = ['Title:', 'Details:', 'Address:', 'City:', 'State:', 'Organization:', 'Category:', 'Date Posted:', 'Available Until:', 'Is Completed?']

  dataSource: MatTableDataSource<Posting>

  ngOnInit() {
    this._activatedRoute.paramMap.subscribe(routeData => {
      this._postingService.getPostDetail(routeData.get('id')).subscribe((singlePost: Posting) => {
        this.posting = singlePost;
      });
    });
  }

}
<file_sep>/src/app/component/organization/organization-delete/organization-delete.component.ts
import { Component, OnInit } from '@angular/core';
import { ActivatedRoute, Router } from '@angular/router';
import { Organization } from '../../../models/organization';
import { OrganizationService } from '../../../services/organization.service';
import { User } from 'src/app/models/user';
import { UserService } from 'src/app/services/user.service';

@Component({
  selector: 'app-organization-delete',
  templateUrl: './organization-delete.component.html',
  styleUrls: ['./organization-delete.component.css']
})
export class OrganizationdeleteComponent implements OnInit {

  organization: Organization;
  user: User;

  constructor(private _organizationService: OrganizationService, private _userService: UserService, private _ar: ActivatedRoute, private _router: Router) { 
    this._ar.paramMap.subscribe(p => {
      this._organizationService.getOrganization(p.get('id')).subscribe((singleOrganization: Organization) => {
        this.organization = singleOrganization;
      });
    });
  }
  onDelete() {
  this._organizationService.deleteOrganization(this.organization.OrganizationID).subscribe(() => {
  this._router.navigate(['/organizations']);
  });
  }
  ngOnInit() {
    this.getUserRole();
  }
  getUserRole(){
    this._userService.getUser().subscribe((singleUser: User) => {
      this.user = singleUser;
      console.log(this.user.Role)
    })
  }
  isAdmin(){
    if(this.user.Role=='Admin'){
      return true;
    }
  }
}
<file_sep>/src/app/component/postinguserdetail/postinguserdetail.component.ts
import { Component, OnInit } from '@angular/core';
import { Posting } from 'src/app/models/posting';
import { PostingService } from 'src/app/services/posting.service';
import { ActivatedRoute, Router } from '@angular/router';
import { User } from '../../models/User';
import { MatTableDataSource } from '@angular/material';

@Component({
  selector: 'app-postinguserdetail',
  templateUrl: './postinguserdetail.component.html',
  styleUrls: ['./postinguserdetail.component.css']
})
export class PostinguserdetailComponent implements OnInit {

posting: Posting;
user: User;

  constructor(private _postingService: PostingService, private _activatedRoute: ActivatedRoute, private _router: Router) {
    this._activatedRoute.paramMap.subscribe(p => {
      this._postingService.getPostDetail(p.get('id')).subscribe((singlePost: Posting) => {
        this.posting = singlePost;
        this.getUserInfo();
      });
    });
   }

   columnNames: ['First Name:', 'Last Name:', 'Phone Number:', 'Email:']

   dataSource: MatTableDataSource<User>

  ngOnInit() {
  }

  getUserInfo(){
    this._postingService.getPostUserDetail(this.posting.UserID).subscribe((userPostDetails: User) =>{
      this.user = userPostDetails;
    });
  }

}
<file_sep>/src/app/component/organization/organization-edit/organization-edit.component.ts
import { Component, OnInit } from '@angular/core';
import { FormGroup, FormBuilder, FormControl } from '@angular/forms';
import { OrganizationService } from 'src/app/services/organization.service';
import { ActivatedRoute, Router } from '@angular/router';
import { Organization } from 'src/app/models/organization';
import { User } from 'src/app/models/user';
import { UserService } from 'src/app/services/user.service';

@Component({
  selector: 'app-notorganizatione-edit',
  templateUrl: './organization-edit.component.html',
  styleUrls: ['./organization-edit.component.css']
})
export class OrganizationeditComponent implements OnInit {

  organization: Organization;
  user: User;

  editOrganizationForm: FormGroup;
  constructor(private _form: FormBuilder,
              private _organizationService:OrganizationService,
              private _userService: UserService,
              private _ar: ActivatedRoute,
              private _router: Router) { 

    this._ar.paramMap.subscribe(p => {
      this._organizationService.getOrganization(p.get('id')).subscribe((singleOrganization: Organization) => {
        this.organization = singleOrganization;
        this.createForm();
      });
    });
}

  ngOnInit() {
    this.getUserRole();
  }

  createForm() {
    this.editOrganizationForm = this._form.group({
      OrganizationID: new FormControl(this.organization.OrganizationID),
      OrganizationName: new FormControl(this.organization.OrganizationName),
      OrganizationLink: new FormControl(this.organization.OrganizationLink),
      OrganizationBio: new FormControl(this.organization.OrganizationBio)
    })
  }
  getUserRole(){
    this._userService.getUser().subscribe((singleUser: User) => {
      this.user = singleUser;
      console.log(this.user.Role)
    })
  }
  isAdmin(){
    if(this.user.Role=='Admin'){
      return true;
    }
  }
  onSubmit(form) {
    console.log(this.organization)
    const updateOrganization: Organization = {
      OrganizationID: form.value.OrganizationID,
      OrganizationName: form.value.OrganizationName,
      OrganizationLink: form.value.OrganizationLink,
      OrganizationBio: form.value.OrganizationBio
    };
    this._organizationService.updateOrganization(updateOrganization).subscribe(d => {
      this._router.navigate(['/organizations']);
    })
  }
}
<file_sep>/src/app/component/userdeleteadmin/userdeleteadmin.component.html
<h1>Delete</h1>
<h4>Are you sure you want to delete this account and all the posts associated with it?  This can't be undone</h4>

<hr>
<div *ngIf="isAdmin()">
    <div>
        <label for="">UserID</label>
        <span> {{user.UserID}}</span>
    </div>
    <div>
        <label for="">First Name</label>
        <span> {{user.FirstName}}</span>
    </div>
    <div>
        <label for="">Last Name</label>
        <span> {{user.LastName}}</span>
    </div>
    <div>
        <label for="">Email</label>
        <span> {{user.Email}}</span>
    </div>
    <div>
        <label for="">Phone Number</label>
        <span> {{user.PhoneNumber}}</span>
    </div>
</div>

<button mat-button color="warn" (click)="onDelete()">Delete</button>
<button mat-button color="primary" routerLink="/userlist">Back to list</button> 
<file_sep>/src/app/component/userdetails/userdetails.component.ts
import { Component, OnInit } from '@angular/core';
import{ActivatedRoute} from '@angular/router';
import { User} from '../../models/user';
import { UserService } from '../../services/user.service';
import { AuthService } from 'src/app/services/auth.service';
import { UserRole } from 'src/app/models/userrole';
@Component({
 selector: 'app-userdetails',
 templateUrl: './userdetails.component.html',
 styleUrls: ['./userdetails.component.css']
})
export class UserdetailsComponent implements OnInit {
user: User;
userRole: UserRole;
 constructor(private _activatedRoute: ActivatedRoute, private _userService: UserService, private _authService: AuthService) { }
 ngOnInit() {
   // this._activatedRoute.paramMap.subscribe(routeData=>{this._userService.getUser(routeData.get('id')).subscribe((singleUser: User)=>{
   //   this.user= singleUser;
   // });
   // });
   this._userService.getUser().subscribe((singleUser: User) => {
     this.user = singleUser;
     console.log(this.user.Role)
   })

  }
  isAdmin(){
    if(this.user.Role=='Admin'){
      return true;
    }
  }
  // isItAdmin(){
  //   this._authService.isAdmin().subscribe((userRole: UserRole) => {
  //    this.userRole = userRole;
  //  }) 
  //  if(this.userRole.Role=='Admin'){
  //    return true;
  //  }
   }
//      checkAdmin(){
//        if (this.user.Email == '<EMAIL>')
//        return true;
//  }

<file_sep>/src/app/component/personalizedlistofpostings/personalizedlistofpostings.component.ts
import { Component, OnInit } from '@angular/core';
import { PostingService } from '../../services/posting.service';
import { Posting } from '../../models/posting';
import { MatTableDataSource } from '@angular/material';
import { User } from '../../models/user';

@Component({
  selector: 'app-personalizedlistofpostings',
  templateUrl: './personalizedlistofpostings.component.html',
  styleUrls: ['./personalizedlistofpostings.component.css']
})
export class PersonalizedlistofpostingsComponent implements OnInit {
  
  columnNames = ['details', 'Title', 'State', 'Available Until', 'buttons']
  
  dataSource: MatTableDataSource<Posting>

  user: User;
  posting: Posting;
  
  constructor(private _postingService: PostingService) { }
  
  ngOnInit() {
    this._postingService.getPostList().subscribe((postings: Posting[]) => {
      this.dataSource = new MatTableDataSource<Posting>(postings);
      // if (this.posting.UserID != this.user.UserID){

      // }
    });
  }
} 
<file_sep>/src/app/component/postingedit/postingedit.component.ts
import { Component, OnInit } from '@angular/core';
import { FormGroup, FormBuilder, FormControl } from '@angular/forms';
import { PostingService } from '../../services/posting.service';
import { Posting } from '../../models/posting';
import { ActivatedRoute, Router } from '@angular/router';

@Component({
  selector: 'app-postingedit',
  templateUrl: './postingedit.component.html',
  styleUrls: ['./postingedit.component.css']
})
export class PostingeditComponent implements OnInit {

  posting: Posting;
  postingEditForm: FormGroup;

  constructor(private _form: FormBuilder, private _postingService: PostingService, private _activatedRoute: ActivatedRoute, private _router: Router) {
    this._activatedRoute.paramMap.subscribe(p => {
      this._postingService.getPostDetail(p.get('id')).subscribe((singlePost: Posting) => {
        this.posting = singlePost;
        console.table(this.posting);
        this.createForm();
      });
    });
  }

  ngOnInit() {

  }

  createForm() {
    this.postingEditForm = this._form.group({
      PostID: new FormControl(this.posting.PostID),
      Title: new FormControl(this.posting.Title),
      Details: new FormControl(this.posting.Details),
      Address: new FormControl(this.posting.Address),
      City: new FormControl(this.posting.City),
      State: new FormControl(this.posting.State),
      NameOfProvider: new FormControl(this.posting.NameOfProvider),
      Category: new FormControl(this.posting.Category),
      DateAvailable: new FormControl(this.posting.DateAvailable),
      IsCompleted: new FormControl(this.posting.IsCompleted)
    });
  }

  onSubmit(form) {
    const updatePost: Posting = {
      PostID: form.value.PostID,
      Title: form.value.Title,
      Details: form.value.Details,
      Address: form.value.Address,
      City: form.value.City,
      State: form.value.State,
      NameOfProvider: form.value.NameOfProvider,
      Category: form.value.Category,
      DateAvailable: form.value.DateAvailable,
      IsCompleted: form.value.IsCompleted
    };

    console.log(this.postingEditForm.value);
    this._postingService.updatePost(updatePost).subscribe(d => {
      this._router.navigate(['/posting/list'])
    });
  }

}
<file_sep>/src/app/services/organization.service.ts
import { Injectable } from '@angular/core';
import { HttpClient, HttpHeaders } from '@angular/common/http';
import { Organization } from '../models/organization';
import { APIURL } from '../../environments/environment.prod';

// const APIURL = 'https://localhost:44381/api';

@Injectable({
  providedIn: 'root'
})

export class OrganizationService {

  constructor(private _http: HttpClient ) { }

  getOrganization(id: string) {
    return this._http.get(`${APIURL}/Organization/${id}`, { headers: this.getHeaders() });
  }

  getOrganizations() {
    return this._http.get(`${APIURL}/Organization`, { headers: this.getHeaders() });
  }

  createOrganization(organization: Organization) {
    return this._http.post(`${APIURL}/Organization`, organization, { headers: this.getHeaders() });
  }

  private getHeaders() {
    return new HttpHeaders().set('Authorization', `Bearer ${localStorage.getItem('id_token')}`)
  }

  updateOrganization(organization: Organization) {
    return this._http.put(`${APIURL}/Organization`, organization, { headers: this.getHeaders() });
  }

  deleteOrganization(id: number) {
    return this._http.delete(`${APIURL}/Organization/${id}`, {headers: this.getHeaders() });
  }
}
<file_sep>/src/environments/environment.prod.ts
export const environment = {
  production: true
};

export let APIURL = '';

switch (window.location.hostname) {
  case 'feedaneed.herokuapp.com':
    APIURL = 'https://feedtheneed.azurewebsites.net'
    break;
  default:
    APIURL = 'http://localhost:44381';
}<file_sep>/src/app/component/useredit/useredit.component.ts
import { Component, OnInit } from '@angular/core';
import { FormGroup, FormBuilder, FormControl } from '@angular/forms';
import { UserService } from 'src/app/services/user.service';

import { User } from 'src/app/models/user';
import { Router } from '@angular/router';

@Component({
  selector: 'app-useredit',
  templateUrl: './useredit.component.html',
  styleUrls: ['./useredit.component.css']
})
export class UserEditComponent implements OnInit {

  user: User;

  editUserForm: FormGroup;
  constructor(private _form: FormBuilder,
              private _userService:UserService, private _router: Router) { 

                this._userService.getUser().subscribe((singleUser: User) => {
                  this.user = singleUser;
                  this.createForm();
      });
    }

  ngOnInit() {
  }
  createForm() {
    this.editUserForm = this._form.group({
    //     FirstName: string;
    // LastName: string;
    // Email: string;
    // PhoneNumber: string;
    UserID: new FormControl(this.user.UserID),
    FirstName: new FormControl(this.user.FirstName),
    LastName: new FormControl(this.user.LastName),
    Email: new FormControl(this.user.Email),
    PhoneNumber: new FormControl(this.user.PhoneNumber)
    });
  }

  onSubmit(form) {
    console.log(this.user)
    const updateUser: User = {
    //     FirstName: string;
    // LastName: string;
    // Email: string;
    // PhoneNumber: string;
      UserID: form.value.UserID,
      FirstName: form.value.FirstName,
      LastName: form.value.LastName,
      Email: form.value.Email,
      PhoneNumber: form.value.PhoneNumber
    };
    this._userService.updateUser(updateUser).subscribe(d => {this._router.navigate(['/userdetails']);
    })
  }
}<file_sep>/src/app/services/posting.service.ts
import { Injectable } from '@angular/core';
import{Posting} from '../models/posting';
import { HttpClient, HttpHeaders } from '@angular/common/http';
import { APIURL } from '../../environments/environment.prod';

// const APIURL = 'https://localhost:44381/api';

@Injectable({
  providedIn: 'root'
})
export class PostingService {

  constructor(private _http: HttpClient) { }

  createPost(posting: Posting){
    return this._http.post(`${APIURL}/Posting`, posting, { headers: this.getHeaders() });
  }
  getPostList(){
    return this._http.get(`${APIURL}/Posting`, { headers: this.getHeaders() });
  }
  getPostDetail(id: string){
    return this._http.get(`${APIURL}/Posting/${id}`, { headers: this.getHeaders() });
  }
  getPostUserDetail(id: string){
    return this._http.get(`${APIURL}/Account/PostingDetailUser?id=${id}`, {headers: this.getHeaders()})
  }
  updatePost(posting: Posting){
    return this._http.put(`${APIURL}/Posting`, posting, { headers: this.getHeaders() });
  }
  deletePost(id: number){
    return this._http.delete(`${APIURL}/Posting/${id}`, { headers: this.getHeaders() });
  }
  getHeaders(){
    return new HttpHeaders().set('Authorization', `Bearer ${localStorage.getItem('id_token')}`);
  }
}
<file_sep>/src/app/component/userlist/userlist.component.ts
import { Component, OnInit } from '@angular/core';
import { MatTableDataSource } from '@angular/material';
import { User } from 'src/app/models/user';
import { UserService } from 'src/app/services/user.service';

@Component({
  selector: 'app-userlist',
  templateUrl: './userlist.component.html',
  styleUrls: ['./userlist.component.css']
})
export class UserlistComponent implements OnInit {

  columnNames = ['First Name', 'Last Name', 'Email', 'Buttons']

  dataSource: MatTableDataSource<User>

  user: User;

  constructor(private _userService: UserService) { 
    this.getUserRole(); }

  ngOnInit() {
    this._userService.getUsers().subscribe((users: User[]) => {
      this.dataSource = new MatTableDataSource<User>(users);
    });
  }
  getUserRole(){
    this._userService.getUser().subscribe((singleUser: User) => {
      this.user = singleUser;
      console.log(this.user.Role)
    })
  }
  isAdmin(){
    if(this.user.Role=='Admin'){
      return true;
    }
  }

}
<file_sep>/src/app/models/organization.ts
export interface Organization {
    OrganizationID?: number;
    OrganizationName?: string;
    OrganizationLink: string;
    OrganizationBio: string;
}<file_sep>/src/app/component/postingcreate/postingcreate.component.ts
import { Component, OnInit } from '@angular/core';
import { FormGroup, FormBuilder, FormControl } from '@angular/forms';
import { PostingService } from 'src/app/services/posting.service';
import { Router } from '@angular/router';
import { Organization } from 'src/app/models/organization';
import { MatTableDataSource } from '@angular/material';
import { OrganizationService } from 'src/app/services/organization.service';

export interface Category {
  value: string;
  viewValue: string;
}

@Component({
  selector: 'app-postingcreate',
  templateUrl: './postingcreate.component.html',
  styleUrls: ['./postingcreate.component.css']
})
export class PostingcreateComponent implements OnInit {
  foods: Category[] = [
    {value: 'Food', viewValue: 'Food'},
    {value: 'Items', viewValue: 'Items'},
    {value: 'Services', viewValue: 'Services'}
  ];
  
  postingForm: FormGroup;
  organizations: any;
  dataSource: MatTableDataSource<Organization>;
  
  constructor(private _form: FormBuilder, private _postingService: PostingService, private _organizationService: OrganizationService, private _router: Router) { 
    this.createForm();
  }

  ngOnInit() {
    this._organizationService.getOrganizations().subscribe((organizations: Organization[]) => {
      this.dataSource = new MatTableDataSource<Organization>(organizations);
      console.log(organizations)
      this.organizations = organizations;
      })
  }

createForm(){
  this.postingForm = this._form.group({	
    title: new FormControl,
    details: new FormControl,
    address: new FormControl,	
    city: new FormControl,
    state: new FormControl,
    nameOfProvider:	new FormControl,
    category: new FormControl,
    dateAvailable: new FormControl
  });
}

onSubmit(){
  console.log(this.postingForm.value);
  this._postingService.createPost(this.postingForm.value).subscribe(data => {
    this._router.navigate(['/posting/list']);
  });
}

}
<file_sep>/src/app/component/organization/organization-details/organization-details.component.ts
import { Component, OnInit } from '@angular/core';
import { ActivatedRoute } from '@angular/router';
import { OrganizationService } from '../../../services/organization.service';
import { Organization } from '../../../models/organization';

@Component({
  selector: 'app-organization-details',
  templateUrl: './organization-details.component.html',
  styleUrls: ['./organization-details.component.css']
})
export class OrganizationDetailsComponent implements OnInit {

  organization: Organization;

  constructor(private _activeRoute: ActivatedRoute, private _organizationService: OrganizationService) { }

  ngOnInit() {
    this._activeRoute.paramMap.subscribe(routeData => {
      this._organizationService.getOrganization(routeData.get('id')).subscribe((singleOrganization: Organization) => {
        this.organization = singleOrganization;
      });
      console.log(routeData);
    });
  }

}
<file_sep>/src/app/component/userdetailsadmin/userdetailsadmin.component.ts
import { Component, OnInit } from '@angular/core';
import { User } from 'src/app/models/user';
import { Posting } from 'src/app/models/posting';
import { UserService } from 'src/app/services/user.service';
import { Router, ActivatedRoute } from '@angular/router';
import { PostingService } from 'src/app/services/posting.service';

@Component({
  selector: 'app-userdetailsadmin',
  templateUrl: './userdetailsadmin.component.html',
  styleUrls: ['./userdetailsadmin.component.css']
})
export class UserdetailsadminComponent implements OnInit {


  user: User;
  adminUser: User;
  posting: Posting
  constructor(private _userService: UserService, private _postingService: PostingService, private _router: Router, private _activatedRoute: ActivatedRoute) {
    this._activatedRoute.paramMap.subscribe(p=>{
      this._postingService.getPostUserDetail(p.get('id')).subscribe((singleUser: User) => {
      this.user = singleUser;
      console.log(this.user)
      this.getUserRole();
    })
                
  });
   }

  ngOnInit() {
  }
  getUserRole(){
    this._userService.getUser().subscribe((userRole: User) => {
      this.adminUser = userRole;
      console.log(this.adminUser.Role)
    })
  }
  isAdmin(){
    if(this.adminUser.Role=='Admin'){
      return true;
    }
  }
}
<file_sep>/src/app/component/organization/organization-create/organization-create.component.ts
import { Component, OnInit } from '@angular/core';
import { FormGroup, FormBuilder, FormControl } from '@angular/forms';
import { OrganizationService } from 'src/app/services/organization.service';
import { Router } from '@angular/router';
import { User } from 'src/app/models/user';
import { UserService } from 'src/app/services/user.service';

@Component({
  selector: 'app-organization-create',
  templateUrl: './organization-create.component.html',
  styleUrls: ['./organization-create.component.css']
})
export class OrganizationcreateComponent implements OnInit {

  organizationForm: FormGroup;
  user: User;

  constructor(private _organizationService: OrganizationService, private _userService: UserService, private _form: FormBuilder, private _router: Router) {
    this.createForm();
    this.getUserRole();
   }

  ngOnInit() {
  }

  createForm() {
    this.organizationForm = this._form.group({
      OrganizationName: new FormControl,
      OrganizationLink: new FormControl,
      OrganizationBio: new FormControl
    })
  }
getUserRole(){
    this._userService.getUser().subscribe((singleUser: User) => {
      this.user = singleUser;
      console.log(this.user.Role)
    })
  }
  isAdmin(){
    if(this.user.Role=='Admin'){
      return true;
    }
  }
  onSubmit() {
    this._organizationService.createOrganization(this.organizationForm.value).subscribe(data => {
      this._router.navigate(["/organizations"]);
    });
  }
  
}
<file_sep>/src/app/app-routing.module.ts
import{RouterModule, Routes} from '@angular/router'
import { AppComponent } from './app.component'
import { ListofpostingsComponent } from './component/listofpostings/listofpostings.component'
import { LoginComponent } from './component/login/login.component'
import { OrganizationcreateComponent } from './component/organization/organization-create/organization-create.component'
import { OrganizationeditComponent } from './component/organization/organization-edit/organization-edit.component'
import { PasswordchangeComponent } from './component/passwordchange/passwordchange.component'
import { PostingcreateComponent } from './component/postingcreate/postingcreate.component'
import { PostingdetailComponent } from './component/postingdetail/postingdetail.component'
import { PostingeditComponent } from './component/postingedit/postingedit.component'
import { PostingdeleteComponent } from './component/postingdelete/postingdelete.component'
import { RegisterComponent } from './component/register/register.component'
import { UserdetailsComponent } from './component/userdetails/userdetails.component'
import { UserEditComponent } from './component/useredit/useredit.component'
import { UserDeleteComponent } from './component/userdelete/userdelete.component'
import { ContactpageComponent } from './component/contactpage/contactpage.component'
import { NgModule } from '@angular/core';
import { OrganizationindexComponent } from './component/organization/organization-index/organization-index.component';
import { OrganizationdeleteComponent } from './component/organization/organization-delete/organization-delete.component';
import { OrganizationDetailsComponent } from './component/organization/organization-details/organization-details.component';
import { UserlistComponent } from './component/userlist/userlist.component';
import { PostinguserdetailComponent } from './component/postinguserdetail/postinguserdetail.component';
import { UserdeleteadminComponent } from './component/userdeleteadmin/userdeleteadmin.component';
import { HomepageComponent } from './component/homepage/homepage.component'
import { UserdetailsadminComponent } from './component/userdetailsadmin/userdetailsadmin.component';

const routes: Routes = [
  
  { path: 'register', component: RegisterComponent },
  { path: 'login', component: LoginComponent },
  { path: '', component: HomepageComponent },
  

  { path: 'posting', children: [
    { path: 'list', component: ListofpostingsComponent },
    { path: 'create', component: PostingcreateComponent },
    { path: 'detail/:id', component: PostingdetailComponent },
    { path: 'edit/:id', component: PostingeditComponent },
    { path: 'delete/:id', component: PostingdeleteComponent },
    { path: 'userdetail/:id', component: PostinguserdetailComponent }
  ]
},
  { 
    path: 'organizations', children: [
      { path: '', component: OrganizationindexComponent },
      { path: 'create', component: OrganizationcreateComponent },
      { path: 'detail/:id', component: OrganizationDetailsComponent },
      { path: 'edit/:id', component: OrganizationeditComponent },
      { path: 'delete/:id', component: OrganizationdeleteComponent }
    ]
  },
  { path: 'passwordchange', component: PasswordchangeComponent },
  { path: 'postingcreate', component: PostingcreateComponent },
  { path: 'postingdetail', component: PostingdetailComponent },
  { path: 'postingedit', component: PostingeditComponent },

  { path: 'userdetails', component: UserdetailsComponent },
  { path: 'useredit', component: UserEditComponent },
  { path: 'userdelete', component: UserDeleteComponent },
  { path: 'userdeleteadmin/:id', component: UserdeleteadminComponent },
  { path: 'userdetailsadmin/:id', component: UserdetailsadminComponent},
  { path: 'contactpage', component: ContactpageComponent },
  { path: 'userlist', component: UserlistComponent }
  // { path: '**', component: AppComponent }
];

@NgModule({
  // other imports here
  imports: [RouterModule.forRoot(routes)], // {enableTracing: true}
  exports: [RouterModule]
})
export class AppRoutingModule { }
<file_sep>/src/app/component/userdeleteadmin/userdeleteadmin.component.ts
import { Component, OnInit } from '@angular/core';
import { User } from 'src/app/models/user';
import { FormGroup, FormBuilder, FormControl } from '@angular/forms';
import { UserService } from 'src/app/services/user.service';
import { Router, ActivatedRoute } from '@angular/router';
import { PostingService } from 'src/app/services/posting.service';
import { Posting } from 'src/app/models/posting';

@Component({
  selector: 'app-userdeleteadmin',
  templateUrl: './userdeleteadmin.component.html',
  styleUrls: ['./userdeleteadmin.component.css']
})
export class UserdeleteadminComponent implements OnInit {

  user: User;
  adminUser: User;
  posting: Posting;
  
  constructor(private _userService:UserService, private _router: Router, private _postingService: PostingService, private _activatedRoute: ActivatedRoute) { 
                this._activatedRoute.paramMap.subscribe(p=>{
                  this._postingService.getPostUserDetail(p.get('id')).subscribe((singleUser: User) => {
                  this.user = singleUser;
                  console.log(this.user)
                  // this.createForm();
                  // console.log(this.user)
                  this.getUserRole();
                  console.log(this.user)
                })
                
      });
    }


  // createForm() {
  //   this.deleteUserForm = this._form.group({
  //   //     FirstName: string;
  //   // LastName: string;
  //   // Email: string;
  //   // PhoneNumber: string;
  //   UserID: new FormControl(this.user.UserID),
  //   FirstName: new FormControl(this.user.FirstName),
  //   LastName: new FormControl(this.user.LastName),
  //   Email: new FormControl(this.user.Email),
  //   PhoneNumber: new FormControl(this.user.PhoneNumber)
  //   });
  // }

 
ngOnInit(){
}
getUserRole(){
  this._userService.getUser().subscribe((userRole: User) => {
    this.adminUser = userRole;
    console.log(this.adminUser.Role)
  })
}
isAdmin(){
  if(this.adminUser.Role=='Admin'){
    return true;
  }
}

onDelete(){
console.log(localStorage.getItem('id_token'));
 this._userService.deleteUserAdmin(this.user.UserID).subscribe(()=>{
   this._router.navigate(['/userlist']);
 });
}


}
<file_sep>/src/app/app.module.ts
import { AppRoutingModule } from './app-routing.module';
import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { FormsModule, ReactiveFormsModule } from '@angular/forms';
import { HeaderComponent } from './component/header/header.component';
import { MatToolbarModule, MatButtonModule, MatFormFieldModule, MatInputModule, MatTableModule, MatCardModule, MatGridListModule, MatSelectModule } from '@angular/material';
import { RouterModule} from '@angular/router';
import { HttpClientModule } from '@angular/common/http';
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
import { AppComponent } from './app.component';
import { NavbarComponent } from './component/navbar/navbar.component';
import { FooterComponent } from './component/footer/footer.component';
import { ListofpostingsComponent } from './component/listofpostings/listofpostings.component';
import { PostingdetailComponent } from './component/postingdetail/postingdetail.component';
import { PostingcreateComponent } from './component/postingcreate/postingcreate.component';
import { PostingeditComponent } from './component/postingedit/postingedit.component';
import { OrganizationindexComponent } from './component/organization/organization-index/organization-index.component';
import { OrganizationcreateComponent } from './component/organization/organization-create/organization-create.component';
import { OrganizationeditComponent } from './component/organization/organization-edit/organization-edit.component';
import { OrganizationDetailsComponent } from './component/organization/organization-details/organization-details.component';
import { OrganizationdeleteComponent } from './component/organization/organization-delete/organization-delete.component';
import { LoginComponent } from './component/login/login.component';
import { RegisterComponent } from './component/register/register.component';
import { UserEditComponent } from './component/useredit/useredit.component';
import { UserdetailsComponent } from './component/userdetails/userdetails.component';
import { PasswordchangeComponent } from './component/passwordchange/passwordchange.component';
import { ContactpageComponent } from './component/contactpage/contactpage.component';
import { OrganizationService } from './services/organization.service';
import { PostingService } from './services/posting.service';
import { UserService } from './services/user.service';
import { AuthService } from './services/auth.service';
import { PostingdeleteComponent } from './component/postingdelete/postingdelete.component';
import { UserDeleteComponent } from './component/userdelete/userdelete.component';
import { PersonalizedlistofpostingsComponent } from './component/personalizedlistofpostings/personalizedlistofpostings.component';
import { PostinguserdetailComponent } from './component/postinguserdetail/postinguserdetail.component';
import { UserlistComponent } from './component/userlist/userlist.component';
import { UserdeleteadminComponent } from './component/userdeleteadmin/userdeleteadmin.component';
import { HomepageComponent } from './component/homepage/homepage.component';
import { UserdetailsadminComponent } from './component/userdetailsadmin/userdetailsadmin.component';




@NgModule({
  declarations: [
    AppComponent,
    NavbarComponent,
    HeaderComponent,
    FooterComponent,
    ListofpostingsComponent,
    PostingdetailComponent,
    PostingcreateComponent,
    PostingeditComponent,
    OrganizationindexComponent,
    OrganizationcreateComponent,
    OrganizationeditComponent,
    LoginComponent,
    RegisterComponent,
    UserEditComponent,
    UserdetailsComponent,
    PasswordchangeComponent,
    ContactpageComponent,
    HeaderComponent,
    PostingdeleteComponent,
    UserDeleteComponent,
    OrganizationDetailsComponent,
    OrganizationdeleteComponent,
    PersonalizedlistofpostingsComponent,
    PostinguserdetailComponent,
    UserlistComponent,
    UserdeleteadminComponent,
    HomepageComponent,
    UserdetailsadminComponent
 
  ],
  imports: [
    BrowserModule,
    BrowserAnimationsModule,
    HttpClientModule,
    MatToolbarModule,
    MatButtonModule,
    FormsModule,
    ReactiveFormsModule,
    MatFormFieldModule,
    MatInputModule,
    MatTableModule,
    MatCardModule,
    MatGridListModule,
    MatFormFieldModule,
    MatSelectModule,
    AppRoutingModule,
  ],

  providers: [
    AuthService,
    OrganizationService,
    PostingService,
    UserService
  ],

  bootstrap: [AppComponent]
})
export class AppModule { }<file_sep>/src/app/component/organization/organization-index/organization-index.component.ts
import { Component, OnInit } from '@angular/core';
import { MatTableDataSource } from '@angular/material';
import { Organization } from '../../../models/organization';
import { OrganizationService } from '../../../services/organization.service';
import { User } from 'src/app/models/user';
import { UserService } from 'src/app/services/user.service';


@Component({
  selector: 'app-organization-index',
  templateUrl: './organization-index.component.html',
  styleUrls: ['./organization-index.component.css']
})
export class OrganizationindexComponent implements OnInit {

  columnNames = ['OrganizationName', 'OrganizationBio', 'OrganizationLink', 'buttons' ];
  dataSource: MatTableDataSource<Organization>;

  user: User;

  constructor(private _organizationService: OrganizationService, private _userService: UserService) { }

  ngOnInit() {
    this._organizationService.getOrganizations().subscribe((organizaions: Organization[]) => {
      this.dataSource = new MatTableDataSource<Organization>(organizaions);
      console.log(organizaions);
      this.getUserRole();
    })
  }
  getUserRole(){
    this._userService.getUser().subscribe((singleUser: User) => {
      this.user = singleUser;
      console.log(this.user.Role)
    })
  }
  isAdmin(){
    if(this.user.Role=='Admin'){
      return true;
    }
  }

}
<file_sep>/src/app/component/postingdelete/postingdelete.component.ts
import { Component, OnInit } from '@angular/core';
import { PostingService } from 'src/app/services/posting.service';
import { ActivatedRoute, Router } from '@angular/router';
import { Posting } from 'src/app/models/posting';

@Component({
  selector: 'app-postingdelete',
  templateUrl: './postingdelete.component.html',
  styleUrls: ['./postingdelete.component.css']
})
export class PostingdeleteComponent implements OnInit {

  posting: Posting;

  constructor(private _postingService: PostingService, private _activatedRoute: ActivatedRoute, private _router: Router) {
    this._activatedRoute.paramMap.subscribe(p => {
      this._postingService.getPostDetail(p.get('id')).subscribe((singlePost: Posting) => {
        this.posting = singlePost;
      });
    });
   }

  ngOnInit() {
  }

  onDelete(){
    this._postingService.deletePost(this.posting.PostID).subscribe(() => {
      this._router.navigate(['/posting/list'])
    });
  }
}
<file_sep>/src/app/models/posting.ts
export interface Posting {
    PostID?: number;	
    UserID?: string;	
    Title:	string;	
    Details: string;	
    Address: string;	
    City: string;
    State: string;	
    NameOfProvider:	string;	
    Category: string;	
    DatePosted?: string;	
    DateAvailable: Date;	
    IsCompleted?: boolean;
}<file_sep>/src/app/services/user.service.ts
import { Injectable } from '@angular/core';
import{HttpClient, HttpHeaders} from '@angular/common/http';
import{User} from '../models/user';
import { APIURL } from '../../environments/environment.prod';

// const APIURL = 'https://localhost:44381/';

@Injectable()
export class UserService {
  constructor(private _http: HttpClient) { }
  getUsers(){
    return this._http.get(`${APIURL}api/Account/UserList`, {headers: this.getHeaders()});
  }
  private getHeaders(){
    return new HttpHeaders().set('Authorization', `Bearer ${localStorage.getItem('id_token')}`);
  }
  getUser(){
    return this._http.get(`${APIURL}api/Account/DetailUser`, {headers: this.getHeaders()});
  }
  updateUser(user: User){
    return this._http.put(`${APIURL}api/Account/changeuserinfo`, user, {headers: this.getHeaders()});
  }
  deleteUser(user: User){
    return this._http.put(`${APIURL}api/Account/RemoveUser`, user, {headers: this.getHeaders()});
  }
  deleteUserAdmin(id: string){
    return this._http.put(`${APIURL}api/Account/RemoveUserAdmin?id=${id}`, null, {headers: this.getHeaders()});
  }
}
<file_sep>/src/app/component/register/register.component.ts
import { Component, OnInit } from '@angular/core';
import { FormBuilder, FormGroup, FormControl } from '@angular/forms';
import { AuthService } from '../../services/auth.service';
import { Router } from '@angular/router';
// import { Organization } from '../../models/organization'
// import { MatTableDataSource } from '@angular/material';
// import { OrganizationService } from '../../services/organization.service';

@Component({
 selector: 'app-register',
 templateUrl: './register.component.html',
 styleUrls: ['./register.component.css']
})
// export class OrganizationindexComponent implements OnInit {

//   columnNames = ['OrganizationName', 'OrganizationBio', 'OrganizationLink', 'buttons' ];
//   dataSource: MatTableDataSource<Organization>;

//   constructor(private _organizationService: OrganizationService) { }

//   ngOnInit() {
//     this._organizationService.getOrganizations().subscribe((organizaions: Organization[]) => {
//       this.dataSource = new MatTableDataSource<Organization>(organizaions);
//       console.log(organizaions)
//     })
//   }

// }
export class RegisterComponent implements OnInit {
 _registerForm: FormGroup;
//  organizations: any;



 constructor(private _form: FormBuilder, private _authService: AuthService, private _router: Router) {
   this.createForm();
  }
 ngOnInit() {
  // this._organizationService.getOrganizations().subscribe((organizations: Organization[]) => {
  // this.dataSource = new MatTableDataSource<Organization>(organizations);
  // console.log(organizations)
  // this.organizations = organizations;
  // })
 }
 createForm(){
   this._registerForm = this._form.group({
     email: new FormControl,
     password: new FormControl,
     confirmPassword: new FormControl,
     firstName: new FormControl,
     lastName: new FormControl,
    //  OrganizationName: new FormControl,
     phoneNumber: new FormControl
   });
   
   
 }
 onSubmit(){
   console.log(this._registerForm.value);
   
   this._authService
   .register(this._registerForm.value)
   .subscribe(()=>this._router.navigate(['/login']));
 }
}<file_sep>/src/app/component/listofpostings/listofpostings.component.ts
import { Component, OnInit } from '@angular/core';
import { PostingService } from 'src/app/services/posting.service';
import { Posting } from 'src/app/models/posting';
import { MatTableDataSource } from '@angular/material';
import { UserService } from 'src/app/services/user.service';
import { User } from 'src/app/models/user';

@Component({
  selector: 'app-listofpostings',
  templateUrl: './listofpostings.component.html',
  styleUrls: ['./listofpostings.component.css']
})
export class ListofpostingsComponent implements OnInit {
  
  columnNames = ['Title', 'State', 'Available Until', 'buttons']
  
  dataSource: MatTableDataSource<Posting>
  
  currentUser: string;
  user: User;
  posting: Posting;

  constructor(private _postingService: PostingService, private _userService: UserService) { this.getUserID()}
  
  ngOnInit() {
    this._postingService.getPostList().subscribe((postings: Posting[]) => {
      this.dataSource = new MatTableDataSource<Posting>(postings);
      console.log(postings)
    });
  }
  getUserID(){
    this._userService.getUser().subscribe((singleUser: User) => {
      this.user = singleUser;
      console.log(this.user.UserID);
      this.currentUser = this.user.UserID;
      //console.log(this.posting.UserID)
    })
  }
  // isUser(){
  //   if (this.posting.UserID == this.user.UserID){
  //     return true;
  //   }
  // }


}
<file_sep>/src/app/component/userdelete/userdelete.component.ts
import { Component, OnInit } from '@angular/core';
import { UserService } from 'src/app/services/user.service';
import { ActivatedRoute, Router } from '@angular/router';
import { User } from '../../models/user';
import { FormBuilder, FormGroup, FormControl } from '@angular/forms';

@Component({
  selector: 'app-userdelete',
  templateUrl: './userdelete.component.html',
  styleUrls: ['./userdelete.component.css']
})
export class UserDeleteComponent implements OnInit {

  user: User;
  deleteUserForm: FormGroup;
  
  constructor(private _form: FormBuilder,
              private _userService:UserService, private _router: Router) { 

                this._userService.getUser().subscribe((singleUser: User) => {
                  this.user = singleUser;
                  this.createForm();
      });
    }


  createForm() {
    this.deleteUserForm = this._form.group({
    //     FirstName: string;
    // LastName: string;
    // Email: string;
    // PhoneNumber: string;
    UserID: new FormControl(this.user.UserID),
    FirstName: new FormControl(this.user.FirstName),
    LastName: new FormControl(this.user.LastName),
    Email: new FormControl(this.user.Email),
    PhoneNumber: new FormControl(this.user.PhoneNumber)
    });
  }

 onDelete(){

 this._userService.deleteUser(this.user).subscribe(()=>{
   this._router.navigate(['/']);
 });
}
ngOnInit(){
}
}<file_sep>/src/app/models/userrole.ts
export interface UserRole{
    Email: string;
    Role: string;
    HasRegistered: string;
    LoginProvider: null;
}