Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
searus committed Aug 20, 2018
0 parents commit 7edce50
Show file tree
Hide file tree
Showing 61 changed files with 11,967 additions and 0 deletions.
10 changes: 10 additions & 0 deletions dddeastanglia.code-workspace
@@ -0,0 +1,10 @@
{
"folders": [
{
"path": "src\\api"
},
{
"path": "src\\ui"
}
]
}
2 changes: 2 additions & 0 deletions src/api/.gitignore
@@ -0,0 +1,2 @@
bin/
obj/
46 changes: 46 additions & 0 deletions src/api/.vscode/launch.json
@@ -0,0 +1,46 @@
{
// Use IntelliSense to find out which attributes exist for C# debugging
// Use hover for the description of the existing attributes
// For further information visit https://github.com/OmniSharp/omnisharp-vscode/blob/master/debugger-launchjson.md
"version": "0.2.0",
"configurations": [
{
"name": ".NET Core Launch (web)",
"type": "coreclr",
"request": "launch",
"preLaunchTask": "build",
// If you have changed target frameworks, make sure to update the program path.
"program": "${workspaceFolder}/bin/Debug/netcoreapp2.1/api.dll",
"args": [],
"cwd": "${workspaceFolder}",
"stopAtEntry": false,
"internalConsoleOptions": "openOnSessionStart",
"launchBrowser": {
"enabled": true,
"args": "${auto-detect-url}",
"windows": {
"command": "cmd.exe",
"args": "/C start ${auto-detect-url}"
},
"osx": {
"command": "open"
},
"linux": {
"command": "xdg-open"
}
},
"env": {
"ASPNETCORE_ENVIRONMENT": "Development"
},
"sourceFileMap": {
"/Views": "${workspaceFolder}/Views"
}
},
{
"name": ".NET Core Attach",
"type": "coreclr",
"request": "attach",
"processId": "${command:pickProcess}"
}
,]
}
15 changes: 15 additions & 0 deletions src/api/.vscode/tasks.json
@@ -0,0 +1,15 @@
{
"version": "2.0.0",
"tasks": [
{
"label": "build",
"command": "dotnet",
"type": "process",
"args": [
"build",
"${workspaceFolder}/api.csproj"
],
"problemMatcher": "$msCompile"
}
]
}
95 changes: 95 additions & 0 deletions src/api/Controllers/ValuesController.cs
@@ -0,0 +1,95 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using api.Models;
using Microsoft.AspNetCore.Mvc;

namespace api.Controllers
{
[Route("api/[controller]")]
[ApiController]
public class ValuesController : ControllerBase
{

private static List<ValueModel> Values = new List<ValueModel>(Enumerable.Range(1, 3).Select(i => new ValueModel
{
Id = i,
Value = $"Value {i}"
}));

// GET api/values
[HttpGet]
public ActionResult<IEnumerable<ValueModel>> Get()
{
return Ok(Values);
}

// GET api/values/5
[HttpGet("{id}")]
public ActionResult<ValueModel> Get(int id)
{

var value = Values.SingleOrDefault(x => x.Id == id);

if (value == null) return NotFound();

return value;

}

// POST api/values
[HttpPost]
public ActionResult<ValueModel> Post([FromBody, Bind("Value")] ValueModel model)
{

if (Values.Any(x => x.Value.Equals(model.Value)))
return BadRequest("Duplicate");

var nextId = Values.Count == 0 ? 1 : Values.Max(x => x.Id) + 1;

var newValue = new ValueModel
{
Id = nextId,
Value = model.Value
};

Values.Add(newValue);

return Ok(newValue);

}

// PUT api/values/5
[HttpPut("{id}")]
public ActionResult Put(int id, [FromBody]ValueModel model)
{

if (id != model.Id) return BadRequest();

var value = Values.SingleOrDefault(x => x.Id == model.Id);

if (value == null) return NotFound();

value.Value = model.Value;

return NoContent();

}

// DELETE api/values/5
[HttpDelete("{id}")]
public ActionResult Delete(int id)
{

var value = Values.SingleOrDefault(x => x.Id == id);

if (value == null) return NotFound();

Values.Remove(value);

return NoContent();

}
}
}
14 changes: 14 additions & 0 deletions src/api/Models/ValueModel.cs
@@ -0,0 +1,14 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;

