Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
Ingafen committed Mar 30, 2022
0 parents commit 2bd2c1b
Show file tree
Hide file tree
Showing 98 changed files with 41,028 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
bin/
obj/
/packages/
riderModule.iml
/_ReSharper.Caches/
25 changes: 25 additions & 0 deletions StarWarsKb.Back/.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
**/.dockerignore
**/.env
**/.git
**/.gitignore
**/.project
**/.settings
**/.toolstarget
**/.vs
**/.vscode
**/.idea
**/*.*proj.user
**/*.dbmdl
**/*.jfm
**/azds.yaml
**/bin
**/charts
**/docker-compose*
**/Dockerfile*
**/node_modules
**/npm-debug.log
**/obj
**/secrets.dev.yaml
**/values.dev.yaml
LICENSE
README.md
1 change: 1 addition & 0 deletions StarWarsKb.Back/Controllers/CharactersController.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

39 changes: 39 additions & 0 deletions StarWarsKb.Back/Controllers/WeatherForecastController.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Logging;

namespace StarWarsKb.Back.Controllers
{
[ApiController]
[Route("[controller]")]
public class WeatherForecastController : ControllerBase
{
private static readonly string[] Summaries = new[]
{
"Freezing", "Bracing", "Chilly", "Cool", "Mild", "Warm", "Balmy", "Hot", "Sweltering", "Scorching"
};

private readonly ILogger<WeatherForecastController> _logger;

public WeatherForecastController(ILogger<WeatherForecastController> logger)
{
_logger = logger;
}

[HttpGet]
public IEnumerable<WeatherForecast> Get()
{
var rng = new Random();
return Enumerable.Range(1, 5).Select(index => new WeatherForecast
{
Date = DateTime.Now.AddDays(index),
TemperatureC = rng.Next(-20, 55),
Summary = Summaries[rng.Next(Summaries.Length)]
})
.ToArray();
}
}
}
20 changes: 20 additions & 0 deletions StarWarsKb.Back/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
FROM mcr.microsoft.com/dotnet/core/aspnet:3.1 AS base
WORKDIR /app
EXPOSE 80
EXPOSE 443

FROM mcr.microsoft.com/dotnet/core/sdk:3.1 AS build
WORKDIR /src
COPY ["StarWarsKb.Back/StarWarsKb.Back.csproj", "StarWarsKb.Back/"]
RUN dotnet restore "StarWarsKb.Back/StarWarsKb.Back.csproj"
COPY . .
WORKDIR "/src/StarWarsKb.Back"
RUN dotnet build "StarWarsKb.Back.csproj" -c Release -o /app/build

FROM build AS publish
RUN dotnet publish "StarWarsKb.Back.csproj" -c Release -o /app/publish

FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
ENTRYPOINT ["dotnet", "StarWarsKb.Back.dll"]
9 changes: 9 additions & 0 deletions StarWarsKb.Back/Model/ICharactersRepository.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
using StarWars.Infrastructure.Model;

namespace StarWars.Back.Model;

public interface ICharactersRepository
{
IList<Character> GetAll();
Character GetById(int id);
}
68 changes: 68 additions & 0 deletions StarWarsKb.Back/Model/StubCharactersRepository.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
using StarWars.Infrastructure.Model;

namespace StarWars.Back.Model;

public class StubCharactersRepository : ICharactersRepository
{
private IList<Character> _list;
public StubCharactersRepository()
{
_list = new List<Character>
{
new()
{
Id = 1, Name = "Test Luke Skywalker",
Height = 172, Mass = 77, HairColor = "blond",
SkinColor = "fair", EyeColor = "blue", BirthYear = "19BBY",
Gender = "male", HomeWorld = new Planet {Name = "Tatooine"},
Films = new List<Film>
{
new() {Title = "The Empire Strikes Back", EpisodeId = 5},
new() {Title = "Revenge of the Sith", EpisodeId = 3}
},
Species = new List<Spec>
{
new() {Name = "human", Classification = "mammal"}
},
Vehicles = new List<Vehicle>
{
new() {Name = "Snowspeeder", Model = "t-47 airspeeder"},
new() {Name = "Imperial Speeder Bike", Model = "74-z speeder bike"}
},
Startships = new List<Starship>
{
new() {Name = "X-wing", Model = "T-65 X-wing"},
new() {Name = "Imperial shuttle", Model = "Lambda-class T-4a shuttle"}
}
},
new()
{
Id = 2, Name = "Boba Fett", Height = 183, Mass = 78.2d, HairColor = "black",
SkinColor = "fair", EyeColor = "brown", BirthYear = "31.5BBY",
Gender = "Male", HomeWorld = new Planet {Name = "Kamino"},
Films = new List<Film>
{
new() {Title = "The Empire Strikes Back", EpisodeId = 5},
new() {Title = "Return of the Jedi", EpisodeId = 6},
new() {Title = "Attack of the Clones", EpisodeId = 2}
},
Species = new List<Spec>(),
Vehicles = new List<Vehicle>(),
Startships = new List<Starship>
{
new() {Name = "Slave 1", Model = "Firespray-31-class patrol and attack"}
}
}
};
}

public IList<Character> GetAll()
{
return _list;
}

public Character GetById(int id)
{
return _list.First(x => x.Id == id);
}
}
23 changes: 23 additions & 0 deletions StarWarsKb.Back/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Logging;

