├── .gitattributes ├── .gitignore ├── LowCodeAPI.sln ├── LowCodeAPI ├── Client │ ├── App.razor │ ├── LowCodeAPI.Client.csproj │ ├── Pages │ │ ├── Counter.razor │ │ ├── FetchData.razor │ │ └── Index.razor │ ├── Program.cs │ ├── Properties │ │ └── launchSettings.json │ ├── Services │ │ ├── APIRepository.cs │ │ └── AuthorsManager.cs │ ├── Shared │ │ ├── MainLayout.razor │ │ ├── MainLayout.razor.css │ │ ├── NavMenu.razor │ │ ├── NavMenu.razor.css │ │ └── SurveyPrompt.razor │ ├── _Imports.razor │ └── wwwroot │ │ ├── css │ │ ├── app.css │ │ ├── bootstrap │ │ │ ├── bootstrap.min.css │ │ │ └── bootstrap.min.css.map │ │ └── open-iconic │ │ │ ├── FONT-LICENSE │ │ │ ├── ICON-LICENSE │ │ │ ├── README.md │ │ │ └── font │ │ │ ├── css │ │ │ └── open-iconic-bootstrap.min.css │ │ │ └── fonts │ │ │ ├── open-iconic.eot │ │ │ ├── open-iconic.otf │ │ │ ├── open-iconic.svg │ │ │ ├── open-iconic.ttf │ │ │ └── open-iconic.woff │ │ ├── favicon.ico │ │ └── index.html ├── Server │ ├── Controllers │ │ ├── AuthorsController.cs │ │ └── WeatherForecastController.cs │ ├── Data │ │ ├── EFControllerBase.cs │ │ ├── EFRepository.cs │ │ └── pubsContext.cs │ ├── LowCodeAPI.Server.csproj │ ├── Pages │ │ ├── Error.cshtml │ │ └── Error.cshtml.cs │ ├── Program.cs │ ├── Properties │ │ └── launchSettings.json │ ├── Startup.cs │ ├── appsettings.Development.json │ └── appsettings.json └── Shared │ ├── LowCodeAPI.Shared.csproj │ ├── Models │ ├── APIEntityResponse.cs │ ├── APIListOfEntityResponse.cs │ ├── Author.cs │ ├── Discount.cs │ ├── Employee.cs │ ├── IRepository.cs │ ├── Job.cs │ ├── PubInfo.cs │ ├── Publisher.cs │ ├── Roysched.cs │ ├── Sale.cs │ ├── Store.cs │ ├── Title.cs │ ├── Titleauthor.cs │ └── Titleview.cs │ └── WeatherForecast.cs ├── README.md ├── md-images └── image-20210707140142879.png ├── pubs.sql └── pubsContext.cs /.gitattributes: -------------------------------------------------------------------------------- 1 | ############################################################################### 2 | # Set default behavior to automatically normalize line endings. 3 | ############################################################################### 4 | * text=auto 5 | 6 | ############################################################################### 7 | # Set default behavior for command prompt diff. 8 | # 9 | # This is need for earlier builds of msysgit that does not have it on by 10 | # default for csharp files. 11 | # Note: This is only used by command line 12 | ############################################################################### 13 | #*.cs diff=csharp 14 | 15 | ############################################################################### 16 | # Set the merge driver for project and solution files 17 | # 18 | # Merging from the command prompt will add diff markers to the files if there 19 | # are conflicts (Merging from VS is not affected by the settings below, in VS 20 | # the diff markers are never inserted). Diff markers may cause the following 21 | # file extensions to fail to load in VS. An alternative would be to treat 22 | # these files as binary and thus will always conflict and require user 23 | # intervention with every merge. To do so, just uncomment the entries below 24 | ############################################################################### 25 | #*.sln merge=binary 26 | #*.csproj merge=binary 27 | #*.vbproj merge=binary 28 | #*.vcxproj merge=binary 29 | #*.vcproj merge=binary 30 | #*.dbproj merge=binary 31 | #*.fsproj merge=binary 32 | #*.lsproj merge=binary 33 | #*.wixproj merge=binary 34 | #*.modelproj merge=binary 35 | #*.sqlproj merge=binary 36 | #*.wwaproj merge=binary 37 | 38 | ############################################################################### 39 | # behavior for image files 40 | # 41 | # image files are treated as binary by default. 42 | ############################################################################### 43 | #*.jpg binary 44 | #*.png binary 45 | #*.gif binary 46 | 47 | ############################################################################### 48 | # diff behavior for common document formats 49 | # 50 | # Convert binary document formats to text before diffing them. This feature 51 | # is only available from the command line. Turn it on by uncommenting the 52 | # entries below. 53 | ############################################################################### 54 | #*.doc diff=astextplain 55 | #*.DOC diff=astextplain 56 | #*.docx diff=astextplain 57 | #*.DOCX diff=astextplain 58 | #*.dot diff=astextplain 59 | #*.DOT diff=astextplain 60 | #*.pdf diff=astextplain 61 | #*.PDF diff=astextplain 62 | #*.rtf diff=astextplain 63 | #*.RTF diff=astextplain 64 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | ## Ignore Visual Studio temporary files, build results, and 2 | ## files generated by popular Visual Studio add-ons. 3 | ## 4 | ## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore 5 | 6 | # User-specific files 7 | *.rsuser 8 | *.suo 9 | *.user 10 | *.userosscache 11 | *.sln.docstates 12 | 13 | # User-specific files (MonoDevelop/Xamarin Studio) 14 | *.userprefs 15 | 16 | # Mono auto generated files 17 | mono_crash.* 18 | 19 | # Build results 20 | [Dd]ebug/ 21 | [Dd]ebugPublic/ 22 | [Rr]elease/ 23 | [Rr]eleases/ 24 | x64/ 25 | x86/ 26 | [Ww][Ii][Nn]32/ 27 | [Aa][Rr][Mm]/ 28 | [Aa][Rr][Mm]64/ 29 | bld/ 30 | [Bb]in/ 31 | [Oo]bj/ 32 | [Oo]ut/ 33 | [Ll]og/ 34 | [Ll]ogs/ 35 | 36 | # Visual Studio 2015/2017 cache/options directory 37 | .vs/ 38 | # Uncomment if you have tasks that create the project's static files in wwwroot 39 | #wwwroot/ 40 | 41 | # Visual Studio 2017 auto generated files 42 | Generated\ Files/ 43 | 44 | # MSTest test Results 45 | [Tt]est[Rr]esult*/ 46 | [Bb]uild[Ll]og.* 47 | 48 | # NUnit 49 | *.VisualState.xml 50 | TestResult.xml 51 | nunit-*.xml 52 | 53 | # Build Results of an ATL Project 54 | [Dd]ebugPS/ 55 | [Rr]eleasePS/ 56 | dlldata.c 57 | 58 | # Benchmark Results 59 | BenchmarkDotNet.Artifacts/ 60 | 61 | # .NET Core 62 | project.lock.json 63 | project.fragment.lock.json 64 | artifacts/ 65 | 66 | # ASP.NET Scaffolding 67 | ScaffoldingReadMe.txt 68 | 69 | # StyleCop 70 | StyleCopReport.xml 71 | 72 | # Files built by Visual Studio 73 | *_i.c 74 | *_p.c 75 | *_h.h 76 | *.ilk 77 | *.meta 78 | *.obj 79 | *.iobj 80 | *.pch 81 | *.pdb 82 | *.ipdb 83 | *.pgc 84 | *.pgd 85 | *.rsp 86 | *.sbr 87 | *.tlb 88 | *.tli 89 | *.tlh 90 | *.tmp 91 | *.tmp_proj 92 | *_wpftmp.csproj 93 | *.log 94 | *.vspscc 95 | *.vssscc 96 | .builds 97 | *.pidb 98 | *.svclog 99 | *.scc 100 | 101 | # Chutzpah Test files 102 | _Chutzpah* 103 | 104 | # Visual C++ cache files 105 | ipch/ 106 | *.aps 107 | *.ncb 108 | *.opendb 109 | *.opensdf 110 | *.sdf 111 | *.cachefile 112 | *.VC.db 113 | *.VC.VC.opendb 114 | 115 | # Visual Studio profiler 116 | *.psess 117 | *.vsp 118 | *.vspx 119 | *.sap 120 | 121 | # Visual Studio Trace Files 122 | *.e2e 123 | 124 | # TFS 2012 Local Workspace 125 | $tf/ 126 | 127 | # Guidance Automation Toolkit 128 | *.gpState 129 | 130 | # ReSharper is a .NET coding add-in 131 | _ReSharper*/ 132 | *.[Rr]e[Ss]harper 133 | *.DotSettings.user 134 | 135 | # TeamCity is a build add-in 136 | _TeamCity* 137 | 138 | # DotCover is a Code Coverage Tool 139 | *.dotCover 140 | 141 | # AxoCover is a Code Coverage Tool 142 | .axoCover/* 143 | !.axoCover/settings.json 144 | 145 | # Coverlet is a free, cross platform Code Coverage Tool 146 | coverage*.json 147 | coverage*.xml 148 | coverage*.info 149 | 150 | # Visual Studio code coverage results 151 | *.coverage 152 | *.coveragexml 153 | 154 | # NCrunch 155 | _NCrunch_* 156 | .*crunch*.local.xml 157 | nCrunchTemp_* 158 | 159 | # MightyMoose 160 | *.mm.* 161 | AutoTest.Net/ 162 | 163 | # Web workbench (sass) 164 | .sass-cache/ 165 | 166 | # Installshield output folder 167 | [Ee]xpress/ 168 | 169 | # DocProject is a documentation generator add-in 170 | DocProject/buildhelp/ 171 | DocProject/Help/*.HxT 172 | DocProject/Help/*.HxC 173 | DocProject/Help/*.hhc 174 | DocProject/Help/*.hhk 175 | DocProject/Help/*.hhp 176 | DocProject/Help/Html2 177 | DocProject/Help/html 178 | 179 | # Click-Once directory 180 | publish/ 181 | 182 | # Publish Web Output 183 | *.[Pp]ublish.xml 184 | *.azurePubxml 185 | # Note: Comment the next line if you want to checkin your web deploy settings, 186 | # but database connection strings (with potential passwords) will be unencrypted 187 | *.pubxml 188 | *.publishproj 189 | 190 | # Microsoft Azure Web App publish settings. Comment the next line if you want to 191 | # checkin your Azure Web App publish settings, but sensitive information contained 192 | # in these scripts will be unencrypted 193 | PublishScripts/ 194 | 195 | # NuGet Packages 196 | *.nupkg 197 | # NuGet Symbol Packages 198 | *.snupkg 199 | # The packages folder can be ignored because of Package Restore 200 | **/[Pp]ackages/* 201 | # except build/, which is used as an MSBuild target. 202 | !**/[Pp]ackages/build/ 203 | # Uncomment if necessary however generally it will be regenerated when needed 204 | #!**/[Pp]ackages/repositories.config 205 | # NuGet v3's project.json files produces more ignorable files 206 | *.nuget.props 207 | *.nuget.targets 208 | 209 | # Microsoft Azure Build Output 210 | csx/ 211 | *.build.csdef 212 | 213 | # Microsoft Azure Emulator 214 | ecf/ 215 | rcf/ 216 | 217 | # Windows Store app package directories and files 218 | AppPackages/ 219 | BundleArtifacts/ 220 | Package.StoreAssociation.xml 221 | _pkginfo.txt 222 | *.appx 223 | *.appxbundle 224 | *.appxupload 225 | 226 | # Visual Studio cache files 227 | # files ending in .cache can be ignored 228 | *.[Cc]ache 229 | # but keep track of directories ending in .cache 230 | !?*.[Cc]ache/ 231 | 232 | # Others 233 | ClientBin/ 234 | ~$* 235 | *~ 236 | *.dbmdl 237 | *.dbproj.schemaview 238 | *.jfm 239 | *.pfx 240 | *.publishsettings 241 | orleans.codegen.cs 242 | 243 | # Including strong name files can present a security risk 244 | # (https://github.com/github/gitignore/pull/2483#issue-259490424) 245 | #*.snk 246 | 247 | # Since there are multiple workflows, uncomment next line to ignore bower_components 248 | # (https://github.com/github/gitignore/pull/1529#issuecomment-104372622) 249 | #bower_components/ 250 | 251 | # RIA/Silverlight projects 252 | Generated_Code/ 253 | 254 | # Backup & report files from converting an old project file 255 | # to a newer Visual Studio version. Backup files are not needed, 256 | # because we have git ;-) 257 | _UpgradeReport_Files/ 258 | Backup*/ 259 | UpgradeLog*.XML 260 | UpgradeLog*.htm 261 | ServiceFabricBackup/ 262 | *.rptproj.bak 263 | 264 | # SQL Server files 265 | *.mdf 266 | *.ldf 267 | *.ndf 268 | 269 | # Business Intelligence projects 270 | *.rdl.data 271 | *.bim.layout 272 | *.bim_*.settings 273 | *.rptproj.rsuser 274 | *- [Bb]ackup.rdl 275 | *- [Bb]ackup ([0-9]).rdl 276 | *- [Bb]ackup ([0-9][0-9]).rdl 277 | 278 | # Microsoft Fakes 279 | FakesAssemblies/ 280 | 281 | # GhostDoc plugin setting file 282 | *.GhostDoc.xml 283 | 284 | # Node.js Tools for Visual Studio 285 | .ntvs_analysis.dat 286 | node_modules/ 287 | 288 | # Visual Studio 6 build log 289 | *.plg 290 | 291 | # Visual Studio 6 workspace options file 292 | *.opt 293 | 294 | # Visual Studio 6 auto-generated workspace file (contains which files were open etc.) 295 | *.vbw 296 | 297 | # Visual Studio LightSwitch build output 298 | **/*.HTMLClient/GeneratedArtifacts 299 | **/*.DesktopClient/GeneratedArtifacts 300 | **/*.DesktopClient/ModelManifest.xml 301 | **/*.Server/GeneratedArtifacts 302 | **/*.Server/ModelManifest.xml 303 | _Pvt_Extensions 304 | 305 | # Paket dependency manager 306 | .paket/paket.exe 307 | paket-files/ 308 | 309 | # FAKE - F# Make 310 | .fake/ 311 | 312 | # CodeRush personal settings 313 | .cr/personal 314 | 315 | # Python Tools for Visual Studio (PTVS) 316 | __pycache__/ 317 | *.pyc 318 | 319 | # Cake - Uncomment if you are using it 320 | # tools/** 321 | # !tools/packages.config 322 | 323 | # Tabs Studio 324 | *.tss 325 | 326 | # Telerik's JustMock configuration file 327 | *.jmconfig 328 | 329 | # BizTalk build output 330 | *.btp.cs 331 | *.btm.cs 332 | *.odx.cs 333 | *.xsd.cs 334 | 335 | # OpenCover UI analysis results 336 | OpenCover/ 337 | 338 | # Azure Stream Analytics local run output 339 | ASALocalRun/ 340 | 341 | # MSBuild Binary and Structured Log 342 | *.binlog 343 | 344 | # NVidia Nsight GPU debugger configuration file 345 | *.nvuser 346 | 347 | # MFractors (Xamarin productivity tool) working folder 348 | .mfractor/ 349 | 350 | # Local History for Visual Studio 351 | .localhistory/ 352 | 353 | # BeatPulse healthcheck temp database 354 | healthchecksdb 355 | 356 | # Backup folder for Package Reference Convert tool in Visual Studio 2017 357 | MigrationBackup/ 358 | 359 | # Ionide (cross platform F# VS Code tools) working folder 360 | .ionide/ 361 | 362 | # Fody - auto-generated XML schema 363 | FodyWeavers.xsd -------------------------------------------------------------------------------- /LowCodeAPI.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio Version 16 4 | VisualStudioVersion = 16.0.31424.327 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LowCodeAPI.Server", "LowCodeAPI\Server\LowCodeAPI.Server.csproj", "{40A115C6-E5AC-4C1C-9AB4-18AD8FD85520}" 7 | EndProject 8 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LowCodeAPI.Client", "LowCodeAPI\Client\LowCodeAPI.Client.csproj", "{261D916A-A30B-470E-8DB0-C0DFF2A53A1E}" 9 | EndProject 10 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LowCodeAPI.Shared", "LowCodeAPI\Shared\LowCodeAPI.Shared.csproj", "{6648528C-3E82-4428-B137-FDED1B7E8A44}" 11 | EndProject 12 | Global 13 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 14 | Debug|Any CPU = Debug|Any CPU 15 | Release|Any CPU = Release|Any CPU 16 | EndGlobalSection 17 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 18 | {40A115C6-E5AC-4C1C-9AB4-18AD8FD85520}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 19 | {40A115C6-E5AC-4C1C-9AB4-18AD8FD85520}.Debug|Any CPU.Build.0 = Debug|Any CPU 20 | {40A115C6-E5AC-4C1C-9AB4-18AD8FD85520}.Release|Any CPU.ActiveCfg = Release|Any CPU 21 | {40A115C6-E5AC-4C1C-9AB4-18AD8FD85520}.Release|Any CPU.Build.0 = Release|Any CPU 22 | {261D916A-A30B-470E-8DB0-C0DFF2A53A1E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 23 | {261D916A-A30B-470E-8DB0-C0DFF2A53A1E}.Debug|Any CPU.Build.0 = Debug|Any CPU 24 | {261D916A-A30B-470E-8DB0-C0DFF2A53A1E}.Release|Any CPU.ActiveCfg = Release|Any CPU 25 | {261D916A-A30B-470E-8DB0-C0DFF2A53A1E}.Release|Any CPU.Build.0 = Release|Any CPU 26 | {6648528C-3E82-4428-B137-FDED1B7E8A44}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 27 | {6648528C-3E82-4428-B137-FDED1B7E8A44}.Debug|Any CPU.Build.0 = Debug|Any CPU 28 | {6648528C-3E82-4428-B137-FDED1B7E8A44}.Release|Any CPU.ActiveCfg = Release|Any CPU 29 | {6648528C-3E82-4428-B137-FDED1B7E8A44}.Release|Any CPU.Build.0 = Release|Any CPU 30 | EndGlobalSection 31 | GlobalSection(SolutionProperties) = preSolution 32 | HideSolutionNode = FALSE 33 | EndGlobalSection 34 | GlobalSection(ExtensibilityGlobals) = postSolution 35 | SolutionGuid = {47B13CDE-526A-4617-9DF1-7E4B80208021} 36 | EndGlobalSection 37 | EndGlobal 38 | -------------------------------------------------------------------------------- /LowCodeAPI/Client/App.razor: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 |

Sorry, there's nothing at this address.

8 |
9 |
10 |
11 | -------------------------------------------------------------------------------- /LowCodeAPI/Client/LowCodeAPI.Client.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | net5.0 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /LowCodeAPI/Client/Pages/Counter.razor: -------------------------------------------------------------------------------- 1 | @page "/counter" 2 | 3 |

Counter

4 | 5 |

Current count: @currentCount

