summaryrefslogtreecommitdiff
path: root/DSACore
diff options
context:
space:
mode:
authorTrueDoctor <d-kobert@web.de>2018-09-26 19:18:41 +0200
committerTrueDoctor <d-kobert@web.de>2018-09-26 19:18:41 +0200
commit92e8bb7523c775014ccf68355e3f0178ebf4a61c (patch)
treec68840e084740c890fe85cf2e4a7356115a1b0be /DSACore
parent0d8ae32d2f974ad6139a55e6e0d97d785fb13489 (diff)
implemented fudamental Web Api
Diffstat (limited to 'DSACore')
-rw-r--r--DSACore/Controllers/CommandsController.cs49
-rw-r--r--DSACore/Controllers/ValuesController.cs45
-rw-r--r--DSACore/DSACore.csproj15
-rw-r--r--DSACore/Models/Command.cs13
-rw-r--r--DSACore/Program.cs24
-rw-r--r--DSACore/Properties/launchSettings.json30
-rw-r--r--DSACore/Startup.cs47
-rw-r--r--DSACore/appsettings.Development.json9
-rw-r--r--DSACore/appsettings.json8
9 files changed, 240 insertions, 0 deletions
diff --git a/DSACore/Controllers/CommandsController.cs b/DSACore/Controllers/CommandsController.cs
new file mode 100644
index 0000000..bda8fd0
--- /dev/null
+++ b/DSACore/Controllers/CommandsController.cs
@@ -0,0 +1,49 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Threading.Tasks;
+using DSACore.Models;
+using Microsoft.AspNetCore.Mvc;
+
+// For more information on enabling Web API for empty projects, visit https://go.microsoft.com/fwlink/?LinkID=397860
+
+namespace DSACore.Controllers
+{
+ [Route("api/[controller]")]
+ public class CommandsController : Controller
+ {
+ // GET: api/<controller>
+ [HttpGet]
+ public IEnumerable<string> Get()
+ {
+ return new string[] { "value1", "value2" };
+ }
+
+ // GET api/<controller>/5
+ [HttpGet("{id}")]
+ public string Get(int id)
+ {
+ return "value";
+ }
+
+ // POST api/<controller>/Felis
+ [HttpPost]
+ public string Post([FromBody]Command cmd)
+ {
+ return cmd.Name + " strichelt erfolgreich das Einhorn" + cmd.CmdText;
+ }
+
+
+ // PUT api/<controller>/5
+ [HttpPut("{id}")]
+ public void Put(int id, [FromBody]string value)
+ {
+ }
+
+ // DELETE api/<controller>/5
+ [HttpDelete("{id}")]
+ public void Delete(int id)
+ {
+ }
+ }
+}
diff --git a/DSACore/Controllers/ValuesController.cs b/DSACore/Controllers/ValuesController.cs
new file mode 100644
index 0000000..eb08898
--- /dev/null
+++ b/DSACore/Controllers/ValuesController.cs
@@ -0,0 +1,45 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Threading.Tasks;
+using Microsoft.AspNetCore.Mvc;
+
+namespace DSACore.Controllers
+{
+ [Route("api/[controller]")]
+ [ApiController]
+ public class ValuesController : ControllerBase
+ {
+ // GET api/values
+ [HttpGet]
+ public ActionResult<IEnumerable<string>> Get()
+ {
+ return new string[] { "value1", "value2" };
+ }
+
+ // GET api/values/5
+ [HttpGet("{id}")]
+ public ActionResult<string> Get(int id)
+ {
+ return "value";
+ }
+
+ // POST api/values
+ [HttpPost]
+ public void Post([FromBody] string value)
+ {
+ }
+
+ // PUT api/values/5
+ [HttpPut("{id}")]
+ public void Put(int id, [FromBody] string value)
+ {
+ }
+
+ // DELETE api/values/5
+ [HttpDelete("{id}")]
+ public void Delete(int id)
+ {
+ }
+ }
+}
diff --git a/DSACore/DSACore.csproj b/DSACore/DSACore.csproj
new file mode 100644
index 0000000..1661770
--- /dev/null
+++ b/DSACore/DSACore.csproj
@@ -0,0 +1,15 @@
+<Project Sdk="Microsoft.NET.Sdk.Web">
+
+ <PropertyGroup>
+ <TargetFramework>netcoreapp2.1</TargetFramework>
+ </PropertyGroup>
+
+ <ItemGroup>
+ <PackageReference Include="Microsoft.AspNetCore.App" />
+ </ItemGroup>
+
+ <ItemGroup>
+ <Folder Include="wwwroot\" />
+ </ItemGroup>
+
+</Project>
diff --git a/DSACore/Models/Command.cs b/DSACore/Models/Command.cs
new file mode 100644
index 0000000..75e3bee
--- /dev/null
+++ b/DSACore/Models/Command.cs
@@ -0,0 +1,13 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Threading.Tasks;
+
+namespace DSACore.Models
+{
+ public class Command
+ {
+ public string Name { get; set; }
+ public string CmdText { get; set; }
+ }
+}
diff --git a/DSACore/Program.cs b/DSACore/Program.cs
new file mode 100644
index 0000000..373a39e
--- /dev/null
+++ b/DSACore/Program.cs
@@ -0,0 +1,24 @@
+using System;
+using System.Collections.Generic;
+using System.IO;
+using System.Linq;
+using System.Threading.Tasks;
+using Microsoft.AspNetCore;
+using Microsoft.AspNetCore.Hosting;
+using Microsoft.Extensions.Configuration;
+using Microsoft.Extensions.Logging;
+
+namespace DSACore
+{
+ public class Program
+ {
+ public static void Main(string[] args)
+ {
+ CreateWebHostBuilder(args).Build().Run();
+ }
+
+ public static IWebHostBuilder CreateWebHostBuilder(string[] args) =>
+ WebHost.CreateDefaultBuilder(args)
+ .UseStartup<Startup>();
+ }
+}
diff --git a/DSACore/Properties/launchSettings.json b/DSACore/Properties/launchSettings.json
new file mode 100644
index 0000000..889d022
--- /dev/null
+++ b/DSACore/Properties/launchSettings.json
@@ -0,0 +1,30 @@
+{
+ "$schema": "http://json.schemastore.org/launchsettings.json",
+ "iisSettings": {
+ "windowsAuthentication": false,
+ "anonymousAuthentication": true,
+ "iisExpress": {
+ "applicationUrl": "http://localhost:29492",
+ "sslPort": 44365
+ }
+ },
+ "profiles": {
+ "IIS Express": {
+ "commandName": "IISExpress",
+ "launchBrowser": true,
+ "launchUrl": "api/commands",
+ "environmentVariables": {
+ "ASPNETCORE_ENVIRONMENT": "Development"
+ }
+ },
+ "DSACore": {
+ "commandName": "Project",
+ "launchBrowser": true,
+ "launchUrl": "api/commands",
+ "applicationUrl": "https://localhost:5001;http://localhost:5000",
+ "environmentVariables": {
+ "ASPNETCORE_ENVIRONMENT": "Development"
+ }
+ }
+ }
+} \ No newline at end of file
diff --git a/DSACore/Startup.cs b/DSACore/Startup.cs
new file mode 100644
index 0000000..2d0c2a3
--- /dev/null
+++ b/DSACore/Startup.cs
@@ -0,0 +1,47 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Threading.Tasks;
+using Microsoft.AspNetCore.Builder;
+using Microsoft.AspNetCore.Hosting;
+using Microsoft.AspNetCore.HttpsPolicy;
+using Microsoft.AspNetCore.Mvc;
+using Microsoft.Extensions.Configuration;
+using Microsoft.Extensions.DependencyInjection;
+using Microsoft.Extensions.Logging;
+using Microsoft.Extensions.Options;
+
+namespace DSACore
+{
+ public class Startup
+ {
+ public Startup(IConfiguration configuration)
+ {
+ Configuration = configuration;
+ }
+
+ public IConfiguration Configuration { get; }
+
+ // This method gets called by the runtime. Use this method to add services to the container.
+ public void ConfigureServices(IServiceCollection services)
+ {
+ services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_1);
+ }
+
+ // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
+ public void Configure(IApplicationBuilder app, IHostingEnvironment env)
+ {
+ if (env.IsDevelopment())
+ {
+ app.UseDeveloperExceptionPage();
+ }
+ else
+ {
+ app.UseHsts();
+ }
+
+ app.UseHttpsRedirection();
+ app.UseMvc();
+ }
+ }
+}
diff --git a/DSACore/appsettings.Development.json b/DSACore/appsettings.Development.json
new file mode 100644
index 0000000..e203e94
--- /dev/null
+++ b/DSACore/appsettings.Development.json
@@ -0,0 +1,9 @@
+{
+ "Logging": {
+ "LogLevel": {
+ "Default": "Debug",
+ "System": "Information",
+ "Microsoft": "Information"
+ }
+ }
+}
diff --git a/DSACore/appsettings.json b/DSACore/appsettings.json
new file mode 100644
index 0000000..def9159
--- /dev/null
+++ b/DSACore/appsettings.json
@@ -0,0 +1,8 @@
+{
+ "Logging": {
+ "LogLevel": {
+ "Default": "Warning"
+ }
+ },
+ "AllowedHosts": "*"
+}