Public/New-NgCrudService.ps1

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
<#
.SYNOPSIS
    Given a C# Angular project that is already set up, add an angular service for basic CRUD and filter operations against a backend REST API representing a table.
.DESCRIPTION
    This will create the service TS file, build in the asynchronous calls to the REST API calls, and add all the required import and provider links to the main Angular app.module.ts file. It is expected BoxTurtlePS commands were already run to create the solution and backend and main Angular files, database connection, and Angular object model. If no switches are provided al verbs are created.
.PARAMETER tableName
    Name of table to create service for. Should correspond to a database table for which a C# Controller REST API was already created.
.PARAMETER create
    Switch to support create method on service
.PARAMETER read
    Switch to support get method on service
.PARAMETER update
    Switch to support update method on service
.PARAMETER delete
    Switch to support delete method on service
.PARAMETER list
    Switch to support list method on service to return all filter
.PARAMETER create
    Switch to support filter method on service to support at-grid syntax for server-side filtering
    
.EXAMPLE
    New-NgCrudService Employee
    # creates service\employee.service.ts ready to be injected into a
    # component constructor to achieve data access
    
    New-NgCrudService Department -read -list
    # Same but only supports list and read verbs
.NOTES
    Author: Brian Woelfel
    Date: 2017/09/13
#>


Function New-NgCrudService() {
    param([Parameter(Mandatory=$true)][string]$tableName, [switch]$create, [switch]$read, [switch]$update, [switch]$delete, [switch]$list, [switch]$filter)
    [SolnInfo]$solnInfo = [SolnInfo]::Load()
    New-NgCrudServicePrivate $solnInfo.webCsprojInfo $tableName $create $read $update $delete $list $filter
}