6 | 7 | 8 | 9 | @code { 10 | private int currentCount = 0; 11 | 12 | private void IncrementCount() 13 | { 14 | currentCount++; 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /LowCodeAPI/Client/Pages/FetchData.razor: -------------------------------------------------------------------------------- 1 | @page "/fetchdata" 2 | @using LowCodeAPI.Shared 3 | @inject HttpClient Http 4 | 5 |

Weather forecast

6 | 7 |

This component demonstrates fetching data from the server.

8 | 9 | @if (forecasts == null) 10 | { 11 |

Loading...

12 | } 13 | else 14 | { 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | @foreach (var forecast in forecasts) 26 | { 27 | 28 | 29 | 30 | 31 | 32 | 33 | } 34 | 35 |
DateTemp. (C)Temp. (F)Summary
@forecast.Date.ToShortDateString()@forecast.TemperatureC@forecast.TemperatureF@forecast.Summary
36 | } 37 | 38 | @code { 39 | private WeatherForecast[] forecasts; 40 | 41 | protected override async Task OnInitializedAsync() 42 | { 43 | forecasts = await Http.GetFromJsonAsync("WeatherForecast"); 44 | } 45 | 46 | } 47 | -------------------------------------------------------------------------------- /LowCodeAPI/Client/Pages/Index.razor: -------------------------------------------------------------------------------- 1 | @page "/" 2 | @inject AuthorsManager AuthorsManager 3 | 4 | @if (Authors != null) 5 | { 6 |  Search by Name:  7 | 8 |   9 | 10 |   11 | 12 |
13 |
14 | 15 | 16 | @if (CanIAddaAuthor()) 17 | { 18 |   19 | 20 | } 21 |
22 |
23 | 29 |
30 |
31 | } 32 | else 33 | { 34 | Loading Authors... 35 | } 36 | @if (Author != null) 37 | { 38 |  Update Last Name:  39 | 40 | 41 |
42 |
43 | 44 | 45 | } 46 |
47 | @ErrorMessage 48 | 49 | @code 50 | { 51 | List Authors; 52 | Author Author; 53 | string SearchName = ""; 54 | string ErrorMessage = ""; 55 | 56 | async Task DeleteAuthor() 57 | { 58 | ErrorMessage = ""; 59 | if (await AuthorsManager.Delete(Author)) 60 | { 61 | var original = (from x in Authors 62 | where x.AuId == Author.AuId 63 | select x).FirstOrDefault(); 64 | if (original != null) 65 | { 66 | var index = Authors.IndexOf(original); 67 | Authors.RemoveAt(index); 68 | Author = null; 69 | } 70 | } 71 | else 72 | { 73 | ErrorMessage = "Could not delete Author."; 74 | } 75 | await InvokeAsync(StateHasChanged); 76 | } 77 | 78 | async Task UpdateAuthor() 79 | { 80 | ErrorMessage = ""; 81 | var original = (from x in Authors 82 | where x.AuId == Author.AuId 83 | select x).FirstOrDefault(); 84 | if (original != null) 85 | { 86 | var index = Authors.IndexOf(original); 87 | var updated = await AuthorsManager.Update(Author); 88 | if (updated != null) 89 | { 90 | Authors[index] = updated; 91 | } 92 | else 93 | { 94 | ErrorMessage = "Could not update Author"; 95 | } 96 | await InvokeAsync(StateHasChanged); 97 | } 98 | } 99 | 100 | async Task Search() 101 | { 102 | ErrorMessage = ""; 103 | var result = await AuthorsManager.SearchByValue("AuLname", SearchName); 104 | if (result != null) 105 | { 106 | Authors = result.ToList(); 107 | } 108 | else 109 | { 110 | Authors = new List(); 111 | ErrorMessage = "No matching Authors."; 112 | } 113 | await InvokeAsync(StateHasChanged); 114 | } 115 | 116 | async Task Get() 117 | { 118 | ErrorMessage = ""; 119 | var result = await AuthorsManager.GetByValue("AuLname", SearchName); 120 | if (result != null) 121 | { 122 | Authors.Clear(); 123 | Authors.Add(result); 124 | } 125 | else 126 | { 127 | Authors = new List(); 128 | ErrorMessage = "No matching Authors."; 129 | } 130 | await InvokeAsync(StateHasChanged); 131 | } 132 | 133 | async Task AuthorSelected(ChangeEventArgs args) 134 | { 135 | ErrorMessage = ""; 136 | var result = (from x in Authors 137 | where x.AuId == args.Value.ToString() 138 | select x).FirstOrDefault(); 139 | 140 | // Get the Author via the API just to exercise all the methods: 141 | Author = await AuthorsManager.GetByValue("AuId", result.AuId); 142 | 143 | await InvokeAsync(StateHasChanged); 144 | } 145 | 146 | bool CanIAddaAuthor() 147 | { 148 | // only if it doesn't exist 149 | var existing = (from x in Authors 150 | where x.AuId == "111-22-3333" 151 | select x).FirstOrDefault(); 152 | if (existing != null) 153 | return false; 154 | else 155 | return true; 156 | } 157 | 158 | async Task AddAuthor() 159 | { 160 | ErrorMessage = ""; 161 | var Author = new Author(); 162 | Author.AuId = "111-22-3333"; 163 | Author.AuFname = "Carl"; 164 | Author.AuLname = "Franklin"; 165 | Author.Phone = "123123132"; 166 | Author.Address = "1 Somewhere Street"; 167 | Author.City = "Anytown"; 168 | Author.State = "CT"; 169 | Author.Zip = "09876"; 170 | Author.Contract = true; 171 | 172 | var result = await AuthorsManager.Insert(Author); 173 | if (result != null) 174 | { 175 | Authors.Add(result); 176 | Author = result; 177 | } 178 | else 179 | { 180 | ErrorMessage = "Could not add Author"; 181 | } 182 | await InvokeAsync(StateHasChanged); 183 | } 184 | 185 | async Task GetAllAuthors() 186 | { 187 | ErrorMessage = ""; 188 | SearchName = ""; 189 | try 190 | { 191 | var result = await AuthorsManager.GetAll(); 192 | if (result != null) 193 | { 194 | Authors = result.ToList(); 195 | Author = null; 196 | } 197 | else 198 | { 199 | ErrorMessage = "Could not fetch Authors"; 200 | } 201 | } 202 | catch (Exception ex) 203 | { 204 | ErrorMessage = ex.Message; 205 | } 206 | } 207 | 208 | protected override async Task OnInitializedAsync() 209 | { 210 | await GetAllAuthors(); 211 | } 212 | } -------------------------------------------------------------------------------- /LowCodeAPI/Client/Program.cs: -------------------------------------------------------------------------------- 1 | using LowCodeAPI.Client.Services; 2 | using Microsoft.AspNetCore.Components.WebAssembly.Hosting; 3 | using Microsoft.Extensions.Configuration; 4 | using Microsoft.Extensions.DependencyInjection; 5 | using Microsoft.Extensions.Logging; 6 | using System; 7 | using System.Collections.Generic; 8 | using System.Net.Http; 9 | using System.Text; 10 | using System.Threading.Tasks; 11 | 12 | namespace LowCodeAPI.Client 13 | { 14 | public class Program 15 | { 16 | public static async Task Main(string[] args) 17 | { 18 | var builder = WebAssemblyHostBuilder.CreateDefault(args); 19 | builder.RootComponents.Add("#app"); 20 | 21 | builder.Services.AddScoped(sp => new HttpClient { BaseAddress = new Uri(builder.HostEnvironment.BaseAddress) }); 22 | builder.Services.AddScoped(); 23 | await builder.Build().RunAsync(); 24 | } 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /LowCodeAPI/Client/Properties/launchSettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "iisSettings": { 3 | "windowsAuthentication": false, 4 | "anonymousAuthentication": true, 5 | "iisExpress": { 6 | "applicationUrl": "http://localhost:32091", 7 | "sslPort": 44347 8 | } 9 | }, 10 | "profiles": { 11 | "IIS Express": { 12 | "commandName": "IISExpress", 13 | "launchBrowser": true, 14 | "inspectUri": "{wsProtocol}://{url.hostname}:{url.port}/_framework/debug/ws-proxy?browser={browserInspectUri}", 15 | "environmentVariables": { 16 | "ASPNETCORE_ENVIRONMENT": "Development" 17 | } 18 | }, 19 | "LowCodeAPI": { 20 | "commandName": "Project", 21 | "dotnetRunMessages": "true", 22 | "launchBrowser": true, 23 | "inspectUri": "{wsProtocol}://{url.hostname}:{url.port}/_framework/debug/ws-proxy?browser={browserInspectUri}", 24 | "applicationUrl": "https://localhost:5001;http://localhost:5000", 25 | "environmentVariables": { 26 | "ASPNETCORE_ENVIRONMENT": "Development" 27 | } 28 | } 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /LowCodeAPI/Client/Services/APIRepository.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Threading.Tasks; 4 | using LowCodeAPI.Shared.Models; 5 | using System.Net.Http; 6 | using System.Net.Http.Json; 7 | using Newtonsoft.Json; 8 | using System.Net; 9 | using System.Linq.Expressions; 10 | using System.Linq; 11 | 12 | /// 13 | /// Reusable API Repository base class that provides access to CRUD APIs 14 | /// 15 | /// 16 | public class APIRepository : IRepository 17 | where TEntity : class 18 | { 19 | string controllerName; 20 | string primaryKeyName; 21 | HttpClient http; 22 | 23 | public APIRepository(HttpClient _http, string _controllerName, string _primaryKeyName) 24 | { 25 | http = _http; 26 | controllerName = _controllerName; 27 | primaryKeyName = _primaryKeyName; 28 | } 29 | 30 | 31 | public async Task> GetAll() 32 | { 33 | try 34 | { 35 | var result = await http.GetAsync(controllerName); 36 | result.EnsureSuccessStatusCode(); 37 | string responseBody = await result.Content.ReadAsStringAsync(); 38 | var response = JsonConvert.DeserializeObject>(responseBody); 39 | if (response.Success) 40 | return response.Data; 41 | else 42 | return new List(); 43 | } 44 | catch (Exception ex) 45 | { 46 | var msg = ex.Message; 47 | return null; 48 | } 49 | } 50 | 51 | public Task> Get(Expression> filter = null, Func, IOrderedQueryable> orderBy = null, string includeProperties = "") 52 | { 53 | throw new NotImplementedException(); 54 | } 55 | 56 | public async Task GetByValue(string PropertyName, string Value) 57 | { 58 | try 59 | { 60 | 61 | var url = $"{controllerName}/{WebUtility.HtmlEncode(PropertyName)}/{WebUtility.HtmlEncode(Value)}/GetByValue"; 62 | var result = await http.GetAsync(url); 63 | result.EnsureSuccessStatusCode(); 64 | string responseBody = await result.Content.ReadAsStringAsync(); 65 | var response = JsonConvert.DeserializeObject>(responseBody); 66 | if (response.Success) 67 | return response.Data; 68 | else 69 | return null; 70 | } 71 | catch (Exception ex) 72 | { 73 | var msg = ex.Message; 74 | return null; 75 | } 76 | } 77 | 78 | public async Task> SearchByValue(string PropertyName, string Value) 79 | { 80 | try 81 | { 82 | var url = $"{controllerName}/{WebUtility.HtmlEncode(PropertyName)}/{WebUtility.HtmlEncode(Value)}/SearchByValue"; 83 | var result = await http.GetAsync(url); 84 | result.EnsureSuccessStatusCode(); 85 | string responseBody = await result.Content.ReadAsStringAsync(); 86 | var response = JsonConvert.DeserializeObject>(responseBody); 87 | if (response.Success) 88 | return response.Data; 89 | else 90 | return null; 91 | } 92 | catch (Exception ex) 93 | { 94 | var msg = ex.Message; 95 | return null; 96 | } 97 | } 98 | 99 | public async Task Insert(TEntity entity) 100 | { 101 | try 102 | { 103 | var result = await http.PostAsJsonAsync(controllerName, entity); 104 | result.EnsureSuccessStatusCode(); 105 | string responseBody = await result.Content.ReadAsStringAsync(); 106 | var response = JsonConvert.DeserializeObject>(responseBody); 107 | if (response.Success) 108 | return response.Data; 109 | else 110 | return null; 111 | } 112 | catch (Exception ex) 113 | { 114 | return null; 115 | } 116 | } 117 | 118 | public async Task Update(TEntity entityToUpdate) 119 | { 120 | try 121 | { 122 | var result = await http.PutAsJsonAsync(controllerName, entityToUpdate); 123 | result.EnsureSuccessStatusCode(); 124 | string responseBody = await result.Content.ReadAsStringAsync(); 125 | var response = JsonConvert.DeserializeObject>(responseBody); 126 | if (response.Success) 127 | return response.Data; 128 | else 129 | return null; 130 | } 131 | catch (Exception ex) 132 | { 133 | return null; 134 | } 135 | } 136 | 137 | public async Task Delete(TEntity entityToDelete) 138 | { 139 | try 140 | { 141 | var value = entityToDelete.GetType() 142 | .GetProperty(primaryKeyName) 143 | .GetValue(entityToDelete, null) 144 | .ToString(); 145 | 146 | return await DeleteByValue(primaryKeyName, value); 147 | } 148 | catch (Exception ex) 149 | { 150 | return false; 151 | } 152 | } 153 | 154 | public async Task DeleteByValue(string PropertyName, string Value) 155 | { 156 | try 157 | { 158 | var url = $"{controllerName}/{WebUtility.HtmlEncode(PropertyName)}/{WebUtility.HtmlEncode(Value)}/DeleteByValue"; 159 | var result = await http.DeleteAsync(url); 160 | result.EnsureSuccessStatusCode(); 161 | return true; 162 | } 163 | catch (Exception ex) 164 | { 165 | return false; 166 | } 167 | } 168 | 169 | } -------------------------------------------------------------------------------- /LowCodeAPI/Client/Services/AuthorsManager.cs: -------------------------------------------------------------------------------- 1 | using LowCodeAPI.Shared.Models; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Linq; 5 | using System.Net.Http; 6 | using System.Threading.Tasks; 7 | 8 | namespace LowCodeAPI.Client.Services 9 | { 10 | public class AuthorsManager : APIRepository 11 | { 12 | HttpClient http; 13 | 14 | public AuthorsManager(HttpClient _http) 15 | : base(_http, "authors", "AuId") 16 | { 17 | http = _http; 18 | } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /LowCodeAPI/Client/Shared/MainLayout.razor: -------------------------------------------------------------------------------- 1 | @inherits LayoutComponentBase 2 | 3 |
4 | 7 | 8 |
9 |
10 | About 11 |
12 | 13 |
14 | @Body 15 |
16 |
17 |
18 | -------------------------------------------------------------------------------- /LowCodeAPI/Client/Shared/MainLayout.razor.css: -------------------------------------------------------------------------------- 1 | .page { 2 | position: relative; 3 | display: flex; 4 | flex-direction: column; 5 | } 6 | 7 | .main { 8 | flex: 1; 9 | } 10 | 11 | .sidebar { 12 | background-image: linear-gradient(180deg, rgb(5, 39, 103) 0%, #3a0647 70%); 13 | } 14 | 15 | .top-row { 16 | background-color: #f7f7f7; 17 | border-bottom: 1px solid #d6d5d5; 18 | justify-content: flex-end; 19 | height: 3.5rem; 20 | display: flex; 21 | align-items: center; 22 | } 23 | 24 | .top-row ::deep a, .top-row .btn-link { 25 | white-space: nowrap; 26 | margin-left: 1.5rem; 27 | } 28 | 29 | .top-row a:first-child { 30 | overflow: hidden; 31 | text-overflow: ellipsis; 32 | } 33 | 34 | @media (max-width: 640.98px) { 35 | .top-row:not(.auth) { 36 | display: none; 37 | } 38 | 39 | .top-row.auth { 40 | justify-content: space-between; 41 | } 42 | 43 | .top-row a, .top-row .btn-link { 44 | margin-left: 0; 45 | } 46 | } 47 | 48 | @media (min-width: 641px) { 49 | .page { 50 | flex-direction: row; 51 | } 52 | 53 | .sidebar { 54 | width: 250px; 55 | height: 100vh; 56 | position: sticky; 57 | top: 0; 58 | } 59 | 60 | .top-row { 61 | position: sticky; 62 | top: 0; 63 | z-index: 1; 64 | } 65 | 66 | .main > div { 67 | padding-left: 2rem !important; 68 | padding-right: 1.5rem !important; 69 | } 70 | } 71 | -------------------------------------------------------------------------------- /LowCodeAPI/Client/Shared/NavMenu.razor: -------------------------------------------------------------------------------- 1 |  7 | 8 |
9 | 26 |
27 | 28 | @code { 29 | private bool collapseNavMenu = true; 30 | 31 | private string NavMenuCssClass => collapseNavMenu ? "collapse" : null; 32 | 33 | private void ToggleNavMenu() 34 | { 35 | collapseNavMenu = !collapseNavMenu; 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /LowCodeAPI/Client/Shared/NavMenu.razor.css: -------------------------------------------------------------------------------- 1 | .navbar-toggler { 2 | background-color: rgba(255, 255, 255, 0.1); 3 | } 4 | 5 | .top-row { 6 | height: 3.5rem; 7 | background-color: rgba(0,0,0,0.4); 8 | } 9 | 10 | .navbar-brand { 11 | font-size: 1.1rem; 12 | } 13 | 14 | .oi { 15 | width: 2rem; 16 | font-size: 1.1rem; 17 | vertical-align: text-top; 18 | top: -2px; 19 | } 20 | 21 | .nav-item { 22 | font-size: 0.9rem; 23 | padding-bottom: 0.5rem; 24 | } 25 | 26 | .nav-item:first-of-type { 27 | padding-top: 1rem; 28 | } 29 | 30 | .nav-item:last-of-type { 31 | padding-bottom: 1rem; 32 | } 33 | 34 | .nav-item ::deep a { 35 | color: #d7d7d7; 36 | border-radius: 4px; 37 | height: 3rem; 38 | display: flex; 39 | align-items: center; 40 | line-height: 3rem; 41 | } 42 | 43 | .nav-item ::deep a.active { 44 | background-color: rgba(255,255,255,0.25); 45 | color: white; 46 | } 47 | 48 | .nav-item ::deep a:hover { 49 | background-color: rgba(255,255,255,0.1); 50 | color: white; 51 | } 52 | 53 | @media (min-width: 641px) { 54 | .navbar-toggler { 55 | display: none; 56 | } 57 | 58 | .collapse { 59 | /* Never collapse the sidebar for wide screens */ 60 | display: block; 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /LowCodeAPI/Client/Shared/SurveyPrompt.razor: -------------------------------------------------------------------------------- 1 |  11 | 12 | @code { 13 | // Demonstrates how a parent component can supply parameters 14 | [Parameter] 15 | public string Title { get; set; } 16 | } 17 | -------------------------------------------------------------------------------- /LowCodeAPI/Client/_Imports.razor: -------------------------------------------------------------------------------- 1 | @using System.Net.Http 2 | @using System.Net.Http.Json 3 | @using Microsoft.AspNetCore.Components.Forms 4 | @using Microsoft.AspNetCore.Components.Routing 5 | @using Microsoft.AspNetCore.Components.Web 6 | @using Microsoft.AspNetCore.Components.Web.Virtualization 7 | @using Microsoft.AspNetCore.Components.WebAssembly.Http 8 | @using Microsoft.JSInterop 9 | @using LowCodeAPI.Client 10 | @using LowCodeAPI.Client.Shared 11 | @using LowCodeAPI.Client.Services 12 | @using LowCodeAPI.Shared.Models -------------------------------------------------------------------------------- /LowCodeAPI/Client/wwwroot/css/app.css: -------------------------------------------------------------------------------- 1 | @import url('open-iconic/font/css/open-iconic-bootstrap.min.css'); 2 | 3 | html, body { 4 | font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; 5 | } 6 | 7 | a, .btn-link { 8 | color: #0366d6; 9 | } 10 | 11 | .btn-primary { 12 | color: #fff; 13 | background-color: #1b6ec2; 14 | border-color: #1861ac; 15 | } 16 | 17 | .content { 18 | padding-top: 1.1rem; 19 | } 20 | 21 | .valid.modified:not([type=checkbox]) { 22 | outline: 1px solid #26b050; 23 | } 24 | 25 | .invalid { 26 | outline: 1px solid red; 27 | } 28 | 29 | .validation-message { 30 | color: red; 31 | } 32 | 33 | #blazor-error-ui { 34 | background: lightyellow; 35 | bottom: 0; 36 | box-shadow: 0 -1px 2px rgba(0, 0, 0, 0.2); 37 | display: none; 38 | left: 0; 39 | padding: 0.6rem 1.25rem 0.7rem 1.25rem; 40 | position: fixed; 41 | width: 100%; 42 | z-index: 1000; 43 | } 44 | 45 | #blazor-error-ui .dismiss { 46 | cursor: pointer; 47 | position: absolute; 48 | right: 0.75rem; 49 | top: 0.5rem; 50 | } 51 | -------------------------------------------------------------------------------- /LowCodeAPI/Client/wwwroot/css/open-iconic/FONT-LICENSE: -------------------------------------------------------------------------------- 1 | SIL OPEN FONT LICENSE Version 1.1 2 | 3 | Copyright (c) 2014 Waybury 4 | 5 | PREAMBLE 6 | The goals of the Open Font License (OFL) are to stimulate worldwide 7 | development of collaborative font projects, to support the font creation 8 | efforts of academic and linguistic communities, and to provide a free and 9 | open framework in which fonts may be shared and improved in partnership 10 | with others. 11 | 12 | The OFL allows the licensed fonts to be used, studied, modified and 13 | redistributed freely as long as they are not sold by themselves. The 14 | fonts, including any derivative works, can be bundled, embedded, 15 | redistributed and/or sold with any software provided that any reserved 16 | names are not used by derivative works. The fonts and derivatives, 17 | however, cannot be released under any other type of license. The 18 | requirement for fonts to remain under this license does not apply 19 | to any document created using the fonts or their derivatives. 20 | 21 | DEFINITIONS 22 | "Font Software" refers to the set of files released by the Copyright 23 | Holder(s) under this license and clearly marked as such. This may 24 | include source files, build scripts and documentation. 25 | 26 | "Reserved Font Name" refers to any names specified as such after the 27 | copyright statement(s). 28 | 29 | "Original Version" refers to the collection of Font Software components as 30 | distributed by the Copyright Holder(s). 31 | 32 | "Modified Version" refers to any derivative made by adding to, deleting, 33 | or substituting -- in part or in whole -- any of the components of the 34 | Original Version, by changing formats or by porting the Font Software to a 35 | new environment. 36 | 37 | "Author" refers to any designer, engineer, programmer, technical 38 | writer or other person who contributed to the Font Software. 39 | 40 | PERMISSION & CONDITIONS 41 | Permission is hereby granted, free of charge, to any person obtaining 42 | a copy of the Font Software, to use, study, copy, merge, embed, modify, 43 | redistribute, and sell modified and unmodified copies of the Font 44 | Software, subject to the following conditions: 45 | 46 | 1) Neither the Font Software nor any of its individual components, 47 | in Original or Modified Versions, may be sold by itself. 48 | 49 | 2) Original or Modified Versions of the Font Software may be bundled, 50 | redistributed and/or sold with any software, provided that each copy 51 | contains the above copyright notice and this license. These can be 52 | included either as stand-alone text files, human-readable headers or 53 | in the appropriate machine-readable metadata fields within text or 54 | binary files as long as those fields can be easily viewed by the user. 55 | 56 | 3) No Modified Version of the Font Software may use the Reserved Font 57 | Name(s) unless explicit written permission is granted by the corresponding 58 | Copyright Holder. This restriction only applies to the primary font name as 59 | presented to the users. 60 | 61 | 4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font 62 | Software shall not be used to promote, endorse or advertise any 63 | Modified Version, except to acknowledge the contribution(s) of the 64 | Copyright Holder(s) and the Author(s) or with their explicit written 65 | permission. 66 | 67 | 5) The Font Software, modified or unmodified, in part or in whole, 68 | must be distributed entirely under this license, and must not be 69 | distributed under any other license. The requirement for fonts to 70 | remain under this license does not apply to any document created 71 | using the Font Software. 72 | 73 | TERMINATION 74 | This license becomes null and void if any of the above conditions are 75 | not met. 76 | 77 | DISCLAIMER 78 | THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 79 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF 80 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT 81 | OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE 82 | COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 83 | INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL 84 | DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 85 | FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM 86 | OTHER DEALINGS IN THE FONT SOFTWARE. 87 | -------------------------------------------------------------------------------- /LowCodeAPI/Client/wwwroot/css/open-iconic/ICON-LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2014 Waybury 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in 13 | all copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | THE SOFTWARE. -------------------------------------------------------------------------------- /LowCodeAPI/Client/wwwroot/css/open-iconic/README.md: -------------------------------------------------------------------------------- 1 | [Open Iconic v1.1.1](http://useiconic.com/open) 2 | =========== 3 | 4 | ### Open Iconic is the open source sibling of [Iconic](http://useiconic.com). It is a hyper-legible collection of 223 icons with a tiny footprint—ready to use with Bootstrap and Foundation. [View the collection](http://useiconic.com/open#icons) 5 | 6 | 7 | 8 | ## What's in Open Iconic? 9 | 10 | * 223 icons designed to be legible down to 8 pixels 11 | * Super-light SVG files - 61.8 for the entire set 12 | * SVG sprite—the modern replacement for icon fonts 13 | * Webfont (EOT, OTF, SVG, TTF, WOFF), PNG and WebP formats 14 | * Webfont stylesheets (including versions for Bootstrap and Foundation) in CSS, LESS, SCSS and Stylus formats 15 | * PNG and WebP raster images in 8px, 16px, 24px, 32px, 48px and 64px. 16 | 17 | 18 | ## Getting Started 19 | 20 | #### For code samples and everything else you need to get started with Open Iconic, check out our [Icons](http://useiconic.com/open#icons) and [Reference](http://useiconic.com/open#reference) sections. 21 | 22 | ### General Usage 23 | 24 | #### Using Open Iconic's SVGs 25 | 26 | We like SVGs and we think they're the way to display icons on the web. Since Open Iconic are just basic SVGs, we suggest you display them like you would any other image (don't forget the `alt` attribute). 27 | 28 | ``` 29 | icon name 30 | ``` 31 | 32 | #### Using Open Iconic's SVG Sprite 33 | 34 | Open Iconic also comes in a SVG sprite which allows you to display all the icons in the set with a single request. It's like an icon font, without being a hack. 35 | 36 | Adding an icon from an SVG sprite is a little different than what you're used to, but it's still a piece of cake. *Tip: To make your icons easily style able, we suggest adding a general class to the* `` *tag and a unique class name for each different icon in the* `` *tag.* 37 | 38 | ``` 39 | 40 | 41 | 42 | ``` 43 | 44 | Sizing icons only needs basic CSS. All the icons are in a square format, so just set the `` tag with equal width and height dimensions. 45 | 46 | ``` 47 | .icon { 48 | width: 16px; 49 | height: 16px; 50 | } 51 | ``` 52 | 53 | Coloring icons is even easier. All you need to do is set the `fill` rule on the `` tag. 54 | 55 | ``` 56 | .icon-account-login { 57 | fill: #f00; 58 | } 59 | ``` 60 | 61 | To learn more about SVG Sprites, read [Chris Coyier's guide](http://css-tricks.com/svg-sprites-use-better-icon-fonts/). 62 | 63 | #### Using Open Iconic's Icon Font... 64 | 65 | 66 | ##### …with Bootstrap 67 | 68 | You can find our Bootstrap stylesheets in `font/css/open-iconic-bootstrap.{css, less, scss, styl}` 69 | 70 | 71 | ``` 72 | 73 | ``` 74 | 75 | 76 | ``` 77 | 78 | ``` 79 | 80 | ##### …with Foundation 81 | 82 | You can find our Foundation stylesheets in `font/css/open-iconic-foundation.{css, less, scss, styl}` 83 | 84 | ``` 85 | 86 | ``` 87 | 88 | 89 | ``` 90 | 91 | ``` 92 | 93 | ##### …on its own 94 | 95 | You can find our default stylesheets in `font/css/open-iconic.{css, less, scss, styl}` 96 | 97 | ``` 98 | 99 | ``` 100 | 101 | ``` 102 | 103 | ``` 104 | 105 | 106 | ## License 107 | 108 | ### Icons 109 | 110 | All code (including SVG markup) is under the [MIT License](http://opensource.org/licenses/MIT). 111 | 112 | ### Fonts 113 | 114 | All fonts are under the [SIL Licensed](http://scripts.sil.org/cms/scripts/page.php?item_id=OFL_web). 115 | -------------------------------------------------------------------------------- /LowCodeAPI/Client/wwwroot/css/open-iconic/font/css/open-iconic-bootstrap.min.css: -------------------------------------------------------------------------------- 1 | @font-face{font-family:Icons;src:url(../fonts/open-iconic.eot);src:url(../fonts/open-iconic.eot?#iconic-sm) format('embedded-opentype'),url(../fonts/open-iconic.woff) format('woff'),url(../fonts/open-iconic.ttf) format('truetype'),url(../fonts/open-iconic.otf) format('opentype'),url(../fonts/open-iconic.svg#iconic-sm) format('svg');font-weight:400;font-style:normal}.oi{position:relative;top:1px;display:inline-block;speak:none;font-family:Icons;font-style:normal;font-weight:400;line-height:1;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale}.oi:empty:before{width:1em;text-align:center;box-sizing:content-box}.oi.oi-align-center:before{text-align:center}.oi.oi-align-left:before{text-align:left}.oi.oi-align-right:before{text-align:right}.oi.oi-flip-horizontal:before{-webkit-transform:scale(-1,1);-ms-transform:scale(-1,1);transform:scale(-1,1)}.oi.oi-flip-vertical:before{-webkit-transform:scale(1,-1);-ms-transform:scale(-1,1);transform:scale(1,-1)}.oi.oi-flip-horizontal-vertical:before{-webkit-transform:scale(-1,-1);-ms-transform:scale(-1,1);transform:scale(-1,-1)}.oi-account-login:before{content:'\e000'}.oi-account-logout:before{content:'\e001'}.oi-action-redo:before{content:'\e002'}.oi-action-undo:before{content:'\e003'}.oi-align-center:before{content:'\e004'}.oi-align-left:before{content:'\e005'}.oi-align-right:before{content:'\e006'}.oi-aperture:before{content:'\e007'}.oi-arrow-bottom:before{content:'\e008'}.oi-arrow-circle-bottom:before{content:'\e009'}.oi-arrow-circle-left:before{content:'\e00a'}.oi-arrow-circle-right:before{content:'\e00b'}.oi-arrow-circle-top:before{content:'\e00c'}.oi-arrow-left:before{content:'\e00d'}.oi-arrow-right:before{content:'\e00e'}.oi-arrow-thick-bottom:before{content:'\e00f'}.oi-arrow-thick-left:before{content:'\e010'}.oi-arrow-thick-right:before{content:'\e011'}.oi-arrow-thick-top:before{content:'\e012'}.oi-arrow-top:before{content:'\e013'}.oi-audio-spectrum:before{content:'\e014'}.oi-audio:before{content:'\e015'}.oi-badge:before{content:'\e016'}.oi-ban:before{content:'\e017'}.oi-bar-chart:before{content:'\e018'}.oi-basket:before{content:'\e019'}.oi-battery-empty:before{content:'\e01a'}.oi-battery-full:before{content:'\e01b'}.oi-beaker:before{content:'\e01c'}.oi-bell:before{content:'\e01d'}.oi-bluetooth:before{content:'\e01e'}.oi-bold:before{content:'\e01f'}.oi-bolt:before{content:'\e020'}.oi-book:before{content:'\e021'}.oi-bookmark:before{content:'\e022'}.oi-box:before{content:'\e023'}.oi-briefcase:before{content:'\e024'}.oi-british-pound:before{content:'\e025'}.oi-browser:before{content:'\e026'}.oi-brush:before{content:'\e027'}.oi-bug:before{content:'\e028'}.oi-bullhorn:before{content:'\e029'}.oi-calculator:before{content:'\e02a'}.oi-calendar:before{content:'\e02b'}.oi-camera-slr:before{content:'\e02c'}.oi-caret-bottom:before{content:'\e02d'}.oi-caret-left:before{content:'\e02e'}.oi-caret-right:before{content:'\e02f'}.oi-caret-top:before{content:'\e030'}.oi-cart:before{content:'\e031'}.oi-chat:before{content:'\e032'}.oi-check:before{content:'\e033'}.oi-chevron-bottom:before{content:'\e034'}.oi-chevron-left:before{content:'\e035'}.oi-chevron-right:before{content:'\e036'}.oi-chevron-top:before{content:'\e037'}.oi-circle-check:before{content:'\e038'}.oi-circle-x:before{content:'\e039'}.oi-clipboard:before{content:'\e03a'}.oi-clock:before{content:'\e03b'}.oi-cloud-download:before{content:'\e03c'}.oi-cloud-upload:before{content:'\e03d'}.oi-cloud:before{content:'\e03e'}.oi-cloudy:before{content:'\e03f'}.oi-code:before{content:'\e040'}.oi-cog:before{content:'\e041'}.oi-collapse-down:before{content:'\e042'}.oi-collapse-left:before{content:'\e043'}.oi-collapse-right:before{content:'\e044'}.oi-collapse-up:before{content:'\e045'}.oi-command:before{content:'\e046'}.oi-comment-square:before{content:'\e047'}.oi-compass:before{content:'\e048'}.oi-contrast:before{content:'\e049'}.oi-copywriting:before{content:'\e04a'}.oi-credit-card:before{content:'\e04b'}.oi-crop:before{content:'\e04c'}.oi-dashboard:before{content:'\e04d'}.oi-data-transfer-download:before{content:'\e04e'}.oi-data-transfer-upload:before{content:'\e04f'}.oi-delete:before{content:'\e050'}.oi-dial:before{content:'\e051'}.oi-document:before{content:'\e052'}.oi-dollar:before{content:'\e053'}.oi-double-quote-sans-left:before{content:'\e054'}.oi-double-quote-sans-right:before{content:'\e055'}.oi-double-quote-serif-left:before{content:'\e056'}.oi-double-quote-serif-right:before{content:'\e057'}.oi-droplet:before{content:'\e058'}.oi-eject:before{content:'\e059'}.oi-elevator:before{content:'\e05a'}.oi-ellipses:before{content:'\e05b'}.oi-envelope-closed:before{content:'\e05c'}.oi-envelope-open:before{content:'\e05d'}.oi-euro:before{content:'\e05e'}.oi-excerpt:before{content:'\e05f'}.oi-expand-down:before{content:'\e060'}.oi-expand-left:before{content:'\e061'}.oi-expand-right:before{content:'\e062'}.oi-expand-up:before{content:'\e063'}.oi-external-link:before{content:'\e064'}.oi-eye:before{content:'\e065'}.oi-eyedropper:before{content:'\e066'}.oi-file:before{content:'\e067'}.oi-fire:before{content:'\e068'}.oi-flag:before{content:'\e069'}.oi-flash:before{content:'\e06a'}.oi-folder:before{content:'\e06b'}.oi-fork:before{content:'\e06c'}.oi-fullscreen-enter:before{content:'\e06d'}.oi-fullscreen-exit:before{content:'\e06e'}.oi-globe:before{content:'\e06f'}.oi-graph:before{content:'\e070'}.oi-grid-four-up:before{content:'\e071'}.oi-grid-three-up:before{content:'\e072'}.oi-grid-two-up:before{content:'\e073'}.oi-hard-drive:before{content:'\e074'}.oi-header:before{content:'\e075'}.oi-headphones:before{content:'\e076'}.oi-heart:before{content:'\e077'}.oi-home:before{content:'\e078'}.oi-image:before{content:'\e079'}.oi-inbox:before{content:'\e07a'}.oi-infinity:before{content:'\e07b'}.oi-info:before{content:'\e07c'}.oi-italic:before{content:'\e07d'}.oi-justify-center:before{content:'\e07e'}.oi-justify-left:before{content:'\e07f'}.oi-justify-right:before{content:'\e080'}.oi-key:before{content:'\e081'}.oi-laptop:before{content:'\e082'}.oi-layers:before{content:'\e083'}.oi-lightbulb:before{content:'\e084'}.oi-link-broken:before{content:'\e085'}.oi-link-intact:before{content:'\e086'}.oi-list-rich:before{content:'\e087'}.oi-list:before{content:'\e088'}.oi-location:before{content:'\e089'}.oi-lock-locked:before{content:'\e08a'}.oi-lock-unlocked:before{content:'\e08b'}.oi-loop-circular:before{content:'\e08c'}.oi-loop-square:before{content:'\e08d'}.oi-loop:before{content:'\e08e'}.oi-magnifying-glass:before{content:'\e08f'}.oi-map-marker:before{content:'\e090'}.oi-map:before{content:'\e091'}.oi-media-pause:before{content:'\e092'}.oi-media-play:before{content:'\e093'}.oi-media-record:before{content:'\e094'}.oi-media-skip-backward:before{content:'\e095'}.oi-media-skip-forward:before{content:'\e096'}.oi-media-step-backward:before{content:'\e097'}.oi-media-step-forward:before{content:'\e098'}.oi-media-stop:before{content:'\e099'}.oi-medical-cross:before{content:'\e09a'}.oi-menu:before{content:'\e09b'}.oi-microphone:before{content:'\e09c'}.oi-minus:before{content:'\e09d'}.oi-monitor:before{content:'\e09e'}.oi-moon:before{content:'\e09f'}.oi-move:before{content:'\e0a0'}.oi-musical-note:before{content:'\e0a1'}.oi-paperclip:before{content:'\e0a2'}.oi-pencil:before{content:'\e0a3'}.oi-people:before{content:'\e0a4'}.oi-person:before{content:'\e0a5'}.oi-phone:before{content:'\e0a6'}.oi-pie-chart:before{content:'\e0a7'}.oi-pin:before{content:'\e0a8'}.oi-play-circle:before{content:'\e0a9'}.oi-plus:before{content:'\e0aa'}.oi-power-standby:before{content:'\e0ab'}.oi-print:before{content:'\e0ac'}.oi-project:before{content:'\e0ad'}.oi-pulse:before{content:'\e0ae'}.oi-puzzle-piece:before{content:'\e0af'}.oi-question-mark:before{content:'\e0b0'}.oi-rain:before{content:'\e0b1'}.oi-random:before{content:'\e0b2'}.oi-reload:before{content:'\e0b3'}.oi-resize-both:before{content:'\e0b4'}.oi-resize-height:before{content:'\e0b5'}.oi-resize-width:before{content:'\e0b6'}.oi-rss-alt:before{content:'\e0b7'}.oi-rss:before{content:'\e0b8'}.oi-script:before{content:'\e0b9'}.oi-share-boxed:before{content:'\e0ba'}.oi-share:before{content:'\e0bb'}.oi-shield:before{content:'\e0bc'}.oi-signal:before{content:'\e0bd'}.oi-signpost:before{content:'\e0be'}.oi-sort-ascending:before{content:'\e0bf'}.oi-sort-descending:before{content:'\e0c0'}.oi-spreadsheet:before{content:'\e0c1'}.oi-star:before{content:'\e0c2'}.oi-sun:before{content:'\e0c3'}.oi-tablet:before{content:'\e0c4'}.oi-tag:before{content:'\e0c5'}.oi-tags:before{content:'\e0c6'}.oi-target:before{content:'\e0c7'}.oi-task:before{content:'\e0c8'}.oi-terminal:before{content:'\e0c9'}.oi-text:before{content:'\e0ca'}.oi-thumb-down:before{content:'\e0cb'}.oi-thumb-up:before{content:'\e0cc'}.oi-timer:before{content:'\e0cd'}.oi-transfer:before{content:'\e0ce'}.oi-trash:before{content:'\e0cf'}.oi-underline:before{content:'\e0d0'}.oi-vertical-align-bottom:before{content:'\e0d1'}.oi-vertical-align-center:before{content:'\e0d2'}.oi-vertical-align-top:before{content:'\e0d3'}.oi-video:before{content:'\e0d4'}.oi-volume-high:before{content:'\e0d5'}.oi-volume-low:before{content:'\e0d6'}.oi-volume-off:before{content:'\e0d7'}.oi-warning:before{content:'\e0d8'}.oi-wifi:before{content:'\e0d9'}.oi-wrench:before{content:'\e0da'}.oi-x:before{content:'\e0db'}.oi-yen:before{content:'\e0dc'}.oi-zoom-in:before{content:'\e0dd'}.oi-zoom-out:before{content:'\e0de'} -------------------------------------------------------------------------------- /LowCodeAPI/Client/wwwroot/css/open-iconic/font/fonts/open-iconic.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/carlfranklin/LowCodeAPI/f4ac5e8a4b54e8290d31a20d5cd226fe64c9a9db/LowCodeAPI/Client/wwwroot/css/open-iconic/font/fonts/open-iconic.eot -------------------------------------------------------------------------------- /LowCodeAPI/Client/wwwroot/css/open-iconic/font/fonts/open-iconic.otf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/carlfranklin/LowCodeAPI/f4ac5e8a4b54e8290d31a20d5cd226fe64c9a9db/LowCodeAPI/Client/wwwroot/css/open-iconic/font/fonts/open-iconic.otf -------------------------------------------------------------------------------- /LowCodeAPI/Client/wwwroot/css/open-iconic/font/fonts/open-iconic.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 6 | 7 | 8 | Created by FontForge 20120731 at Tue Jul 1 20:39:22 2014 9 | By P.J. Onori 10 | Created by P.J. Onori with FontForge 2.0 (http://fontforge.sf.net) 11 | 12 | 13 | 14 | 27 | 28 | 30 | 32 | 34 | 36 | 38 | 40 | 42 | 45 | 47 | 49 | 51 | 53 | 55 | 57 | 59 | 61 | 63 | 65 | 67 | 69 | 71 | 74 | 76 | 79 | 81 | 84 | 86 | 88 | 91 | 93 | 95 | 98 | 100 | 102 | 104 | 106 | 109 | 112 | 115 | 117 | 121 | 123 | 125 | 127 | 130 | 132 | 134 | 136 | 138 | 141 | 143 | 145 | 147 | 149 | 151 | 153 | 155 | 157 | 159 | 162 | 165 | 167 | 169 | 172 | 174 | 177 | 179 | 181 | 183 | 185 | 189 | 191 | 194 | 196 | 198 | 200 | 202 | 205 | 207 | 209 | 211 | 213 | 215 | 218 | 220 | 222 | 224 | 226 | 228 | 230 | 232 | 234 | 236 | 238 | 241 | 243 | 245 | 247 | 249 | 251 | 253 | 256 | 259 | 261 | 263 | 265 | 267 | 269 | 272 | 274 | 276 | 280 | 282 | 285 | 287 | 289 | 292 | 295 | 298 | 300 | 302 | 304 | 306 | 309 | 312 | 314 | 316 | 318 | 320 | 322 | 324 | 326 | 330 | 334 | 338 | 340 | 343 | 345 | 347 | 349 | 351 | 353 | 355 | 358 | 360 | 363 | 365 | 367 | 369 | 371 | 373 | 375 | 377 | 379 | 381 | 383 | 386 | 388 | 390 | 392 | 394 | 396 | 399 | 401 | 404 | 406 | 408 | 410 | 412 | 414 | 416 | 419 | 421 | 423 | 425 | 428 | 431 | 435 | 438 | 440 | 442 | 444 | 446 | 448 | 451 | 453 | 455 | 457 | 460 | 462 | 464 | 466 | 468 | 471 | 473 | 477 | 479 | 481 | 483 | 486 | 488 | 490 | 492 | 494 | 496 | 499 | 501 | 504 | 506 | 509 | 512 | 515 | 517 | 520 | 522 | 524 | 526 | 529 | 532 | 534 | 536 | 539 | 542 | 543 | 544 | -------------------------------------------------------------------------------- /LowCodeAPI/Client/wwwroot/css/open-iconic/font/fonts/open-iconic.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/carlfranklin/LowCodeAPI/f4ac5e8a4b54e8290d31a20d5cd226fe64c9a9db/LowCodeAPI/Client/wwwroot/css/open-iconic/font/fonts/open-iconic.ttf -------------------------------------------------------------------------------- /LowCodeAPI/Client/wwwroot/css/open-iconic/font/fonts/open-iconic.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/carlfranklin/LowCodeAPI/f4ac5e8a4b54e8290d31a20d5cd226fe64c9a9db/LowCodeAPI/Client/wwwroot/css/open-iconic/font/fonts/open-iconic.woff -------------------------------------------------------------------------------- /LowCodeAPI/Client/wwwroot/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/carlfranklin/LowCodeAPI/f4ac5e8a4b54e8290d31a20d5cd226fe64c9a9db/LowCodeAPI/Client/wwwroot/favicon.ico -------------------------------------------------------------------------------- /LowCodeAPI/Client/wwwroot/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | LowCodeAPI 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 |
Loading...
16 | 17 |
18 | An unhandled error has occurred. 19 | Reload 20 | 🗙 21 |
22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /LowCodeAPI/Server/Controllers/AuthorsController.cs: -------------------------------------------------------------------------------- 1 | using LowCodeAPI.Server.Data; 2 | using LowCodeAPI.Shared.Models; 3 | using Microsoft.AspNetCore.Mvc; 4 | using System; 5 | using System.Collections.Generic; 6 | using System.Linq; 7 | using System.Threading.Tasks; 8 | 9 | namespace LowCodeAPI.Server.Controllers 10 | { 11 | [Route("[controller]")] 12 | [ApiController] 13 | public class AuthorsController : EFControllerBase 14 | { 15 | EFRepository repository; 16 | 17 | public AuthorsController(EFRepository _repository) 18 | : base(_repository) 19 | { 20 | repository = _repository; 21 | } 22 | 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /LowCodeAPI/Server/Controllers/WeatherForecastController.cs: -------------------------------------------------------------------------------- 1 | using LowCodeAPI.Shared; 2 | using Microsoft.AspNetCore.Mvc; 3 | using Microsoft.Extensions.Logging; 4 | using System; 5 | using System.Collections.Generic; 6 | using System.Linq; 7 | using System.Threading.Tasks; 8 | 9 | namespace LowCodeAPI.Server.Controllers 10 | { 11 | [ApiController] 12 | [Route("[controller]")] 13 | public class WeatherForecastController : ControllerBase 14 | { 15 | private static readonly string[] Summaries = new[] 16 | { 17 | "Freezing", "Bracing", "Chilly", "Cool", "Mild", "Warm", "Balmy", "Hot", "Sweltering", "Scorching" 18 | }; 19 | 20 | private readonly ILogger _logger; 21 | 22 | public WeatherForecastController(ILogger logger) 23 | { 24 | _logger = logger; 25 | } 26 | 27 | [HttpGet] 28 | public IEnumerable Get() 29 | { 30 | var rng = new Random(); 31 | return Enumerable.Range(1, 5).Select(index => new WeatherForecast 32 | { 33 | Date = DateTime.Now.AddDays(index), 34 | TemperatureC = rng.Next(-20, 55), 35 | Summary = Summaries[rng.Next(Summaries.Length)] 36 | }) 37 | .ToArray(); 38 | } 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /LowCodeAPI/Server/Data/EFControllerBase.cs: -------------------------------------------------------------------------------- 1 | using LowCodeAPI.Server.Data; 2 | using LowCodeAPI.Shared.Models; 3 | using Microsoft.AspNetCore.Mvc; 4 | using Microsoft.EntityFrameworkCore; 5 | using System; 6 | using System.Collections.Generic; 7 | using System.Linq; 8 | using System.Threading.Tasks; 9 | 10 | public class EFControllerBase : ControllerBase 11 | where TEntity : class 12 | where TDataContext : DbContext 13 | { 14 | private EFRepository repository; 15 | 16 | public EFControllerBase(EFRepository _repository) 17 | { 18 | repository = _repository; 19 | } 20 | 21 | [HttpGet] 22 | public async Task>> GetAll() 23 | { 24 | try 25 | { 26 | var result = await repository.GetAll(); 27 | return Ok(new APIListOfEntityResponse() 28 | { 29 | Success = true, 30 | Data = result 31 | }); 32 | } 33 | catch (Exception ex) 34 | { 35 | // log exception here 36 | return StatusCode(500); 37 | } 38 | } 39 | 40 | [HttpGet("{PropertyName}/{Value}/GetByValue")] 41 | public async Task>> GetByValue(string PropertyName, string Value) 42 | { 43 | 44 | await Task.Delay(0); 45 | try 46 | { 47 | var IdProperty = typeof(TEntity).GetProperty(PropertyName); 48 | var result = (from x in repository.dbSet.ToList() 49 | where IdProperty.GetValue(x).ToString().ToLower() == Value.ToLower() 50 | select x).FirstOrDefault(); 51 | if (result != null) 52 | { 53 | return Ok(new APIEntityResponse() 54 | { 55 | Success = true, 56 | Data = result 57 | }); 58 | } 59 | else 60 | { 61 | return Ok(new APIEntityResponse() 62 | { 63 | Success = false, 64 | ErrorMessages = new List() { "Entity Not Found" }, 65 | Data = null 66 | }); 67 | } 68 | } 69 | catch (Exception ex) 70 | { 71 | // log exception here 72 | return StatusCode(500); 73 | } 74 | } 75 | 76 | [HttpGet("{PropertyName}/{Value}/SearchByValue")] 77 | public async Task>> SearchByValue(string PropertyName, string Value) 78 | { 79 | await Task.Delay(0); 80 | try 81 | { 82 | var IdProperty = typeof(TEntity).GetProperty(PropertyName); 83 | var result = (from x in repository.dbSet.ToList() 84 | where IdProperty.GetValue(x).ToString().ToLower().Contains(Value.ToLower()) 85 | select x); 86 | if (result != null) 87 | { 88 | return Ok(new APIListOfEntityResponse() 89 | { 90 | Success = true, 91 | Data = result 92 | }); 93 | } 94 | else 95 | { 96 | return Ok(new APIListOfEntityResponse() 97 | { 98 | Success = false, 99 | ErrorMessages = new List() { "No Entities Found" }, 100 | Data = null 101 | }); 102 | } 103 | } 104 | catch (Exception ex) 105 | { 106 | // log exception here 107 | return StatusCode(500); 108 | } 109 | } 110 | 111 | [HttpPost] 112 | public async Task>> Post([FromBody] TEntity Entity) 113 | { 114 | try 115 | { 116 | await repository.Insert(Entity); 117 | return Ok(new APIEntityResponse() 118 | { 119 | Success = true, 120 | Data = Entity 121 | }); 122 | } 123 | catch (Exception ex) 124 | { 125 | // log exception here 126 | return StatusCode(500); 127 | } 128 | } 129 | 130 | [HttpPut] 131 | public async Task>> Put([FromBody] TEntity Entity) 132 | { 133 | try 134 | { 135 | await repository.Update(Entity); 136 | return Ok(new APIEntityResponse() 137 | { 138 | Success = true, 139 | Data = Entity 140 | }); 141 | } 142 | catch (Exception ex) 143 | { 144 | // log exception here 145 | return StatusCode(500); 146 | } 147 | } 148 | 149 | [HttpDelete("{PropertyName}/{Value}/DeleteByValue")] 150 | public async Task DeleteByValue(string PropertyName, string Value) 151 | { 152 | try 153 | { 154 | var IdProperty = typeof(TEntity).GetProperty(PropertyName); 155 | var entity = (from x in repository.dbSet.ToList() 156 | where IdProperty.GetValue(x).ToString() == Value 157 | select x).FirstOrDefault(); 158 | 159 | if (entity != null) 160 | { 161 | await repository.Delete(entity); 162 | return NoContent(); 163 | } 164 | else 165 | { 166 | return StatusCode(500); 167 | } 168 | } 169 | catch (Exception ex) 170 | { 171 | // log exception here 172 | var msg = ex.Message; 173 | return StatusCode(500); 174 | } 175 | } 176 | } 177 | -------------------------------------------------------------------------------- /LowCodeAPI/Server/Data/EFRepository.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.EntityFrameworkCore; 2 | using LowCodeAPI.Shared.Models; 3 | using System; 4 | using System.Collections.Generic; 5 | using System.Linq; 6 | using System.Linq.Expressions; 7 | using System.Threading.Tasks; 8 | 9 | public class EFRepository : IRepository 10 | where TEntity : class 11 | where TDataContext : DbContext 12 | { 13 | protected readonly TDataContext context; 14 | internal DbSet dbSet; 15 | 16 | public EFRepository(TDataContext dataContext) 17 | { 18 | context = dataContext; 19 | context.ChangeTracker.QueryTrackingBehavior = QueryTrackingBehavior.NoTracking; 20 | dbSet = context.Set(); 21 | } 22 | 23 | public virtual async Task> GetAll() 24 | { 25 | await Task.Delay(1); 26 | return dbSet; 27 | } 28 | 29 | public virtual async Task> Get(Expression> filter = null, Func, IOrderedQueryable> orderBy = null, string includeProperties = "") 30 | { 31 | try 32 | { 33 | // Get the dbSet from the Entity passed in 34 | IQueryable query = dbSet; 35 | 36 | // Apply the filter 37 | if (filter != null) 38 | { 39 | query = query.Where(filter); 40 | } 41 | 42 | // Include the specified properties 43 | foreach (var includeProperty in includeProperties.Split 44 | (new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries)) 45 | { 46 | query = query.Include(includeProperty); 47 | } 48 | 49 | // Sort 50 | if (orderBy != null) 51 | { 52 | return orderBy(query).ToList(); 53 | } 54 | else 55 | { 56 | return await query.ToListAsync(); 57 | } 58 | } 59 | catch (Exception ex) 60 | { 61 | var msg = ex.Message; 62 | return null; 63 | } 64 | } 65 | 66 | public virtual async Task Insert(TEntity entity) 67 | { 68 | await dbSet.AddAsync(entity); 69 | await context.SaveChangesAsync(); 70 | return entity; 71 | } 72 | 73 | public virtual async Task Update(TEntity entityToUpdate) 74 | { 75 | var dbSet = context.Set(); 76 | dbSet.Attach(entityToUpdate); 77 | context.Entry(entityToUpdate).State = EntityState.Modified; 78 | await context.SaveChangesAsync(); 79 | return entityToUpdate; 80 | } 81 | 82 | public virtual async Task Delete(TEntity entityToDelete) 83 | { 84 | if (context.Entry(entityToDelete).State == EntityState.Detached) 85 | { 86 | dbSet.Attach(entityToDelete); 87 | } 88 | dbSet.Remove(entityToDelete); 89 | return await context.SaveChangesAsync() >= 1; 90 | } 91 | } 92 | -------------------------------------------------------------------------------- /LowCodeAPI/Server/Data/pubsContext.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Microsoft.EntityFrameworkCore; 3 | using Microsoft.EntityFrameworkCore.Metadata; 4 | using LowCodeAPI.Shared.Models; 5 | 6 | #nullable disable 7 | 8 | namespace LowCodeAPI.Server.Data 9 | { 10 | public partial class pubsContext : DbContext 11 | { 12 | public pubsContext() 13 | { 14 | } 15 | 16 | public pubsContext(DbContextOptions options) 17 | : base(options) 18 | { 19 | } 20 | 21 | public virtual DbSet Authors { get; set; } 22 | public virtual DbSet Discounts { get; set; } 23 | public virtual DbSet Employees { get; set; } 24 | public virtual DbSet Jobs { get; set; } 25 | public virtual DbSet PubInfos { get; set; } 26 | public virtual DbSet Publishers { get; set; } 27 | public virtual DbSet Royscheds { get; set; } 28 | public virtual DbSet Sales { get; set; } 29 | public virtual DbSet Stores { get; set; } 30 | public virtual DbSet Titles { get; set; } 31 | public virtual DbSet<Titleauthor> Titleauthors { get; set; } 32 | public virtual DbSet<Titleview> Titleviews { get; set; } 33 | 34 | protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) 35 | { 36 | if (!optionsBuilder.IsConfigured) 37 | { 38 | #warning To protect potentially sensitive information in your connection string, you should move it out of source code. You can avoid scaffolding the connection string by using the Name= syntax to read it from configuration - see https://go.microsoft.com/fwlink/?linkid=2131148. For more guidance on storing connection strings, see http://go.microsoft.com/fwlink/?LinkId=723263. 39 | optionsBuilder.UseSqlServer("Data Source=(localdb)\\MSSQLLocalDB;Initial Catalog=pubs"); 40 | } 41 | } 42 | 43 | protected override void OnModelCreating(ModelBuilder modelBuilder) 44 | { 45 | modelBuilder.Entity<Author>(entity => 46 | { 47 | entity.HasKey(e => e.AuId) 48 | .HasName("UPKCL_auidind"); 49 | 50 | entity.ToTable("authors"); 51 | 52 | entity.HasIndex(e => new { e.AuLname, e.AuFname }, "aunmind"); 53 | 54 | entity.Property(e => e.AuId) 55 | .HasMaxLength(11) 56 | .IsUnicode(false) 57 | .HasColumnName("au_id"); 58 | 59 | entity.Property(e => e.Address) 60 | .HasMaxLength(40) 61 | .IsUnicode(false) 62 | .HasColumnName("address"); 63 | 64 | entity.Property(e => e.AuFname) 65 | .IsRequired() 66 | .HasMaxLength(20) 67 | .IsUnicode(false) 68 | .HasColumnName("au_fname"); 69 | 70 | entity.Property(e => e.AuLname) 71 | .IsRequired() 72 | .HasMaxLength(40) 73 | .IsUnicode(false) 74 | .HasColumnName("au_lname"); 75 | 76 | entity.Property(e => e.City) 77 | .HasMaxLength(20) 78 | .IsUnicode(false) 79 | .HasColumnName("city"); 80 | 81 | entity.Property(e => e.Contract).HasColumnName("contract"); 82 | 83 | entity.Property(e => e.Phone) 84 | .IsRequired() 85 | .HasMaxLength(12) 86 | .IsUnicode(false) 87 | .HasColumnName("phone") 88 | .HasDefaultValueSql("('UNKNOWN')") 89 | .IsFixedLength(true); 90 | 91 | entity.Property(e => e.State) 92 | .HasMaxLength(2) 93 | .IsUnicode(false) 94 | .HasColumnName("state") 95 | .IsFixedLength(true); 96 | 97 | entity.Property(e => e.Zip) 98 | .HasMaxLength(5) 99 | .IsUnicode(false) 100 | .HasColumnName("zip") 101 | .IsFixedLength(true); 102 | }); 103 | 104 | modelBuilder.Entity<Discount>(entity => 105 | { 106 | entity.HasNoKey(); 107 | 108 | entity.ToTable("discounts"); 109 | 110 | entity.Property(e => e.Discount1) 111 | .HasColumnType("decimal(4, 2)") 112 | .HasColumnName("discount"); 113 | 114 | entity.Property(e => e.Discounttype) 115 | .IsRequired() 116 | .HasMaxLength(40) 117 | .IsUnicode(false) 118 | .HasColumnName("discounttype"); 119 | 120 | entity.Property(e => e.Highqty).HasColumnName("highqty"); 121 | 122 | entity.Property(e => e.Lowqty).HasColumnName("lowqty"); 123 | 124 | entity.Property(e => e.StorId) 125 | .HasMaxLength(4) 126 | .IsUnicode(false) 127 | .HasColumnName("stor_id") 128 | .IsFixedLength(true); 129 | 130 | entity.HasOne(d => d.Stor) 131 | .WithMany() 132 | .HasForeignKey(d => d.StorId) 133 | .HasConstraintName("FK__discounts__stor___3B75D760"); 134 | }); 135 | 136 | modelBuilder.Entity<Employee>(entity => 137 | { 138 | entity.HasKey(e => e.EmpId) 139 | .HasName("PK_emp_id") 140 | .IsClustered(false); 141 | 142 | entity.ToTable("employee"); 143 | 144 | entity.HasIndex(e => new { e.Lname, e.Fname, e.Minit }, "employee_ind") 145 | .IsClustered(); 146 | 147 | entity.Property(e => e.EmpId) 148 | .HasMaxLength(9) 149 | .IsUnicode(false) 150 | .HasColumnName("emp_id") 151 | .IsFixedLength(true); 152 | 153 | entity.Property(e => e.Fname) 154 | .IsRequired() 155 | .HasMaxLength(20) 156 | .IsUnicode(false) 157 | .HasColumnName("fname"); 158 | 159 | entity.Property(e => e.HireDate) 160 | .HasColumnType("datetime") 161 | .HasColumnName("hire_date") 162 | .HasDefaultValueSql("(getdate())"); 163 | 164 | entity.Property(e => e.JobId) 165 | .HasColumnName("job_id") 166 | .HasDefaultValueSql("((1))"); 167 | 168 | entity.Property(e => e.JobLvl) 169 | .HasColumnName("job_lvl") 170 | .HasDefaultValueSql("((10))"); 171 | 172 | entity.Property(e => e.Lname) 173 | .IsRequired() 174 | .HasMaxLength(30) 175 | .IsUnicode(false) 176 | .HasColumnName("lname"); 177 | 178 | entity.Property(e => e.Minit) 179 | .HasMaxLength(1) 180 | .IsUnicode(false) 181 | .HasColumnName("minit") 182 | .IsFixedLength(true); 183 | 184 | entity.Property(e => e.PubId) 185 | .IsRequired() 186 | .HasMaxLength(4) 187 | .IsUnicode(false) 188 | .HasColumnName("pub_id") 189 | .HasDefaultValueSql("('9952')") 190 | .IsFixedLength(true); 191 | 192 | entity.HasOne(d => d.Job) 193 | .WithMany(p => p.Employees) 194 | .HasForeignKey(d => d.JobId) 195 | .OnDelete(DeleteBehavior.ClientSetNull) 196 | .HasConstraintName("FK__employee__job_id__47DBAE45"); 197 | 198 | entity.HasOne(d => d.Pub) 199 | .WithMany(p => p.Employees) 200 | .HasForeignKey(d => d.PubId) 201 | .OnDelete(DeleteBehavior.ClientSetNull) 202 | .HasConstraintName("FK__employee__pub_id__4AB81AF0"); 203 | }); 204 | 205 | modelBuilder.Entity<Job>(entity => 206 | { 207 | entity.ToTable("jobs"); 208 | 209 | entity.Property(e => e.JobId).HasColumnName("job_id"); 210 | 211 | entity.Property(e => e.JobDesc) 212 | .IsRequired() 213 | .HasMaxLength(50) 214 | .IsUnicode(false) 215 | .HasColumnName("job_desc") 216 | .HasDefaultValueSql("('New Position - title not formalized yet')"); 217 | 218 | entity.Property(e => e.MaxLvl).HasColumnName("max_lvl"); 219 | 220 | entity.Property(e => e.MinLvl).HasColumnName("min_lvl"); 221 | }); 222 | 223 | modelBuilder.Entity<PubInfo>(entity => 224 | { 225 | entity.HasKey(e => e.PubId) 226 | .HasName("UPKCL_pubinfo"); 227 | 228 | entity.ToTable("pub_info"); 229 | 230 | entity.Property(e => e.PubId) 231 | .HasMaxLength(4) 232 | .IsUnicode(false) 233 | .HasColumnName("pub_id") 234 | .IsFixedLength(true); 235 | 236 | entity.Property(e => e.Logo) 237 | .HasColumnType("image") 238 | .HasColumnName("logo"); 239 | 240 | entity.Property(e => e.PrInfo) 241 | .HasColumnType("text") 242 | .HasColumnName("pr_info"); 243 | 244 | entity.HasOne(d => d.Pub) 245 | .WithOne(p => p.PubInfo) 246 | .HasForeignKey<PubInfo>(d => d.PubId) 247 | .OnDelete(DeleteBehavior.ClientSetNull) 248 | .HasConstraintName("FK__pub_info__pub_id__4316F928"); 249 | }); 250 | 251 | modelBuilder.Entity<Publisher>(entity => 252 | { 253 | entity.HasKey(e => e.PubId) 254 | .HasName("UPKCL_pubind"); 255 | 256 | entity.ToTable("publishers"); 257 | 258 | entity.Property(e => e.PubId) 259 | .HasMaxLength(4) 260 | .IsUnicode(false) 261 | .HasColumnName("pub_id") 262 | .IsFixedLength(true); 263 | 264 | entity.Property(e => e.City) 265 | .HasMaxLength(20) 266 | .IsUnicode(false) 267 | .HasColumnName("city"); 268 | 269 | entity.Property(e => e.Country) 270 | .HasMaxLength(30) 271 | .IsUnicode(false) 272 | .HasColumnName("country") 273 | .HasDefaultValueSql("('USA')"); 274 | 275 | entity.Property(e => e.PubName) 276 | .HasMaxLength(40) 277 | .IsUnicode(false) 278 | .HasColumnName("pub_name"); 279 | 280 | entity.Property(e => e.State) 281 | .HasMaxLength(2) 282 | .IsUnicode(false) 283 | .HasColumnName("state") 284 | .IsFixedLength(true); 285 | }); 286 | 287 | modelBuilder.Entity<Roysched>(entity => 288 | { 289 | entity.HasNoKey(); 290 | 291 | entity.ToTable("roysched"); 292 | 293 | entity.HasIndex(e => e.TitleId, "titleidind"); 294 | 295 | entity.Property(e => e.Hirange).HasColumnName("hirange"); 296 | 297 | entity.Property(e => e.Lorange).HasColumnName("lorange"); 298 | 299 | entity.Property(e => e.Royalty).HasColumnName("royalty"); 300 | 301 | entity.Property(e => e.TitleId) 302 | .IsRequired() 303 | .HasMaxLength(6) 304 | .IsUnicode(false) 305 | .HasColumnName("title_id"); 306 | 307 | entity.HasOne(d => d.Title) 308 | .WithMany() 309 | .HasForeignKey(d => d.TitleId) 310 | .OnDelete(DeleteBehavior.ClientSetNull) 311 | .HasConstraintName("FK__roysched__title___398D8EEE"); 312 | }); 313 | 314 | modelBuilder.Entity<Sale>(entity => 315 | { 316 | entity.HasKey(e => new { e.StorId, e.OrdNum, e.TitleId }) 317 | .HasName("UPKCL_sales"); 318 | 319 | entity.ToTable("sales"); 320 | 321 | entity.HasIndex(e => e.TitleId, "titleidind"); 322 | 323 | entity.Property(e => e.StorId) 324 | .HasMaxLength(4) 325 | .IsUnicode(false) 326 | .HasColumnName("stor_id") 327 | .IsFixedLength(true); 328 | 329 | entity.Property(e => e.OrdNum) 330 | .HasMaxLength(20) 331 | .IsUnicode(false) 332 | .HasColumnName("ord_num"); 333 | 334 | entity.Property(e => e.TitleId) 335 | .HasMaxLength(6) 336 | .IsUnicode(false) 337 | .HasColumnName("title_id"); 338 | 339 | entity.Property(e => e.OrdDate) 340 | .HasColumnType("datetime") 341 | .HasColumnName("ord_date"); 342 | 343 | entity.Property(e => e.Payterms) 344 | .IsRequired() 345 | .HasMaxLength(12) 346 | .IsUnicode(false) 347 | .HasColumnName("payterms"); 348 | 349 | entity.Property(e => e.Qty).HasColumnName("qty"); 350 | 351 | entity.HasOne(d => d.Stor) 352 | .WithMany(p => p.Sales) 353 | .HasForeignKey(d => d.StorId) 354 | .OnDelete(DeleteBehavior.ClientSetNull) 355 | .HasConstraintName("FK__sales__stor_id__36B12243"); 356 | 357 | entity.HasOne(d => d.Title) 358 | .WithMany(p => p.Sales) 359 | .HasForeignKey(d => d.TitleId) 360 | .OnDelete(DeleteBehavior.ClientSetNull) 361 | .HasConstraintName("FK__sales__title_id__37A5467C"); 362 | }); 363 | 364 | modelBuilder.Entity<Store>(entity => 365 | { 366 | entity.HasKey(e => e.StorId) 367 | .HasName("UPK_storeid"); 368 | 369 | entity.ToTable("stores"); 370 | 371 | entity.Property(e => e.StorId) 372 | .HasMaxLength(4) 373 | .IsUnicode(false) 374 | .HasColumnName("stor_id") 375 | .IsFixedLength(true); 376 | 377 | entity.Property(e => e.City) 378 | .HasMaxLength(20) 379 | .IsUnicode(false) 380 | .HasColumnName("city"); 381 | 382 | entity.Property(e => e.State) 383 | .HasMaxLength(2) 384 | .IsUnicode(false) 385 | .HasColumnName("state") 386 | .IsFixedLength(true); 387 | 388 | entity.Property(e => e.StorAddress) 389 | .HasMaxLength(40) 390 | .IsUnicode(false) 391 | .HasColumnName("stor_address"); 392 | 393 | entity.Property(e => e.StorName) 394 | .HasMaxLength(40) 395 | .IsUnicode(false) 396 | .HasColumnName("stor_name"); 397 | 398 | entity.Property(e => e.Zip) 399 | .HasMaxLength(5) 400 | .IsUnicode(false) 401 | .HasColumnName("zip") 402 | .IsFixedLength(true); 403 | }); 404 | 405 | modelBuilder.Entity<Title>(entity => 406 | { 407 | entity.ToTable("titles"); 408 | 409 | entity.HasIndex(e => e.Title1, "titleind"); 410 | 411 | entity.Property(e => e.TitleId) 412 | .HasMaxLength(6) 413 | .IsUnicode(false) 414 | .HasColumnName("title_id"); 415 | 416 | entity.Property(e => e.Advance) 417 | .HasColumnType("money") 418 | .HasColumnName("advance"); 419 | 420 | entity.Property(e => e.Notes) 421 | .HasMaxLength(200) 422 | .IsUnicode(false) 423 | .HasColumnName("notes"); 424 | 425 | entity.Property(e => e.Price) 426 | .HasColumnType("money") 427 | .HasColumnName("price"); 428 | 429 | entity.Property(e => e.PubId) 430 | .HasMaxLength(4) 431 | .IsUnicode(false) 432 | .HasColumnName("pub_id") 433 | .IsFixedLength(true); 434 | 435 | entity.Property(e => e.Pubdate) 436 | .HasColumnType("datetime") 437 | .HasColumnName("pubdate") 438 | .HasDefaultValueSql("(getdate())"); 439 | 440 | entity.Property(e => e.Royalty).HasColumnName("royalty"); 441 | 442 | entity.Property(e => e.Title1) 443 | .IsRequired() 444 | .HasMaxLength(80) 445 | .IsUnicode(false) 446 | .HasColumnName("title"); 447 | 448 | entity.Property(e => e.Type) 449 | .IsRequired() 450 | .HasMaxLength(12) 451 | .IsUnicode(false) 452 | .HasColumnName("type") 453 | .HasDefaultValueSql("('UNDECIDED')") 454 | .IsFixedLength(true); 455 | 456 | entity.Property(e => e.YtdSales).HasColumnName("ytd_sales"); 457 | 458 | entity.HasOne(d => d.Pub) 459 | .WithMany(p => p.Titles) 460 | .HasForeignKey(d => d.PubId) 461 | .HasConstraintName("FK__titles__pub_id__2D27B809"); 462 | }); 463 | 464 | modelBuilder.Entity<Titleauthor>(entity => 465 | { 466 | entity.HasKey(e => new { e.AuId, e.TitleId }) 467 | .HasName("UPKCL_taind"); 468 | 469 | entity.ToTable("titleauthor"); 470 | 471 | entity.HasIndex(e => e.AuId, "auidind"); 472 | 473 | entity.HasIndex(e => e.TitleId, "titleidind"); 474 | 475 | entity.Property(e => e.AuId) 476 | .HasMaxLength(11) 477 | .IsUnicode(false) 478 | .HasColumnName("au_id"); 479 | 480 | entity.Property(e => e.TitleId) 481 | .HasMaxLength(6) 482 | .IsUnicode(false) 483 | .HasColumnName("title_id"); 484 | 485 | entity.Property(e => e.AuOrd).HasColumnName("au_ord"); 486 | 487 | entity.Property(e => e.Royaltyper).HasColumnName("royaltyper"); 488 | 489 | entity.HasOne(d => d.Au) 490 | .WithMany(p => p.Titleauthors) 491 | .HasForeignKey(d => d.AuId) 492 | .OnDelete(DeleteBehavior.ClientSetNull) 493 | .HasConstraintName("FK__titleauth__au_id__30F848ED"); 494 | 495 | entity.HasOne(d => d.Title) 496 | .WithMany(p => p.Titleauthors) 497 | .HasForeignKey(d => d.TitleId) 498 | .OnDelete(DeleteBehavior.ClientSetNull) 499 | .HasConstraintName("FK__titleauth__title__31EC6D26"); 500 | }); 501 | 502 | modelBuilder.Entity<Titleview>(entity => 503 | { 504 | entity.HasNoKey(); 505 | 506 | entity.ToView("titleview"); 507 | 508 | entity.Property(e => e.AuLname) 509 | .IsRequired() 510 | .HasMaxLength(40) 511 | .IsUnicode(false) 512 | .HasColumnName("au_lname"); 513 | 514 | entity.Property(e => e.AuOrd).HasColumnName("au_ord"); 515 | 516 | entity.Property(e => e.Price) 517 | .HasColumnType("money") 518 | .HasColumnName("price"); 519 | 520 | entity.Property(e => e.PubId) 521 | .HasMaxLength(4) 522 | .IsUnicode(false) 523 | .HasColumnName("pub_id") 524 | .IsFixedLength(true); 525 | 526 | entity.Property(e => e.Title) 527 | .IsRequired() 528 | .HasMaxLength(80) 529 | .IsUnicode(false) 530 | .HasColumnName("title"); 531 | 532 | entity.Property(e => e.YtdSales).HasColumnName("ytd_sales"); 533 | }); 534 | 535 | OnModelCreatingPartial(modelBuilder); 536 | } 537 | 538 | partial void OnModelCreatingPartial(ModelBuilder modelBuilder); 539 | } 540 | } 541 | -------------------------------------------------------------------------------- /LowCodeAPI/Server/LowCodeAPI.Server.csproj: -------------------------------------------------------------------------------- 1 | <Project Sdk="Microsoft.NET.Sdk.Web"> 2 | 3 | <PropertyGroup> 4 | <TargetFramework>net5.0</TargetFramework> 5 | </PropertyGroup> 6 | 7 | <ItemGroup> 8 | <PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.Server" Version="5.0.7" /> 9 | <PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="5.0.0" /> 10 | <PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="5.0.0" /> 11 | <PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="5.0.0" /> 12 | </ItemGroup> 13 | 14 | <ItemGroup> 15 | <ProjectReference Include="..\Client\LowCodeAPI.Client.csproj" /> 16 | <ProjectReference Include="..\Shared\LowCodeAPI.Shared.csproj" /> 17 | </ItemGroup> 18 | 19 | 20 | </Project> 21 | -------------------------------------------------------------------------------- /LowCodeAPI/Server/Pages/Error.cshtml: -------------------------------------------------------------------------------- 1 | @page 2 | @model LowCodeAPI.Server.Pages.ErrorModel 3 | 4 | <!DOCTYPE html> 5 | <html> 6 | 7 | <head> 8 | <meta charset="utf-8" /> 9 | <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" /> 10 | <title>Error 11 | 12 | 13 | 14 | 15 | 16 |
17 |
18 |

Error.

19 |

An error occurred while processing your request.

20 | 21 | @if (Model.ShowRequestId) 22 | { 23 |

24 | Request ID: @Model.RequestId 25 |

26 | } 27 | 28 |

Development Mode

29 |

30 | Swapping to the Development environment displays detailed information about the error that occurred. 31 |

32 |

33 | The Development environment shouldn't be enabled for deployed applications. 34 | It can result in displaying sensitive information from exceptions to end users. 35 | For local debugging, enable the Development environment by setting the ASPNETCORE_ENVIRONMENT environment variable to Development 36 | and restarting the app. 37 |

38 |
39 |
40 | 41 | 42 | 43 | -------------------------------------------------------------------------------- /LowCodeAPI/Server/Pages/Error.cshtml.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.AspNetCore.Mvc; 2 | using Microsoft.AspNetCore.Mvc.RazorPages; 3 | using Microsoft.Extensions.Logging; 4 | using System; 5 | using System.Collections.Generic; 6 | using System.Diagnostics; 7 | using System.Linq; 8 | using System.Threading.Tasks; 9 | 10 | namespace LowCodeAPI.Server.Pages 11 | { 12 | [ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)] 13 | [IgnoreAntiforgeryToken] 14 | public class ErrorModel : PageModel 15 | { 16 | public string RequestId { get; set; } 17 | 18 | public bool ShowRequestId => !string.IsNullOrEmpty(RequestId); 19 | 20 | private readonly ILogger _logger; 21 | 22 | public ErrorModel(ILogger logger) 23 | { 24 | _logger = logger; 25 | } 26 | 27 | public void OnGet() 28 | { 29 | RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier; 30 | } 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /LowCodeAPI/Server/Program.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.AspNetCore.Hosting; 2 | using Microsoft.Extensions.Configuration; 3 | using Microsoft.Extensions.Hosting; 4 | using Microsoft.Extensions.Logging; 5 | using System; 6 | using System.Collections.Generic; 7 | using System.Linq; 8 | using System.Threading.Tasks; 9 | 10 | namespace LowCodeAPI.Server 11 | { 12 | public class Program 13 | { 14 | public static void Main(string[] args) 15 | { 16 | CreateHostBuilder(args).Build().Run(); 17 | } 18 | 19 | public static IHostBuilder CreateHostBuilder(string[] args) => 20 | Host.CreateDefaultBuilder(args) 21 | .ConfigureWebHostDefaults(webBuilder => 22 | { 23 | webBuilder.UseStartup(); 24 | }); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /LowCodeAPI/Server/Properties/launchSettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "iisSettings": { 3 | "windowsAuthentication": false, 4 | "anonymousAuthentication": true, 5 | "iisExpress": { 6 | "applicationUrl": "http://localhost:32091", 7 | "sslPort": 44347 8 | } 9 | }, 10 | "profiles": { 11 | "IIS Express": { 12 | "commandName": "IISExpress", 13 | "launchBrowser": true, 14 | "inspectUri": "{wsProtocol}://{url.hostname}:{url.port}/_framework/debug/ws-proxy?browser={browserInspectUri}", 15 | "environmentVariables": { 16 | "ASPNETCORE_ENVIRONMENT": "Development" 17 | } 18 | }, 19 | "LowCodeAPI.Server": { 20 | "commandName": "Project", 21 | "dotnetRunMessages": "true", 22 | "launchBrowser": true, 23 | "inspectUri": "{wsProtocol}://{url.hostname}:{url.port}/_framework/debug/ws-proxy?browser={browserInspectUri}", 24 | "applicationUrl": "https://localhost:5001;http://localhost:5000", 25 | "environmentVariables": { 26 | "ASPNETCORE_ENVIRONMENT": "Development" 27 | } 28 | } 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /LowCodeAPI/Server/Startup.cs: -------------------------------------------------------------------------------- 1 | using LowCodeAPI.Shared.Models; 2 | using LowCodeAPI.Server.Data; 3 | using Microsoft.AspNetCore.Builder; 4 | using Microsoft.AspNetCore.Hosting; 5 | using Microsoft.AspNetCore.HttpsPolicy; 6 | using Microsoft.AspNetCore.ResponseCompression; 7 | using Microsoft.Extensions.Configuration; 8 | using Microsoft.Extensions.DependencyInjection; 9 | using Microsoft.Extensions.Hosting; 10 | using System.Linq; 11 | 12 | namespace LowCodeAPI.Server 13 | { 14 | public class Startup 15 | { 16 | public Startup(IConfiguration configuration) 17 | { 18 | Configuration = configuration; 19 | } 20 | 21 | public IConfiguration Configuration { get; } 22 | 23 | // This method gets called by the runtime. Use this method to add services to the container. 24 | // For more information on how to configure your application, visit https://go.microsoft.com/fwlink/?LinkID=398940 25 | public void ConfigureServices(IServiceCollection services) 26 | { 27 | // First, add the dbContext 28 | services.AddTransient(); 29 | 30 | // Next, add an EFRepository for each model you want a controller for 31 | services.AddTransient>(); 32 | 33 | services.AddControllersWithViews(); 34 | services.AddRazorPages(); 35 | } 36 | 37 | // This method gets called by the runtime. Use this method to configure the HTTP request pipeline. 38 | public void Configure(IApplicationBuilder app, IWebHostEnvironment env) 39 | { 40 | if (env.IsDevelopment()) 41 | { 42 | app.UseDeveloperExceptionPage(); 43 | app.UseWebAssemblyDebugging(); 44 | } 45 | else 46 | { 47 | app.UseExceptionHandler("/Error"); 48 | // The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts. 49 | app.UseHsts(); 50 | } 51 | 52 | app.UseHttpsRedirection(); 53 | app.UseBlazorFrameworkFiles(); 54 | app.UseStaticFiles(); 55 | 56 | app.UseRouting(); 57 | 58 | app.UseEndpoints(endpoints => 59 | { 60 | endpoints.MapRazorPages(); 61 | endpoints.MapControllers(); 62 | endpoints.MapFallbackToFile("index.html"); 63 | }); 64 | } 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /LowCodeAPI/Server/appsettings.Development.json: -------------------------------------------------------------------------------- 1 | { 2 | "Logging": { 3 | "LogLevel": { 4 | "Default": "Information", 5 | "Microsoft": "Warning", 6 | "Microsoft.Hosting.Lifetime": "Information" 7 | } 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /LowCodeAPI/Server/appsettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "Logging": { 3 | "LogLevel": { 4 | "Default": "Information", 5 | "Microsoft": "Warning", 6 | "Microsoft.Hosting.Lifetime": "Information" 7 | } 8 | }, 9 | "AllowedHosts": "*" 10 | } 11 | -------------------------------------------------------------------------------- /LowCodeAPI/Shared/LowCodeAPI.Shared.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | net5.0 5 | 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /LowCodeAPI/Shared/Models/APIEntityResponse.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | public class APIEntityResponse where TEntity : class 6 | { 7 | public bool Success { get; set; } 8 | public List ErrorMessages { get; set; } = new List(); 9 | public TEntity Data { get; set; } 10 | } 11 | -------------------------------------------------------------------------------- /LowCodeAPI/Shared/Models/APIListOfEntityResponse.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | public class APIListOfEntityResponse where TEntity : class 6 | { 7 | public bool Success { get; set; } 8 | public List ErrorMessages { get; set; } = new List(); 9 | public IEnumerable Data { get; set; } 10 | } 11 | -------------------------------------------------------------------------------- /LowCodeAPI/Shared/Models/Author.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | 4 | #nullable disable 5 | 6 | namespace LowCodeAPI.Shared.Models 7 | { 8 | public partial class Author 9 | { 10 | public Author() 11 | { 12 | Titleauthors = new HashSet(); 13 | } 14 | 15 | public string AuId { get; set; } 16 | public string AuLname { get; set; } 17 | public string AuFname { get; set; } 18 | public string Phone { get; set; } 19 | public string Address { get; set; } 20 | public string City { get; set; } 21 | public string State { get; set; } 22 | public string Zip { get; set; } 23 | public bool Contract { get; set; } 24 | 25 | public virtual ICollection Titleauthors { get; set; } 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /LowCodeAPI/Shared/Models/Discount.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | 4 | #nullable disable 5 | 6 | namespace LowCodeAPI.Shared.Models 7 | { 8 | public partial class Discount 9 | { 10 | public string Discounttype { get; set; } 11 | public string StorId { get; set; } 12 | public short? Lowqty { get; set; } 13 | public short? Highqty { get; set; } 14 | public decimal Discount1 { get; set; } 15 | 16 | public virtual Store Stor { get; set; } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /LowCodeAPI/Shared/Models/Employee.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | 4 | #nullable disable 5 | 6 | namespace LowCodeAPI.Shared.Models 7 | { 8 | public partial class Employee 9 | { 10 | public string EmpId { get; set; } 11 | public string Fname { get; set; } 12 | public string Minit { get; set; } 13 | public string Lname { get; set; } 14 | public short JobId { get; set; } 15 | public byte? JobLvl { get; set; } 16 | public string PubId { get; set; } 17 | public DateTime HireDate { get; set; } 18 | 19 | public virtual Job Job { get; set; } 20 | public virtual Publisher Pub { get; set; } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /LowCodeAPI/Shared/Models/IRepository.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Linq.Expressions; 5 | using System.Text; 6 | using System.Threading.Tasks; 7 | 8 | public interface IRepository where TEntity : class 9 | { 10 | Task> GetAll(); 11 | Task> Get( 12 | Expression> filter = null, 13 | Func, IOrderedQueryable> orderBy = null, 14 | string includeProperties = ""); 15 | Task Insert(TEntity entity); 16 | Task Update(TEntity entityToUpdate); 17 | Task Delete(TEntity entityToDelete); 18 | } 19 | -------------------------------------------------------------------------------- /LowCodeAPI/Shared/Models/Job.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | 4 | #nullable disable 5 | 6 | namespace LowCodeAPI.Shared.Models 7 | { 8 | public partial class Job 9 | { 10 | public Job() 11 | { 12 | Employees = new HashSet(); 13 | } 14 | 15 | public short JobId { get; set; } 16 | public string JobDesc { get; set; } 17 | public byte MinLvl { get; set; } 18 | public byte MaxLvl { get; set; } 19 | 20 | public virtual ICollection Employees { get; set; } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /LowCodeAPI/Shared/Models/PubInfo.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | 4 | #nullable disable 5 | 6 | namespace LowCodeAPI.Shared.Models 7 | { 8 | public partial class PubInfo 9 | { 10 | public string PubId { get; set; } 11 | public byte[] Logo { get; set; } 12 | public string PrInfo { get; set; } 13 | 14 | public virtual Publisher Pub { get; set; } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /LowCodeAPI/Shared/Models/Publisher.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | 4 | #nullable disable 5 | 6 | namespace LowCodeAPI.Shared.Models 7 | { 8 | public partial class Publisher 9 | { 10 | public Publisher() 11 | { 12 | Employees = new HashSet(); 13 | Titles = new HashSet(); 14 | } 15 | 16 | public string PubId { get; set; } 17 | public string PubName { get; set; } 18 | public string City { get; set; } 19 | public string State { get; set; } 20 | public string Country { get; set; } 21 | 22 | public virtual PubInfo PubInfo { get; set; } 23 | public virtual ICollection<Employee> Employees { get; set; } 24 | public virtual ICollection<Title> Titles { get; set; } 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /LowCodeAPI/Shared/Models/Roysched.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | 4 | #nullable disable 5 | 6 | namespace LowCodeAPI.Shared.Models 7 | { 8 | public partial class Roysched 9 | { 10 | public string TitleId { get; set; } 11 | public int? Lorange { get; set; } 12 | public int? Hirange { get; set; } 13 | public int? Royalty { get; set; } 14 | 15 | public virtual Title Title { get; set; } 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /LowCodeAPI/Shared/Models/Sale.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | 4 | #nullable disable 5 | 6 | namespace LowCodeAPI.Shared.Models 7 | { 8 | public partial class Sale 9 | { 10 | public string StorId { get; set; } 11 | public string OrdNum { get; set; } 12 | public DateTime OrdDate { get; set; } 13 | public short Qty { get; set; } 14 | public string Payterms { get; set; } 15 | public string TitleId { get; set; } 16 | 17 | public virtual Store Stor { get; set; } 18 | public virtual Title Title { get; set; } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /LowCodeAPI/Shared/Models/Store.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | 4 | #nullable disable 5 | 6 | namespace LowCodeAPI.Shared.Models 7 | { 8 | public partial class Store 9 | { 10 | public Store() 11 | { 12 | Sales = new HashSet<Sale>(); 13 | } 14 | 15 | public string StorId { get; set; } 16 | public string StorName { get; set; } 17 | public string StorAddress { get; set; } 18 | public string City { get; set; } 19 | public string State { get; set; } 20 | public string Zip { get; set; } 21 | 22 | public virtual ICollection<Sale> Sales { get; set; } 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /LowCodeAPI/Shared/Models/Title.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | 4 | #nullable disable 5 | 6 | namespace LowCodeAPI.Shared.Models 7 | { 8 | public partial class Title 9 | { 10 | public Title() 11 | { 12 | Sales = new HashSet<Sale>(); 13 | Titleauthors = new HashSet<Titleauthor>(); 14 | } 15 | 16 | public string TitleId { get; set; } 17 | public string Title1 { get; set; } 18 | public string Type { get; set; } 19 | public string PubId { get; set; } 20 | public decimal? Price { get; set; } 21 | public decimal? Advance { get; set; } 22 | public int? Royalty { get; set; } 23 | public int? YtdSales { get; set; } 24 | public string Notes { get; set; } 25 | public DateTime Pubdate { get; set; } 26 | 27 | public virtual Publisher Pub { get; set; } 28 | public virtual ICollection<Sale> Sales { get; set; } 29 | public virtual ICollection<Titleauthor> Titleauthors { get; set; } 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /LowCodeAPI/Shared/Models/Titleauthor.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | 4 | #nullable disable 5 | 6 | namespace LowCodeAPI.Shared.Models 7 | { 8 | public partial class Titleauthor 9 | { 10 | public string AuId { get; set; } 11 | public string TitleId { get; set; } 12 | public byte? AuOrd { get; set; } 13 | public int? Royaltyper { get; set; } 14 | 15 | public virtual Author Au { get; set; } 16 | public virtual Title Title { get; set; } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /LowCodeAPI/Shared/Models/Titleview.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | 4 | #nullable disable 5 | 6 | namespace LowCodeAPI.Shared.Models 7 | { 8 | public partial class Titleview 9 | { 10 | public string Title { get; set; } 11 | public byte? AuOrd { get; set; } 12 | public string AuLname { get; set; } 13 | public decimal? Price { get; set; } 14 | public int? YtdSales { get; set; } 15 | public string PubId { get; set; } 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /LowCodeAPI/Shared/WeatherForecast.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace LowCodeAPI.Shared 6 | { 7 | public class WeatherForecast 8 | { 9 | public DateTime Date { get; set; } 10 | 11 | public int TemperatureC { get; set; } 12 | 13 | public string Summary { get; set; } 14 | 15 | public int TemperatureF => 32 + (int)(TemperatureC / 0.5556); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Low Code API 2 | 3 | LowCodeAPI is a set of .NET 5 classes and interfaces that reduce the amount of boilerplate code necessary for any ASP.NET web project. 4 | 5 | > ## **Warning: It is not recommended to expose your EF Entities directly to the client. This is a demo of how to generate controllers for in-house applications only. Do not use it for public applications.** 6 | 7 | ## Sample App 8 | 9 | This repo not only has the generic files you will need, but also a sample Blazor WebAssembly app. You do not need to run the Sample App to use the framework. If you just want to get to the goods, skip over the steps to run the sample app. 10 | 11 | ### Sample App Instructions: 12 | 13 | #### Step 1 - Create a "pubs" database in LocalDB 14 | 15 | <img src="md-images/image-20210707140142879.png" alt="image-20210707140142879" style="zoom: 80%;" /> 16 | 17 | Use the **SQL Server Object Explorer** (or your favorite SQL Manager) to create a new database called "pubs" 18 | 19 | #### Step 2 - Execute the *pubs.sql* script to generate the database 20 | 21 | This script is in the repo, and was downloaded from https://github.com/microsoft/sql-server-samples/blob/master/samples/databases/northwind-pubs/instpubs.sql 22 | 23 | #### Option - Generate the models and dbContext in your own app 24 | 25 | The sample app already has the models and dbContext, but if you want to generate them for your own project, you can follow the instructions at https://docs.microsoft.com/en-us/ef/core/cli/dotnet 26 | 27 | - Make sure you have these packages in your Server project's *.csproj* file: 28 | 29 | ``` 30 | <PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="5.0.0" /> 31 | <PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="5.0.0" /> 32 | <PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="5.0.0" /> 33 | ``` 34 | 35 | - Open a command window in the *Server* project directory and execute this command: 36 | 37 | ``` 38 | dotnet ef dbcontext scaffold "Data Source=(localdb)\MSSQLLocalDB;Initial Catalog=pubs" Microsoft.EntityFrameworkCore.SqlServer --context-dir Data --output-dir Models 39 | ``` 40 | 41 | - If you get an error you may need to install the dotnet-ef CLI tool: 42 | 43 | ``` 44 | dotnet tool install --global dotnet-ef 45 | ``` 46 | 47 | - Move the *Models* folder and the model files out of the *Server* project and into the *Shared* project. 48 | 49 | - Rename the namespaces in each model accordingly. 50 | 51 | - Rename the models namespace in the `dbContext` file (*pubsContext.cs*)": 52 | 53 | ```c# 54 | using LowCodeAPI.Shared.Models; 55 | ``` 56 | 57 | 58 | 59 | ## LowCodeAPI Required Files 60 | 61 | Once you have a project with models and a `dbContext`, you can start building out the API Layer. The following files are not model or dbContext-specific. 62 | 63 | ### IRepository.cs 64 | 65 | Everything starts with this interface, which goes in the *Shared* project's *Models* folder 66 | 67 | ```c# 68 | using System; 69 | using System.Collections.Generic; 70 | using System.Linq; 71 | using System.Linq.Expressions; 72 | using System.Text; 73 | using System.Threading.Tasks; 74 | 75 | public interface IRepository<TEntity> where TEntity : class 76 | { 77 | Task<IEnumerable<TEntity>> GetAll(); 78 | Task<IEnumerable<TEntity>> Get( 79 | Expression<Func<TEntity, bool>> filter = null, 80 | Func<IQueryable<TEntity>, IOrderedQueryable<TEntity>> orderBy = null, 81 | string includeProperties = ""); 82 | Task<TEntity> Insert(TEntity entity); 83 | Task<TEntity> Update(TEntity entityToUpdate); 84 | Task<bool> Delete(TEntity entityToDelete); 85 | } 86 | ``` 87 | 88 | The `IRepository` interface has everything you need for basic CRUD actions. It is generic, accepting an entity type `TEntity`. 89 | 90 | ### EFRepository.cs 91 | 92 | This is an implementation of `IRepository` that uses an Entity Framework dbContext. It can be re-used for any dbContext and entity. This goes in the *Server* project's *Data* folder. 93 | 94 | ```c# 95 | using Microsoft.EntityFrameworkCore; 96 | using LowCodeAPI.Shared.Models; 97 | using System; 98 | using System.Collections.Generic; 99 | using System.Linq; 100 | using System.Linq.Expressions; 101 | using System.Threading.Tasks; 102 | 103 | public class EFRepository<TEntity, TDataContext> : IRepository<TEntity> 104 | where TEntity : class 105 | where TDataContext : DbContext 106 | { 107 | protected readonly TDataContext context; 108 | internal DbSet<TEntity> dbSet; 109 | 110 | public EFRepository(TDataContext dataContext) 111 | { 112 | context = dataContext; 113 | context.ChangeTracker.QueryTrackingBehavior = QueryTrackingBehavior.NoTracking; 114 | dbSet = context.Set<TEntity>(); 115 | } 116 | 117 | public virtual async Task<IEnumerable<TEntity>> GetAll() 118 | { 119 | await Task.Delay(1); 120 | return dbSet; 121 | } 122 | 123 | public virtual async Task<IEnumerable<TEntity>> Get(Expression<Func<TEntity, bool>> filter = null, Func<IQueryable<TEntity>, IOrderedQueryable<TEntity>> orderBy = null, string includeProperties = "") 124 | { 125 | try 126 | { 127 | // Get the dbSet from the Entity passed in 128 | IQueryable<TEntity> query = dbSet; 129 | 130 | // Apply the filter 131 | if (filter != null) 132 | { 133 | query = query.Where(filter); 134 | } 135 | 136 | // Include the specified properties 137 | foreach (var includeProperty in includeProperties.Split 138 | (new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries)) 139 | { 140 | query = query.Include(includeProperty); 141 | } 142 | 143 | // Sort 144 | if (orderBy != null) 145 | { 146 | return orderBy(query).ToList(); 147 | } 148 | else 149 | { 150 | return await query.ToListAsync(); 151 | } 152 | } 153 | catch (Exception ex) 154 | { 155 | var msg = ex.Message; 156 | return null; 157 | } 158 | } 159 | 160 | public virtual async Task<TEntity> Insert(TEntity entity) 161 | { 162 | await dbSet.AddAsync(entity); 163 | await context.SaveChangesAsync(); 164 | return entity; 165 | } 166 | 167 | public virtual async Task<TEntity> Update(TEntity entityToUpdate) 168 | { 169 | var dbSet = context.Set<TEntity>(); 170 | dbSet.Attach(entityToUpdate); 171 | context.Entry(entityToUpdate).State = EntityState.Modified; 172 | await context.SaveChangesAsync(); 173 | return entityToUpdate; 174 | } 175 | 176 | public virtual async Task<bool> Delete(TEntity entityToDelete) 177 | { 178 | if (context.Entry(entityToDelete).State == EntityState.Detached) 179 | { 180 | dbSet.Attach(entityToDelete); 181 | } 182 | dbSet.Remove(entityToDelete); 183 | return await context.SaveChangesAsync() >= 1; 184 | } 185 | } 186 | ``` 187 | 188 | ### APIEntityResponse.cs 189 | 190 | This class is returned by any API Controller Endpoint that returns a single entity. It exists in the *Shared* project's *Models* folder. 191 | 192 | ```c# 193 | using System; 194 | using System.Collections.Generic; 195 | using System.Text; 196 | 197 | public class APIEntityResponse<TEntity> where TEntity : class 198 | { 199 | public bool Success { get; set; } 200 | public List<string> ErrorMessages { get; set; } = new List<string>(); 201 | public TEntity Data { get; set; } 202 | } 203 | ``` 204 | 205 | ### APIListOfEntityResponse.cs 206 | 207 | This class is returned by any API Controller Endpoint that returns a list of entities. It exists in the *Shared* project's *Models* folder. 208 | 209 | ```c# 210 | using System; 211 | using System.Collections.Generic; 212 | using System.Text; 213 | 214 | public class APIListOfEntityResponse<TEntity> where TEntity : class 215 | { 216 | public bool Success { get; set; } 217 | public List<string> ErrorMessages { get; set; } = new List<string>(); 218 | public IEnumerable<TEntity> Data { get; set; } 219 | } 220 | ``` 221 | 222 | ### EFControllerBase.cs 223 | 224 | This base class is used for all API Controllers that are based on a model (`TEntity`). Note that there are two endpoints not in the `IRepository` interface, `GetByValue` and `SearchByValue`. The fact is, we can't use the `IRepository` interface, because the return types are specific to API endpoints: `APIEntityResponse` and `APIListOfEntityResponse`. 225 | 226 | ```c# 227 | using LowCodeAPI.Server.Data; 228 | using LowCodeAPI.Shared.Models; 229 | using Microsoft.AspNetCore.Mvc; 230 | using Microsoft.EntityFrameworkCore; 231 | using System; 232 | using System.Collections.Generic; 233 | using System.Linq; 234 | using System.Threading.Tasks; 235 | 236 | public class EFControllerBase<TEntity, TDataContext> : ControllerBase 237 | where TEntity : class 238 | where TDataContext : DbContext 239 | { 240 | private EFRepository<TEntity, TDataContext> repository; 241 | 242 | public EFControllerBase(EFRepository<TEntity, TDataContext> _repository) 243 | { 244 | repository = _repository; 245 | } 246 | 247 | [HttpGet] 248 | public async Task<ActionResult<APIListOfEntityResponse<TEntity>>> GetAll() 249 | { 250 | try 251 | { 252 | var result = await repository.GetAll(); 253 | return Ok(new APIListOfEntityResponse<TEntity>() 254 | { 255 | Success = true, 256 | Data = result 257 | }); 258 | } 259 | catch (Exception ex) 260 | { 261 | // log exception here 262 | return StatusCode(500); 263 | } 264 | } 265 | 266 | [HttpGet("{PropertyName}/{Value}/GetByValue")] 267 | public async Task<ActionResult<APIEntityResponse<TEntity>>> GetByValue(string PropertyName, string Value) 268 | { 269 | 270 | await Task.Delay(0); 271 | try 272 | { 273 | var IdProperty = typeof(TEntity).GetProperty(PropertyName); 274 | var result = (from x in repository.dbSet.ToList() 275 | where IdProperty.GetValue(x).ToString().ToLower() == Value.ToLower() 276 | select x).FirstOrDefault(); 277 | if (result != null) 278 | { 279 | return Ok(new APIEntityResponse<TEntity>() 280 | { 281 | Success = true, 282 | Data = result 283 | }); 284 | } 285 | else 286 | { 287 | return Ok(new APIEntityResponse<TEntity>() 288 | { 289 | Success = false, 290 | ErrorMessages = new List<string>() { "Entity Not Found" }, 291 | Data = null 292 | }); 293 | } 294 | } 295 | catch (Exception ex) 296 | { 297 | // log exception here 298 | return StatusCode(500); 299 | } 300 | } 301 | 302 | [HttpGet("{PropertyName}/{Value}/SearchByValue")] 303 | public async Task<ActionResult<APIListOfEntityResponse<TEntity>>> SearchByValue(string PropertyName, string Value) 304 | { 305 | await Task.Delay(0); 306 | try 307 | { 308 | var IdProperty = typeof(TEntity).GetProperty(PropertyName); 309 | var result = (from x in repository.dbSet.ToList() 310 | where IdProperty.GetValue(x).ToString().ToLower().Contains(Value.ToLower()) 311 | select x); 312 | if (result != null) 313 | { 314 | return Ok(new APIListOfEntityResponse<TEntity>() 315 | { 316 | Success = true, 317 | Data = result 318 | }); 319 | } 320 | else 321 | { 322 | return Ok(new APIListOfEntityResponse<TEntity>() 323 | { 324 | Success = false, 325 | ErrorMessages = new List<string>() { "No Entities Found" }, 326 | Data = null 327 | }); 328 | } 329 | } 330 | catch (Exception ex) 331 | { 332 | // log exception here 333 | return StatusCode(500); 334 | } 335 | } 336 | 337 | [HttpPost] 338 | public async Task<ActionResult<APIEntityResponse<TEntity>>> Post([FromBody] TEntity Entity) 339 | { 340 | try 341 | { 342 | await repository.Insert(Entity); 343 | return Ok(new APIEntityResponse<TEntity>() 344 | { 345 | Success = true, 346 | Data = Entity 347 | }); 348 | } 349 | catch (Exception ex) 350 | { 351 | // log exception here 352 | return StatusCode(500); 353 | } 354 | } 355 | 356 | [HttpPut] 357 | public async Task<ActionResult<APIEntityResponse<TEntity>>> Put([FromBody] TEntity Entity) 358 | { 359 | try 360 | { 361 | await repository.Update(Entity); 362 | return Ok(new APIEntityResponse<TEntity>() 363 | { 364 | Success = true, 365 | Data = Entity 366 | }); 367 | } 368 | catch (Exception ex) 369 | { 370 | // log exception here 371 | return StatusCode(500); 372 | } 373 | } 374 | 375 | [HttpDelete("{PropertyName}/{Value}/DeleteByValue")] 376 | public async Task<ActionResult> DeleteByValue(string PropertyName, string Value) 377 | { 378 | try 379 | { 380 | var IdProperty = typeof(TEntity).GetProperty(PropertyName); 381 | var entity = (from x in repository.dbSet.ToList() 382 | where IdProperty.GetValue(x).ToString() == Value 383 | select x).FirstOrDefault(); 384 | 385 | if (entity != null) 386 | { 387 | await repository.Delete(entity); 388 | return NoContent(); 389 | } 390 | else 391 | { 392 | return StatusCode(500); 393 | } 394 | } 395 | catch (Exception ex) 396 | { 397 | // log exception here 398 | var msg = ex.Message; 399 | return StatusCode(500); 400 | } 401 | } 402 | } 403 | ``` 404 | 405 | ### APIRepository.cs 406 | 407 | This implementation of `IRepository` goes in the *Client* project's *Services* folder. It can be re-used to access any controller. You will need to install the latest `Newtonsoft.Json` package. 408 | 409 | ```c# 410 | using System; 411 | using System.Collections.Generic; 412 | using System.Threading.Tasks; 413 | using LowCodeAPI.Shared.Models; 414 | using System.Net.Http; 415 | using System.Net.Http.Json; 416 | using Newtonsoft.Json; 417 | using System.Net; 418 | using System.Linq.Expressions; 419 | using System.Linq; 420 | 421 | /// <summary> 422 | /// Reusable API Repository base class that provides access to CRUD APIs 423 | /// </summary> 424 | /// <typeparam name="TEntity"></typeparam> 425 | public class APIRepository<TEntity> : IRepository<TEntity> 426 | where TEntity : class 427 | { 428 | string controllerName; 429 | string primaryKeyName; 430 | HttpClient http; 431 | 432 | public APIRepository(HttpClient _http, string _controllerName, string _primaryKeyName) 433 | { 434 | http = _http; 435 | controllerName = _controllerName; 436 | primaryKeyName = _primaryKeyName; 437 | } 438 | 439 | 440 | public async Task<IEnumerable<TEntity>> GetAll() 441 | { 442 | try 443 | { 444 | var result = await http.GetAsync(controllerName); 445 | result.EnsureSuccessStatusCode(); 446 | string responseBody = await result.Content.ReadAsStringAsync(); 447 | var response = JsonConvert.DeserializeObject<APIListOfEntityResponse<TEntity>>(responseBody); 448 | if (response.Success) 449 | return response.Data; 450 | else 451 | return new List<TEntity>(); 452 | } 453 | catch (Exception ex) 454 | { 455 | var msg = ex.Message; 456 | return null; 457 | } 458 | } 459 | 460 | public Task<IEnumerable<TEntity>> Get(Expression<Func<TEntity, bool>> filter = null, Func<IQueryable<TEntity>, IOrderedQueryable<TEntity>> orderBy = null, string includeProperties = "") 461 | { 462 | throw new NotImplementedException(); 463 | } 464 | 465 | public async Task<TEntity> GetByValue(string PropertyName, string Value) 466 | { 467 | try 468 | { 469 | 470 | var url = $"{controllerName}/{WebUtility.HtmlEncode(PropertyName)}/{WebUtility.HtmlEncode(Value)}/GetByValue"; 471 | var result = await http.GetAsync(url); 472 | result.EnsureSuccessStatusCode(); 473 | string responseBody = await result.Content.ReadAsStringAsync(); 474 | var response = JsonConvert.DeserializeObject<APIEntityResponse<TEntity>>(responseBody); 475 | if (response.Success) 476 | return response.Data; 477 | else 478 | return null; 479 | } 480 | catch (Exception ex) 481 | { 482 | var msg = ex.Message; 483 | return null; 484 | } 485 | } 486 | 487 | public async Task<IEnumerable<TEntity>> SearchByValue(string PropertyName, string Value) 488 | { 489 | try 490 | { 491 | var url = $"{controllerName}/{WebUtility.HtmlEncode(PropertyName)}/{WebUtility.HtmlEncode(Value)}/SearchByValue"; 492 | var result = await http.GetAsync(url); 493 | result.EnsureSuccessStatusCode(); 494 | string responseBody = await result.Content.ReadAsStringAsync(); 495 | var response = JsonConvert.DeserializeObject<APIListOfEntityResponse<TEntity>>(responseBody); 496 | if (response.Success) 497 | return response.Data; 498 | else 499 | return null; 500 | } 501 | catch (Exception ex) 502 | { 503 | var msg = ex.Message; 504 | return null; 505 | } 506 | } 507 | 508 | public async Task<TEntity> Insert(TEntity entity) 509 | { 510 | try 511 | { 512 | var result = await http.PostAsJsonAsync(controllerName, entity); 513 | result.EnsureSuccessStatusCode(); 514 | string responseBody = await result.Content.ReadAsStringAsync(); 515 | var response = JsonConvert.DeserializeObject<APIEntityResponse<TEntity>>(responseBody); 516 | if (response.Success) 517 | return response.Data; 518 | else 519 | return null; 520 | } 521 | catch (Exception ex) 522 | { 523 | return null; 524 | } 525 | } 526 | 527 | public async Task<TEntity> Update(TEntity entityToUpdate) 528 | { 529 | try 530 | { 531 | var result = await http.PutAsJsonAsync(controllerName, entityToUpdate); 532 | result.EnsureSuccessStatusCode(); 533 | string responseBody = await result.Content.ReadAsStringAsync(); 534 | var response = JsonConvert.DeserializeObject<APIEntityResponse<TEntity>>(responseBody); 535 | if (response.Success) 536 | return response.Data; 537 | else 538 | return null; 539 | } 540 | catch (Exception ex) 541 | { 542 | return null; 543 | } 544 | } 545 | 546 | public async Task<bool> Delete(TEntity entityToDelete) 547 | { 548 | try 549 | { 550 | var value = entityToDelete.GetType() 551 | .GetProperty(primaryKeyName) 552 | .GetValue(entityToDelete, null) 553 | .ToString(); 554 | 555 | return await DeleteByValue(primaryKeyName, value); 556 | } 557 | catch (Exception ex) 558 | { 559 | return false; 560 | } 561 | } 562 | 563 | public async Task<bool> DeleteByValue(string PropertyName, string Value) 564 | { 565 | try 566 | { 567 | var url = $"{controllerName}/{WebUtility.HtmlEncode(PropertyName)}/{WebUtility.HtmlEncode(Value)}/DeleteByValue"; 568 | var result = await http.DeleteAsync(url); 569 | result.EnsureSuccessStatusCode(); 570 | return true; 571 | } 572 | catch (Exception ex) 573 | { 574 | return false; 575 | } 576 | } 577 | } 578 | ``` 579 | 580 | ## Server-Side Configuration 581 | 582 | ### Creating a Controller 583 | 584 | To create a new API Controller from an entity (and `dbContext`), it looks like this: 585 | 586 | *AuthorsController.cs*: 587 | 588 | ```c# 589 | using LowCodeAPI.Server.Data; 590 | using LowCodeAPI.Shared.Models; 591 | using Microsoft.AspNetCore.Mvc; 592 | using System; 593 | using System.Collections.Generic; 594 | using System.Linq; 595 | using System.Threading.Tasks; 596 | 597 | namespace LowCodeAPI.Server.Controllers 598 | { 599 | [Route("[controller]")] 600 | [ApiController] 601 | public class AuthorsController : EFControllerBase<Author, pubsContext> 602 | { 603 | EFRepository<Author, pubsContext> repository; 604 | 605 | public AuthorsController(EFRepository<Author, pubsContext> _repository) 606 | : base(_repository) 607 | { 608 | repository = _repository; 609 | } 610 | 611 | } 612 | } 613 | ``` 614 | 615 | Just inherit `EFControllerBase<TEntity, TDataContext>`, inject an `EFRepository<TEntity, TDataContext>`, and pass the repository into the `base` constructor. You can add your own endpoints using the repository. 616 | 617 | ### Add to Startup.ConfigureServices() 618 | 619 | To the *Server* projects' *Startup.cs* file, add the `dbContext`, and an `EFRepository` for each model you want a controller for as `Transient` services"." 620 | 621 | ```c# 622 | public void ConfigureServices(IServiceCollection services) 623 | { 624 | // First, add the dbContext 625 | services.AddTransient<pubsContext, pubsContext>(); 626 | 627 | // Next, add an EFRepository for each model you want a controller for 628 | services.AddTransient<EFRepository<Author, pubsContext>>(); 629 | 630 | services.AddControllersWithViews(); 631 | services.AddRazorPages(); 632 | } 633 | ``` 634 | 635 | ## Client-Side Configuration 636 | 637 | ### Create a Manager 638 | 639 | Create a Manager class for every entity that you want to access. For example: 640 | 641 | *AuthorsManager.cs*: 642 | 643 | ```c# 644 | using LowCodeAPI.Shared.Models; 645 | using System; 646 | using System.Collections.Generic; 647 | using System.Linq; 648 | using System.Net.Http; 649 | using System.Threading.Tasks; 650 | 651 | namespace LowCodeAPI.Client.Services 652 | { 653 | public class AuthorsManager : APIRepository<Authors> 654 | { 655 | HttpClient http; 656 | 657 | public AuthorsManager(HttpClient _http) 658 | : base(_http, "authors", "AuId") 659 | { 660 | http = _http; 661 | } 662 | } 663 | } 664 | ``` 665 | 666 | Just inherit from `APIRepository<TEntity>` and pass the `HttpClient` to the base constructor, along with the name of the controller (for URL purposes) and the primary key property name. 667 | 668 | You can add your own client methods using the `HttpClient`. 669 | 670 | ### Add Manager as a Service 671 | 672 | In the `Main` method of the *Client* project's *Program.cs*, add your managers as scoped services: 673 | 674 | ```c# 675 | builder.Services.AddScoped<AuthorsManager>(); 676 | ``` 677 | 678 | 679 | 680 | ## Sample Blazor Files 681 | 682 | If you are building your own sample Blazor WebAssembly app, use this as a guide. These are the files that I changed for the sample. 683 | 684 | #### _Imports.razor 685 | 686 | Add the following to the *Client* project's *_Imports.razor* file: 687 | 688 | ``` 689 | @using LowCodeAPI.Client.Services 690 | @using LowCodeAPI.Shared.Models 691 | ``` 692 | 693 | Of course, if your namespaces are different, change them here. 694 | 695 | #### Index.razor 696 | 697 | And finally, here is our Index page, which lists the authors, and allows CRUD operations. 698 | 699 | ```c# 700 | @page "/" 701 | @inject AuthorsManager AuthorsManager 702 | 703 | @if (Authors != null) 704 | { 705 | <span> Search by Name: </span> 706 | <input @bind="@SearchName" /> 707 | <span> </span> 708 | <button @onclick="Search">Search by Last Name</button> 709 | <span> </span> 710 | <button @onclick="Get">Get by Last Name</button> 711 | <br /> 712 | <br /> 713 | 714 | <button @onclick="GetAllAuthors">Show All</button> 715 | @if (CanIAddaAuthor()) 716 | { 717 | <span> </span> 718 | <button @onclick="AddAuthor">Add Author</button> 719 | } 720 | <br /> 721 | <br /> 722 | <select @onchange="AuthorSelected" size="10" style="width:100%;"> 723 | @foreach (var Author in Authors) 724 | { 725 | <option value="@Author.AuId">@Author.AuFname @Author.AuLname</option> 726 | } 727 | </select> 728 | <br /> 729 | <br /> 730 | } 731 | else 732 | { 733 | <i>Loading Authors...</i> 734 | } 735 | @if (Author != null) 736 | { 737 | <span> Update Last Name: </span> 738 | <input @bind="@Author.AuLname" /> 739 | <button @onclick="UpdateAuthor">Update</button> 740 | <br /> 741 | <br /> 742 | <button @onclick="DeleteAuthor">Delete</button> 743 | 744 | } 745 | <br /> 746 | <span style="color:red;">@ErrorMessage</span> 747 | 748 | @code 749 | { 750 | List<Author> Authors; 751 | Author Author; 752 | string SearchName = ""; 753 | string ErrorMessage = ""; 754 | 755 | async Task DeleteAuthor() 756 | { 757 | ErrorMessage = ""; 758 | if (await AuthorsManager.Delete(Author)) 759 | { 760 | var original = (from x in Authors 761 | where x.AuId == Author.AuId 762 | select x).FirstOrDefault(); 763 | if (original != null) 764 | { 765 | var index = Authors.IndexOf(original); 766 | Authors.RemoveAt(index); 767 | Author = null; 768 | } 769 | } 770 | else 771 | { 772 | ErrorMessage = "Could not delete Author."; 773 | } 774 | await InvokeAsync(StateHasChanged); 775 | } 776 | 777 | async Task UpdateAuthor() 778 | { 779 | ErrorMessage = ""; 780 | var original = (from x in Authors 781 | where x.AuId == Author.AuId 782 | select x).FirstOrDefault(); 783 | if (original != null) 784 | { 785 | var index = Authors.IndexOf(original); 786 | var updated = await AuthorsManager.Update(Author); 787 | if (updated != null) 788 | { 789 | Authors[index] = updated; 790 | } 791 | else 792 | { 793 | ErrorMessage = "Could not update Author"; 794 | } 795 | await InvokeAsync(StateHasChanged); 796 | } 797 | } 798 | 799 | async Task Search() 800 | { 801 | ErrorMessage = ""; 802 | var result = await AuthorsManager.SearchByValue("AuLname", SearchName); 803 | if (result != null) 804 | { 805 | Authors = result.ToList<Author>(); 806 | } 807 | else 808 | { 809 | Authors = new List<Author>(); 810 | ErrorMessage = "No matching Authors."; 811 | } 812 | await InvokeAsync(StateHasChanged); 813 | } 814 | 815 | async Task Get() 816 | { 817 | ErrorMessage = ""; 818 | var result = await AuthorsManager.GetByValue("AuLname", SearchName); 819 | if (result != null) 820 | { 821 | Authors.Clear(); 822 | Authors.Add(result); 823 | } 824 | else 825 | { 826 | Authors = new List<Author>(); 827 | ErrorMessage = "No matching Authors."; 828 | } 829 | await InvokeAsync(StateHasChanged); 830 | } 831 | 832 | async Task AuthorSelected(ChangeEventArgs args) 833 | { 834 | ErrorMessage = ""; 835 | var result = (from x in Authors 836 | where x.AuId == args.Value.ToString() 837 | select x).FirstOrDefault(); 838 | 839 | // Get the Author via the API just to exercise all the methods: 840 | Author = await AuthorsManager.GetByValue("AuId", result.AuId); 841 | 842 | await InvokeAsync(StateHasChanged); 843 | } 844 | 845 | bool CanIAddaAuthor() 846 | { 847 | // only if it doesn't exist 848 | var existing = (from x in Authors 849 | where x.AuId == "111-22-3333" 850 | select x).FirstOrDefault(); 851 | if (existing != null) 852 | return false; 853 | else 854 | return true; 855 | } 856 | 857 | async Task AddAuthor() 858 | { 859 | ErrorMessage = ""; 860 | var Author = new Author(); 861 | Author.AuId = "111-22-3333"; 862 | Author.AuFname = "Carl"; 863 | Author.AuLname = "Franklin"; 864 | Author.Phone = "123123132"; 865 | Author.Address = "1 Somewhere Street"; 866 | Author.City = "Anytown"; 867 | Author.State = "CT"; 868 | Author.Zip = "09876"; 869 | Author.Contract = true; 870 | 871 | var result = await AuthorsManager.Insert(Author); 872 | if (result != null) 873 | { 874 | Authors.Add(result); 875 | Author = result; 876 | } 877 | else 878 | { 879 | ErrorMessage = "Could not add Author"; 880 | } 881 | await InvokeAsync(StateHasChanged); 882 | } 883 | 884 | async Task GetAllAuthors() 885 | { 886 | ErrorMessage = ""; 887 | SearchName = ""; 888 | try 889 | { 890 | var result = await AuthorsManager.GetAll(); 891 | if (result != null) 892 | { 893 | Authors = result.ToList<Author>(); 894 | Author = null; 895 | } 896 | else 897 | { 898 | ErrorMessage = "Could not fetch Authors"; 899 | } 900 | } 901 | catch (Exception ex) 902 | { 903 | ErrorMessage = ex.Message; 904 | } 905 | } 906 | 907 | protected override async Task OnInitializedAsync() 908 | { 909 | await GetAllAuthors(); 910 | } 911 | } 912 | ``` 913 | 914 | -------------------------------------------------------------------------------- /md-images/image-20210707140142879.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/carlfranklin/LowCodeAPI/f4ac5e8a4b54e8290d31a20d5cd226fe64c9a9db/md-images/image-20210707140142879.png -------------------------------------------------------------------------------- /pubsContext.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Microsoft.EntityFrameworkCore; 3 | using Microsoft.EntityFrameworkCore.Metadata; 4 | using LowCodeAPI.Shared.Models; 5 | 6 | #nullable disable 7 | 8 | namespace LowCodeAPI.Server.Data 9 | { 10 | public partial class pubsContext : DbContext 11 | { 12 | public pubsContext() 13 | { 14 | } 15 | 16 | public pubsContext(DbContextOptions<pubsContext> options) 17 | : base(options) 18 | { 19 | } 20 | 21 | public virtual DbSet<Author> Authors { get; set; } 22 | public virtual DbSet<Discount> Discounts { get; set; } 23 | public virtual DbSet<Employee> Employees { get; set; } 24 | public virtual DbSet<Job> Jobs { get; set; } 25 | public virtual DbSet<PubInfo> PubInfos { get; set; } 26 | public virtual DbSet<Publisher> Publishers { get; set; } 27 | public virtual DbSet<Roysched> Royscheds { get; set; } 28 | public virtual DbSet<Sale> Sales { get; set; } 29 | public virtual DbSet<Store> Stores { get; set; } 30 | public virtual DbSet<Title> Titles { get; set; } 31 | public virtual DbSet<Titleauthor> Titleauthors { get; set; } 32 | public virtual DbSet<Titleview> Titleviews { get; set; } 33 | 34 | protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) 35 | { 36 | if (!optionsBuilder.IsConfigured) 37 | { 38 | #warning To protect potentially sensitive information in your connection string, you should move it out of source code. You can avoid scaffolding the connection string by using the Name= syntax to read it from configuration - see https://go.microsoft.com/fwlink/?linkid=2131148. For more guidance on storing connection strings, see http://go.microsoft.com/fwlink/?LinkId=723263. 39 | optionsBuilder.UseSqlServer("Data Source=(localdb)\\MSSQLLocalDB;Initial Catalog=pubs"); 40 | } 41 | } 42 | 43 | protected override void OnModelCreating(ModelBuilder modelBuilder) 44 | { 45 | modelBuilder.Entity<Author>(entity => 46 | { 47 | entity.HasKey(e => e.AuId) 48 | .HasName("UPKCL_auidind"); 49 | 50 | entity.ToTable("authors"); 51 | 52 | entity.HasIndex(e => new { e.AuLname, e.AuFname }, "aunmind"); 53 | 54 | entity.Property(e => e.AuId) 55 | .HasMaxLength(11) 56 | .IsUnicode(false) 57 | .HasColumnName("au_id"); 58 | 59 | entity.Property(e => e.Address) 60 | .HasMaxLength(40) 61 | .IsUnicode(false) 62 | .HasColumnName("address"); 63 | 64 | entity.Property(e => e.AuFname) 65 | .IsRequired() 66 | .HasMaxLength(20) 67 | .IsUnicode(false) 68 | .HasColumnName("au_fname"); 69 | 70 | entity.Property(e => e.AuLname) 71 | .IsRequired() 72 | .HasMaxLength(40) 73 | .IsUnicode(false) 74 | .HasColumnName("au_lname"); 75 | 76 | entity.Property(e => e.City) 77 | .HasMaxLength(20) 78 | .IsUnicode(false) 79 | .HasColumnName("city"); 80 | 81 | entity.Property(e => e.Contract).HasColumnName("contract"); 82 | 83 | entity.Property(e => e.Phone) 84 | .IsRequired() 85 | .HasMaxLength(12) 86 | .IsUnicode(false) 87 | .HasColumnName("phone") 88 | .HasDefaultValueSql("('UNKNOWN')") 89 | .IsFixedLength(true); 90 | 91 | entity.Property(e => e.State) 92 | .HasMaxLength(2) 93 | .IsUnicode(false) 94 | .HasColumnName("state") 95 | .IsFixedLength(true); 96 | 97 | entity.Property(e => e.Zip) 98 | .HasMaxLength(5) 99 | .IsUnicode(false) 100 | .HasColumnName("zip") 101 | .IsFixedLength(true); 102 | }); 103 | 104 | modelBuilder.Entity<Discount>(entity => 105 | { 106 | entity.HasNoKey(); 107 | 108 | entity.ToTable("discounts"); 109 | 110 | entity.Property(e => e.Discount1) 111 | .HasColumnType("decimal(4, 2)") 112 | .HasColumnName("discount"); 113 | 114 | entity.Property(e => e.Discounttype) 115 | .IsRequired() 116 | .HasMaxLength(40) 117 | .IsUnicode(false) 118 | .HasColumnName("discounttype"); 119 | 120 | entity.Property(e => e.Highqty).HasColumnName("highqty"); 121 | 122 | entity.Property(e => e.Lowqty).HasColumnName("lowqty"); 123 | 124 | entity.Property(e => e.StorId) 125 | .HasMaxLength(4) 126 | .IsUnicode(false) 127 | .HasColumnName("stor_id") 128 | .IsFixedLength(true); 129 | 130 | entity.HasOne(d => d.Stor) 131 | .WithMany() 132 | .HasForeignKey(d => d.StorId) 133 | .HasConstraintName("FK__discounts__stor___3B75D760"); 134 | }); 135 | 136 | modelBuilder.Entity<Employee>(entity => 137 | { 138 | entity.HasKey(e => e.EmpId) 139 | .HasName("PK_emp_id") 140 | .IsClustered(false); 141 | 142 | entity.ToTable("employee"); 143 | 144 | entity.HasIndex(e => new { e.Lname, e.Fname, e.Minit }, "employee_ind") 145 | .IsClustered(); 146 | 147 | entity.Property(e => e.EmpId) 148 | .HasMaxLength(9) 149 | .IsUnicode(false) 150 | .HasColumnName("emp_id") 151 | .IsFixedLength(true); 152 | 153 | entity.Property(e => e.Fname) 154 | .IsRequired() 155 | .HasMaxLength(20) 156 | .IsUnicode(false) 157 | .HasColumnName("fname"); 158 | 159 | entity.Property(e => e.HireDate) 160 | .HasColumnType("datetime") 161 | .HasColumnName("hire_date") 162 | .HasDefaultValueSql("(getdate())"); 163 | 164 | entity.Property(e => e.JobId) 165 | .HasColumnName("job_id") 166 | .HasDefaultValueSql("((1))"); 167 | 168 | entity.Property(e => e.JobLvl) 169 | .HasColumnName("job_lvl") 170 | .HasDefaultValueSql("((10))"); 171 | 172 | entity.Property(e => e.Lname) 173 | .IsRequired() 174 | .HasMaxLength(30) 175 | .IsUnicode(false) 176 | .HasColumnName("lname"); 177 | 178 | entity.Property(e => e.Minit) 179 | .HasMaxLength(1) 180 | .IsUnicode(false) 181 | .HasColumnName("minit") 182 | .IsFixedLength(true); 183 | 184 | entity.Property(e => e.PubId) 185 | .IsRequired() 186 | .HasMaxLength(4) 187 | .IsUnicode(false) 188 | .HasColumnName("pub_id") 189 | .HasDefaultValueSql("('9952')") 190 | .IsFixedLength(true); 191 | 192 | entity.HasOne(d => d.Job) 193 | .WithMany(p => p.Employees) 194 | .HasForeignKey(d => d.JobId) 195 | .OnDelete(DeleteBehavior.ClientSetNull) 196 | .HasConstraintName("FK__employee__job_id__47DBAE45"); 197 | 198 | entity.HasOne(d => d.Pub) 199 | .WithMany(p => p.Employees) 200 | .HasForeignKey(d => d.PubId) 201 | .OnDelete(DeleteBehavior.ClientSetNull) 202 | .HasConstraintName("FK__employee__pub_id__4AB81AF0"); 203 | }); 204 | 205 | modelBuilder.Entity<Job>(entity => 206 | { 207 | entity.ToTable("jobs"); 208 | 209 | entity.Property(e => e.JobId).HasColumnName("job_id"); 210 | 211 | entity.Property(e => e.JobDesc) 212 | .IsRequired() 213 | .HasMaxLength(50) 214 | .IsUnicode(false) 215 | .HasColumnName("job_desc") 216 | .HasDefaultValueSql("('New Position - title not formalized yet')"); 217 | 218 | entity.Property(e => e.MaxLvl).HasColumnName("max_lvl"); 219 | 220 | entity.Property(e => e.MinLvl).HasColumnName("min_lvl"); 221 | }); 222 | 223 | modelBuilder.Entity<PubInfo>(entity => 224 | { 225 | entity.HasKey(e => e.PubId) 226 | .HasName("UPKCL_pubinfo"); 227 | 228 | entity.ToTable("pub_info"); 229 | 230 | entity.Property(e => e.PubId) 231 | .HasMaxLength(4) 232 | .IsUnicode(false) 233 | .HasColumnName("pub_id") 234 | .IsFixedLength(true); 235 | 236 | entity.Property(e => e.Logo) 237 | .HasColumnType("image") 238 | .HasColumnName("logo"); 239 | 240 | entity.Property(e => e.PrInfo) 241 | .HasColumnType("text") 242 | .HasColumnName("pr_info"); 243 | 244 | entity.HasOne(d => d.Pub) 245 | .WithOne(p => p.PubInfo) 246 | .HasForeignKey<PubInfo>(d => d.PubId) 247 | .OnDelete(DeleteBehavior.ClientSetNull) 248 | .HasConstraintName("FK__pub_info__pub_id__4316F928"); 249 | }); 250 | 251 | modelBuilder.Entity<Publisher>(entity => 252 | { 253 | entity.HasKey(e => e.PubId) 254 | .HasName("UPKCL_pubind"); 255 | 256 | entity.ToTable("publishers"); 257 | 258 | entity.Property(e => e.PubId) 259 | .HasMaxLength(4) 260 | .IsUnicode(false) 261 | .HasColumnName("pub_id") 262 | .IsFixedLength(true); 263 | 264 | entity.Property(e => e.City) 265 | .HasMaxLength(20) 266 | .IsUnicode(false) 267 | .HasColumnName("city"); 268 | 269 | entity.Property(e => e.Country) 270 | .HasMaxLength(30) 271 | .IsUnicode(false) 272 | .HasColumnName("country") 273 | .HasDefaultValueSql("('USA')"); 274 | 275 | entity.Property(e => e.PubName) 276 | .HasMaxLength(40) 277 | .IsUnicode(false) 278 | .HasColumnName("pub_name"); 279 | 280 | entity.Property(e => e.State) 281 | .HasMaxLength(2) 282 | .IsUnicode(false) 283 | .HasColumnName("state") 284 | .IsFixedLength(true); 285 | }); 286 | 287 | modelBuilder.Entity<Roysched>(entity => 288 | { 289 | entity.HasNoKey(); 290 | 291 | entity.ToTable("roysched"); 292 | 293 | entity.HasIndex(e => e.TitleId, "titleidind"); 294 | 295 | entity.Property(e => e.Hirange).HasColumnName("hirange"); 296 | 297 | entity.Property(e => e.Lorange).HasColumnName("lorange"); 298 | 299 | entity.Property(e => e.Royalty).HasColumnName("royalty"); 300 | 301 | entity.Property(e => e.TitleId) 302 | .IsRequired() 303 | .HasMaxLength(6) 304 | .IsUnicode(false) 305 | .HasColumnName("title_id"); 306 | 307 | entity.HasOne(d => d.Title) 308 | .WithMany() 309 | .HasForeignKey(d => d.TitleId) 310 | .OnDelete(DeleteBehavior.ClientSetNull) 311 | .HasConstraintName("FK__roysched__title___398D8EEE"); 312 | }); 313 | 314 | modelBuilder.Entity<Sale>(entity => 315 | { 316 | entity.HasKey(e => new { e.StorId, e.OrdNum, e.TitleId }) 317 | .HasName("UPKCL_sales"); 318 | 319 | entity.ToTable("sales"); 320 | 321 | entity.HasIndex(e => e.TitleId, "titleidind"); 322 | 323 | entity.Property(e => e.StorId) 324 | .HasMaxLength(4) 325 | .IsUnicode(false) 326 | .HasColumnName("stor_id") 327 | .IsFixedLength(true); 328 | 329 | entity.Property(e => e.OrdNum) 330 | .HasMaxLength(20) 331 | .IsUnicode(false) 332 | .HasColumnName("ord_num"); 333 | 334 | entity.Property(e => e.TitleId) 335 | .HasMaxLength(6) 336 | .IsUnicode(false) 337 | .HasColumnName("title_id"); 338 | 339 | entity.Property(e => e.OrdDate) 340 | .HasColumnType("datetime") 341 | .HasColumnName("ord_date"); 342 | 343 | entity.Property(e => e.Payterms) 344 | .IsRequired() 345 | .HasMaxLength(12) 346 | .IsUnicode(false) 347 | .HasColumnName("payterms"); 348 | 349 | entity.Property(e => e.Qty).HasColumnName("qty"); 350 | 351 | entity.HasOne(d => d.Stor) 352 | .WithMany(p => p.Sales) 353 | .HasForeignKey(d => d.StorId) 354 | .OnDelete(DeleteBehavior.ClientSetNull) 355 | .HasConstraintName("FK__sales__stor_id__36B12243"); 356 | 357 | entity.HasOne(d => d.Title) 358 | .WithMany(p => p.Sales) 359 | .HasForeignKey(d => d.TitleId) 360 | .OnDelete(DeleteBehavior.ClientSetNull) 361 | .HasConstraintName("FK__sales__title_id__37A5467C"); 362 | }); 363 | 364 | modelBuilder.Entity<Store>(entity => 365 | { 366 | entity.HasKey(e => e.StorId) 367 | .HasName("UPK_storeid"); 368 | 369 | entity.ToTable("stores"); 370 | 371 | entity.Property(e => e.StorId) 372 | .HasMaxLength(4) 373 | .IsUnicode(false) 374 | .HasColumnName("stor_id") 375 | .IsFixedLength(true); 376 | 377 | entity.Property(e => e.City) 378 | .HasMaxLength(20) 379 | .IsUnicode(false) 380 | .HasColumnName("city"); 381 | 382 | entity.Property(e => e.State) 383 | .HasMaxLength(2) 384 | .IsUnicode(false) 385 | .HasColumnName("state") 386 | .IsFixedLength(true); 387 | 388 | entity.Property(e => e.StorAddress) 389 | .HasMaxLength(40) 390 | .IsUnicode(false) 391 | .HasColumnName("stor_address"); 392 | 393 | entity.Property(e => e.StorName) 394 | .HasMaxLength(40) 395 | .IsUnicode(false) 396 | .HasColumnName("stor_name"); 397 | 398 | entity.Property(e => e.Zip) 399 | .HasMaxLength(5) 400 | .IsUnicode(false) 401 | .HasColumnName("zip") 402 | .IsFixedLength(true); 403 | }); 404 | 405 | modelBuilder.Entity<Title>(entity => 406 | { 407 | entity.ToTable("titles"); 408 | 409 | entity.HasIndex(e => e.Title1, "titleind"); 410 | 411 | entity.Property(e => e.TitleId) 412 | .HasMaxLength(6) 413 | .IsUnicode(false) 414 | .HasColumnName("title_id"); 415 | 416 | entity.Property(e => e.Advance) 417 | .HasColumnType("money") 418 | .HasColumnName("advance"); 419 | 420 | entity.Property(e => e.Notes) 421 | .HasMaxLength(200) 422 | .IsUnicode(false) 423 | .HasColumnName("notes"); 424 | 425 | entity.Property(e => e.Price) 426 | .HasColumnType("money") 427 | .HasColumnName("price"); 428 | 429 | entity.Property(e => e.PubId) 430 | .HasMaxLength(4) 431 | .IsUnicode(false) 432 | .HasColumnName("pub_id") 433 | .IsFixedLength(true); 434 | 435 | entity.Property(e => e.Pubdate) 436 | .HasColumnType("datetime") 437 | .HasColumnName("pubdate") 438 | .HasDefaultValueSql("(getdate())"); 439 | 440 | entity.Property(e => e.Royalty).HasColumnName("royalty"); 441 | 442 | entity.Property(e => e.Title1) 443 | .IsRequired() 444 | .HasMaxLength(80) 445 | .IsUnicode(false) 446 | .HasColumnName("title"); 447 | 448 | entity.Property(e => e.Type) 449 | .IsRequired() 450 | .HasMaxLength(12) 451 | .IsUnicode(false) 452 | .HasColumnName("type") 453 | .HasDefaultValueSql("('UNDECIDED')") 454 | .IsFixedLength(true); 455 | 456 | entity.Property(e => e.YtdSales).HasColumnName("ytd_sales"); 457 | 458 | entity.HasOne(d => d.Pub) 459 | .WithMany(p => p.Titles) 460 | .HasForeignKey(d => d.PubId) 461 | .HasConstraintName("FK__titles__pub_id__2D27B809"); 462 | }); 463 | 464 | modelBuilder.Entity<Titleauthor>(entity => 465 | { 466 | entity.HasKey(e => new { e.AuId, e.TitleId }) 467 | .HasName("UPKCL_taind"); 468 | 469 | entity.ToTable("titleauthor"); 470 | 471 | entity.HasIndex(e => e.AuId, "auidind"); 472 | 473 | entity.HasIndex(e => e.TitleId, "titleidind"); 474 | 475 | entity.Property(e => e.AuId) 476 | .HasMaxLength(11) 477 | .IsUnicode(false) 478 | .HasColumnName("au_id"); 479 | 480 | entity.Property(e => e.TitleId) 481 | .HasMaxLength(6) 482 | .IsUnicode(false) 483 | .HasColumnName("title_id"); 484 | 485 | entity.Property(e => e.AuOrd).HasColumnName("au_ord"); 486 | 487 | entity.Property(e => e.Royaltyper).HasColumnName("royaltyper"); 488 | 489 | entity.HasOne(d => d.Au) 490 | .WithMany(p => p.Titleauthors) 491 | .HasForeignKey(d => d.AuId) 492 | .OnDelete(DeleteBehavior.ClientSetNull) 493 | .HasConstraintName("FK__titleauth__au_id__30F848ED"); 494 | 495 | entity.HasOne(d => d.Title) 496 | .WithMany(p => p.Titleauthors) 497 | .HasForeignKey(d => d.TitleId) 498 | .OnDelete(DeleteBehavior.ClientSetNull) 499 | .HasConstraintName("FK__titleauth__title__31EC6D26"); 500 | }); 501 | 502 | modelBuilder.Entity<Titleview>(entity => 503 | { 504 | entity.HasNoKey(); 505 | 506 | entity.ToView("titleview"); 507 | 508 | entity.Property(e => e.AuLname) 509 | .IsRequired() 510 | .HasMaxLength(40) 511 | .IsUnicode(false) 512 | .HasColumnName("au_lname"); 513 | 514 | entity.Property(e => e.AuOrd).HasColumnName("au_ord"); 515 | 516 | entity.Property(e => e.Price) 517 | .HasColumnType("money") 518 | .HasColumnName("price"); 519 | 520 | entity.Property(e => e.PubId) 521 | .HasMaxLength(4) 522 | .IsUnicode(false) 523 | .HasColumnName("pub_id") 524 | .IsFixedLength(true); 525 | 526 | entity.Property(e => e.Title) 527 | .IsRequired() 528 | .HasMaxLength(80) 529 | .IsUnicode(false) 530 | .HasColumnName("title"); 531 | 532 | entity.Property(e => e.YtdSales).HasColumnName("ytd_sales"); 533 | }); 534 | 535 | OnModelCreatingPartial(modelBuilder); 536 | } 537 | 538 | partial void OnModelCreatingPartial(ModelBuilder modelBuilder); 539 | } 540 | } 541 | --------------------------------------------------------------------------------