|
@@ -0,0 +1,80 @@
|
|
1
|
+# Luticate2 API Utils
|
|
2
|
+
|
|
3
|
+## Install
|
|
4
|
+
|
|
5
|
+NuGet.Config
|
|
6
|
+```xml
|
|
7
|
+<?xml version="1.0" encoding="utf-8"?>
|
|
8
|
+<configuration>
|
|
9
|
+ <packageSources>
|
|
10
|
+ <add key="nuget.org" value="https://api.nuget.org/v3/index.json" protocolVersion="3" />
|
|
11
|
+ <add key="rthoni" value="http://nuget.rthoni.com" protocolVersion="2" />
|
|
12
|
+ </packageSources>
|
|
13
|
+</configuration>
|
|
14
|
+
|
|
15
|
+```
|
|
16
|
+
|
|
17
|
+project.json
|
|
18
|
+```json
|
|
19
|
+{
|
|
20
|
+ ...
|
|
21
|
+ dependencies": {
|
|
22
|
+ "Luticate2.Utils": "0.1.*",
|
|
23
|
+ ...
|
|
24
|
+ }
|
|
25
|
+ ...
|
|
26
|
+}
|
|
27
|
+```
|
|
28
|
+
|
|
29
|
+appsettings.json
|
|
30
|
+```json
|
|
31
|
+{
|
|
32
|
+ ...
|
|
33
|
+ "ConnectionStrings": {
|
|
34
|
+ "default": "User ID=POSTGRES_USER;Password=POSTGRES_PASSWORD;Host=POSTGRES_HOST;Port=5432;Database=POSTGRES_DB;Pooling=true;",
|
|
35
|
+ ...
|
|
36
|
+ }
|
|
37
|
+ ...
|
|
38
|
+}
|
|
39
|
+```
|
|
40
|
+
|
|
41
|
+Startup.cs
|
|
42
|
+```C#
|
|
43
|
+public void ConfigureServices(IServiceCollection services)
|
|
44
|
+{
|
|
45
|
+ // ...
|
|
46
|
+
|
|
47
|
+ // MUST be before addMvc()
|
|
48
|
+ services.AddLuticateUtils(options => options.Version = "dev");
|
|
49
|
+
|
|
50
|
+ // ...
|
|
51
|
+
|
|
52
|
+ services.AddDbContext<YourDbContext>(options => // Replace YourDbContext with your own database context
|
|
53
|
+ {
|
|
54
|
+ options.UseNpgsql(Configuration.GetConnectionString("default"));
|
|
55
|
+ options.UseInternalServiceProvider(new ServiceCollection()
|
|
56
|
+ .AddEntityFrameworkNpgsqlLuticate() // MUST be before AddEntityFrameworkNpgsql()
|
|
57
|
+ .AddEntityFrameworkNpgsql()
|
|
58
|
+ .BuildServiceProvider());
|
|
59
|
+ });
|
|
60
|
+
|
|
61
|
+ services.AddMvc()
|
|
62
|
+ .AddLuticateUtils();
|
|
63
|
+
|
|
64
|
+ // ...
|
|
65
|
+}
|
|
66
|
+
|
|
67
|
+public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
|
|
68
|
+{
|
|
69
|
+ // ...
|
|
70
|
+
|
|
71
|
+ // MUST be before useMvc()
|
|
72
|
+ app.UseLuticateUtils();
|
|
73
|
+
|
|
74
|
+ // ...
|
|
75
|
+}
|
|
76
|
+```
|
|
77
|
+
|
|
78
|
+## Usage
|
|
79
|
+
|
|
80
|
+See WebApiUtils for an example
|