namespace StarWarsKb.Back
{
public class Program
{
public static void Main(string[] args)
{
CreateHostBuilder(args).Build().Run();
}

public static IHostBuilder CreateHostBuilder(string[] args) =>
Host.CreateDefaultBuilder(args)
.ConfigureWebHostDefaults(webBuilder => { webBuilder.UseStartup<Startup>(); });
}
}
30 changes: 30 additions & 0 deletions StarWarsKb.Back/Properties/launchSettings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
{
"$schema": "http://json.schemastore.org/launchsettings.json",
"iisSettings": {
"windowsAuthentication": false,
"anonymousAuthentication": true,
"iisExpress": {
"applicationUrl": "http://localhost:65344",
"sslPort": 44398
}
},
"profiles": {
"IIS Express": {
"commandName": "IISExpress",
"launchBrowser": true,
"launchUrl": "weatherforecast",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
},
"StarWarsKb.Back": {
"commandName": "Project",
"launchBrowser": true,
"launchUrl": "weatherforecast",
"applicationUrl": "https://localhost:5001;http://localhost:5000",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
}
}
}
9 changes: 9 additions & 0 deletions StarWarsKb.Back/StarWarsKb.Back.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<Project Sdk="Microsoft.NET.Sdk.Web">

<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
<DockerDefaultTargetOS>Linux</DockerDefaultTargetOS>
</PropertyGroup>


</Project>
48 changes: 48 additions & 0 deletions StarWarsKb.Back/Startup.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
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.Hosting;
using Microsoft.Extensions.Logging;

namespace StarWarsKb.Back
{
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.AddControllers();
}

// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
{
if (env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
}

app.UseHttpsRedirection();

app.UseRouting();

app.UseAuthorization();

app.UseEndpoints(endpoints => { endpoints.MapControllers(); });
}
}
}
15 changes: 15 additions & 0 deletions StarWarsKb.Back/WeatherForecast.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
using System;

namespace StarWarsKb.Back
{
public class WeatherForecast
{
public DateTime Date { get; set; }

public int TemperatureC { get; set; }

public int TemperatureF => 32 + (int) (TemperatureC / 0.5556);

public string Summary { get; set; }
}
}
9 changes: 9 additions & 0 deletions StarWarsKb.Back/appsettings.Development.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft": "Warning",
"Microsoft.Hosting.Lifetime": "Information"
}
}
}
10 changes: 10 additions & 0 deletions StarWarsKb.Back/appsettings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft": "Warning",
"Microsoft.Hosting.Lifetime": "Information"
}
},
"AllowedHosts": "*"
}
25 changes: 25 additions & 0 deletions StarWarsKb.Front/.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
**/.dockerignore
**/.env
**/.git
**/.gitignore
**/.project
**/.settings
**/.toolstarget
**/.vs
**/.vscode
**/.idea
**/*.*proj.user
**/*.dbmdl
**/*.jfm
**/azds.yaml
**/bin
**/charts
**/docker-compose*
**/Dockerfile*
**/node_modules
**/npm-debug.log
**/obj
**/secrets.dev.yaml
**/values.dev.yaml
LICENSE
README.md
37 changes: 37 additions & 0 deletions StarWarsKb.Front/Controllers/HomeController.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Logging;
using StarWarsKb.Front.Models;

namespace StarWarsKb.Front.Controllers
{
public class HomeController : Controller
{
private readonly ILogger<HomeController> _logger;

public HomeController(ILogger<HomeController> logger)
{
_logger = logger;
}

public IActionResult Index()
{
return View();
}

public IActionResult Privacy()
{
return View();
}

[ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)]
public IActionResult Error()
{
return View(new ErrorViewModel {RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier});
}
}
}
Loading

0 comments on commit 2bd2c1b

Please sign in to comment.