namespace api.Models
{
public class ValueModel
{
public int Id { get; set; }
public string Value { get; set; }
}
}
24 changes: 24 additions & 0 deletions src/api/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 api
{
public class Program
{
public static void Main(string[] args)
{
CreateWebHostBuilder(args).Build().Run();
}

public static IWebHostBuilder CreateWebHostBuilder(string[] args) =>
WebHost.CreateDefaultBuilder(args)
.UseStartup<Startup>();
}
}
30 changes: 30 additions & 0 deletions src/api/Properties/launchSettings.json
@@ -0,0 +1,30 @@
{
"$schema": "http://json.schemastore.org/launchsettings.json",
"iisSettings": {
"windowsAuthentication": false,
"anonymousAuthentication": true,
"iisExpress": {
"applicationUrl": "http://localhost:52575",
"sslPort": 44384
}
},
"profiles": {
"IIS Express": {
"commandName": "IISExpress",
"launchBrowser": true,
"launchUrl": "api/values",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
},
"api": {
"commandName": "Project",
"launchBrowser": true,
"launchUrl": "api/values",
"applicationUrl": "https://localhost:5001;http://localhost:5000",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
}
}
}
55 changes: 55 additions & 0 deletions src/api/Startup.cs
@@ -0,0 +1,55 @@
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 api
{
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.AddCors();
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.UseCors(config => config
.AllowAnyHeader()
.AllowAnyMethod()
.AllowAnyOrigin()
.AllowCredentials()
);

app.UseHttpsRedirection();
app.UseMvc();
}
}
}
15 changes: 15 additions & 0 deletions src/api/api.csproj
@@ -0,0 +1,15 @@
<Project Sdk="Microsoft.NET.Sdk.Web">

<PropertyGroup>
<TargetFramework>netcoreapp2.1</TargetFramework>
</PropertyGroup>

<ItemGroup>
<Folder Include="wwwroot\" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.App" />
</ItemGroup>

</Project>
9 changes: 9 additions & 0 deletions src/api/appsettings.Development.json
@@ -0,0 +1,9 @@
{
"Logging": {
"LogLevel": {
"Default": "Debug",
"System": "Information",
"Microsoft": "Information"
}
}
}
8 changes: 8 additions & 0 deletions src/api/appsettings.json
@@ -0,0 +1,8 @@
{
"Logging": {
"LogLevel": {
"Default": "Warning"
}
},
"AllowedHosts": "*"
}
12 changes: 12 additions & 0 deletions src/ui/.editorconfig
@@ -0,0 +1,12 @@
# EditorConfig is awesome: http://EditorConfig.org

# top-most EditorConfig file
root = true

# Unix-style newlines with a newline ending every file
[*]
end_of_line = lf
insert_final_newline = true
# 2 space indentation
indent_style = space
indent_size = 2
31 changes: 31 additions & 0 deletions src/ui/.gitignore
@@ -0,0 +1,31 @@
# You may want to customise this file depending on your Operating System
# and the editor that you use.
#
# We recommend that you use a Global Gitignore for files that are not related
# to the project. (https://help.github.com/articles/ignoring-files/#create-a-global-gitignore)

# OS
#
# Ref: https://github.com/github/gitignore/blob/master/Global/macOS.gitignore
# Ref: https://github.com/github/gitignore/blob/master/Global/Windows.gitignore
# Ref: https://github.com/github/gitignore/blob/master/Global/Linux.gitignore
.DS_STORE
Thumbs.db

# Editors
#
# Ref: https://github.com/github/gitignore/blob/master/Global
# Ref: https://github.com/github/gitignore/blob/master/Global/JetBrains.gitignore
# Ref: https://github.com/github/gitignore/blob/master/Global/VisualStudioCode.gitignore
.idea
.vscode/*
!.vscode/settings.json
!.vscode/tasks.json
!.vscode/launch.json
!.vscode/extensions.json

# Dependencies
node_modules

# Compiled files
scripts
10 changes: 10 additions & 0 deletions src/ui/.vscode/extensions.json
@@ -0,0 +1,10 @@
{
"recommendations": [
"AureliaEffect.aurelia",
"msjsdiag.debugger-for-chrome",
"steoates.autoimport",
"EditorConfig.EditorConfig",
"christian-kohler.path-intellisense",
"behzad88.Aurelia"
]
}

0 comments on commit 7edce50

Please sign in to comment.