Private/Cs/WebProj/New-CsController.ps1
<############################################################################ # Make a new C# CRUD controller from entity framework for an entity ############################################################################> Function New-CsControllerPrivate([SolnInfo] $solnInfo, [WebCsprojInfo] $webCsprojInfo, [DbInfo] $dbInfo, [string] $entity, [bool]$create, [bool]$read, [bool]$update, [bool]$delete, [bool]$list, [bool]$filter) { # If all switches unspecified (false), then they are all true # (Syntax explained in http://peterreavy.com/tech/2014/04/30/Map,-reduce-and-filter-in-PowerShell.html) if( -not ( ($create, $read, $update, $delete, $list, $filter) | % { [bool]$tempBool = $false } { $tempBool = $tempBool -or $_ } { $tempBool }) ) { $create = $true $read = $true $update = $true $delete = $true $list = $true $filter = $true } if($projName -eq "") { $projName = "$($solnInfo.nickName)Web" } $proj = $solnInfo.GetProjInfoByName($projName) Write-Host "### Make $($webCsprojInfo.csprojName) controller for $entity" $entityCapital = (ConvertTo-CapitalCamelCase $entity) New-CsControllerCsToString $solnInfo.nickName $webCsprojInfo.csprojName $entity $create $read $update $delete $list $filter | Out-FileUtf8NoBom "$($webCsprojInfo.csprojDir)\Controllers\$($entityCapital)Controller.cs" } |