$GENERATED_CS_COMMENT using System; using System.Collections.Generic; using System.ComponentModel.DataAnnotations; using System.Threading.Tasks; using System.Runtime.Serialization; using Microsoft.AspNetCore.Mvc; using Swashbuckle.AspNetCore.Annotations; using Microsoft.AspNetCore.Authorization; using Swashbuckle.AspNetCore.SwaggerGen; using Newtonsoft.Json; using ${env['packagename']}.Attributes; using ${env['packagename']}.Models; using ${env['packagename']}.Controllers; using ${env['packagename']}.Services; namespace ${env['packagename']}.Implementations { #for $operation in $operations #if $operation['paramInputTypes'] [DataContract] public class ${operation['func']}InputType { #for $inputType in $operation['paramInputTypes'] #if $inputType['required'] [Required] #end if [DataMember(Name="$inputType['name']")] public $inputType['type'] $inputType['csName'] { get; set; } #end for } #end if #end for public class RegularApiImplementation : RegularApiController { private readonly IDbService _dbService; public RegularApiImplementation(IDbService dbService) { _dbService = dbService; } #for $operation in $operations #if $operation['method'] == 'get' public override async Task ${operation['func']}(#slurp #if $operation['bodyInputType'] [FromBody]$operation['bodyInputType']['csName'] $operation['bodyInputType']['apiName'] #slurp #end if #if $operation['paramInputTypes'] #set sep = '' #for $inputType in $operation['paramInputTypes'] $sep#slurp #if $inputType['in'] == 'query' [FromQuery #slurp #elif $inputType['in'] == 'path' [FromRoute #slurp #else #raise Exception('Invalid in for paramInput') #end if (Name = "$inputType['name']")]#slurp #if $inputType['required'] [Required()]#slurp #end if $inputType['type'] $inputType['name']#slurp #set sep = ', ' #end for #end if ) { #if $operation['paramInputTypes'] ${operation['func']}InputType paramInput = new ${operation['func']}InputType(); #for $inputType in $operation['paramInputTypes'] paramInput.$inputType['csName'] = $inputType['name']; #end for #end if try { List<$operation['resultType']['csName']> res = await _dbService.ReadBySelect<#slurp #if $operation['bodyInputType'] $operation['bodyInputType']['csName'], #slurp #elif $operation['paramInputTypes'] ${operation['func']}InputType, #slurp #else Object, #slurp #end if $operation['resultType']['csName']>("#slurp #if not $operation['statement'] SELECT #slurp #set $sep = "" #for $property in $types[$operation['resultType']['apiName']]['properties'] $sep$property['sqlName'] #slurp #set $sep = "," #end for FROM $types[$operation['resultType']['apiName']]['sqlName']#slurp #else $operation['statement']#slurp #end if ", #slurp #if $operation['isList'] true, #slurp #else false, #slurp #end if #if $operation['bodyInputType'] $operation['bodyInputType']['apiName']#slurp #elif $operation['paramInputTypes'] paramInput#slurp #else null#slurp #end if ); return new ObjectResult(res#slurp #if $operation['isList'] [0]#slurp #end if ); } catch (NotDataFoundException) { return StatusCode(404, "No $operation['resultType']['apiName'] element found"); } } #elif $operation['method'] == 'post' // INSERT #elif $operation['method'] == 'put' // UPDATE #elif $operation['method'] == 'delete' // DELETE #else #raise Exception('invalid method') #end if #end for } }