Skip to content

Commit

Permalink
Add project files.
Browse files Browse the repository at this point in the history
  • Loading branch information
chs-danofficeit committed Jan 22, 2022
1 parent 02a145f commit 706c897
Show file tree
Hide file tree
Showing 25 changed files with 1,243 additions and 0 deletions.
25 changes: 25 additions & 0 deletions .dockerignore
@@ -0,0 +1,25 @@
**/.classpath
**/.dockerignore
**/.env
**/.git
**/.gitignore
**/.project
**/.settings
**/.toolstarget
**/.vs
**/.vscode
**/*.*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
4 changes: 4 additions & 0 deletions .editorconfig
@@ -0,0 +1,4 @@
[*.cs]

# CS8618: Non-nullable field must contain a non-null value when exiting constructor. Consider declaring as nullable.
dotnet_diagnostic.CS8618.severity = silent
30 changes: 30 additions & 0 deletions SuperHeroApi.sln
@@ -0,0 +1,30 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.0.32014.148
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SuperHeroApi", "SuperHeroApi\SuperHeroApi.csproj", "{0B4520C5-2D35-4D48-A908-25DBCA897E39}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{75DC658F-A708-4674-AEE6-483FB21BCB3D}"
ProjectSection(SolutionItems) = preProject
.editorconfig = .editorconfig
EndProjectSection
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{0B4520C5-2D35-4D48-A908-25DBCA897E39}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{0B4520C5-2D35-4D48-A908-25DBCA897E39}.Debug|Any CPU.Build.0 = Debug|Any CPU
{0B4520C5-2D35-4D48-A908-25DBCA897E39}.Release|Any CPU.ActiveCfg = Release|Any CPU
{0B4520C5-2D35-4D48-A908-25DBCA897E39}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {A6DB8171-D299-465B-8EDA-61B35E4686A5}
EndGlobalSection
EndGlobal
31 changes: 31 additions & 0 deletions SuperHeroApi/Data/ApplicationDbContext.cs
@@ -0,0 +1,31 @@
using Microsoft.EntityFrameworkCore;
using SuperHeroApi.Data.ContextConfigurations;
using SuperHeroApi.Models;

namespace SuperHeroApi.Data
{
public class ApplicationDbContext : DbContext
{
public ApplicationDbContext(DbContextOptions options) : base(options)
{

}

protected override void OnModelCreating(ModelBuilder builder)
{
// Generate three GUIDS and place them in an arrays
var ids = new Guid[] {Guid.NewGuid(), Guid.NewGuid(), Guid.NewGuid() };

// Apply configuration for the three contexts in our application
// This will create the demo data for our GraphQL endpoint.
builder.ApplyConfiguration(new SuperheroContextConfiguration(ids));
builder.ApplyConfiguration(new SuperpowerContextConfiguration(ids));
builder.ApplyConfiguration(new MovieContextConfiguration(ids));
}

// Add the DbSets for each of our models we would like at our database
public DbSet<Superhero> Superheroes { get; set; }
public DbSet<Superpower> Superpowers { get; set; }
public DbSet<Movie> Movies { get; set; }
}
}
@@ -0,0 +1,85 @@
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
using SuperHeroApi.Models;

namespace SuperHeroApi.Data.ContextConfigurations
{
public class MovieContextConfiguration : IEntityTypeConfiguration<Movie>
{
private Guid[] _ids;

public MovieContextConfiguration(Guid[] ids)
{
_ids = ids;
}

public void Configure(EntityTypeBuilder<Movie> builder)
{
builder
.HasData(
new Movie
{
Id = Guid.NewGuid(),
Title = "Batman Begins",
Description = "Batman Begins is a 2005 superhero film directed by Christopher Nolan and written by Nolan and David S. Goyer. Based on the DC Comics character Batman, it stars Christian Bale as Bruce Wayne / Batman, with Michael Caine, Liam Neeson, Katie Holmes, Gary Oldman,",
Instructor = "Christopher Nolan",
ReleaseDate = new DateTime(2005, 06, 25),
SuperheroId = _ids[0]
},
new Movie
{
Id= Guid.NewGuid(),
Title = "The Dark Knight",
Description = "The Dark Knight is a 2008 superhero film directed, produced, and co-written by Christopher Nolan. Based on the DC Comics character Batman, the film is the second installment of Nolan's The Dark Knight Trilogy and a sequel to 2005's Batman Begins, starring Christian Bale and supported by Michael Caine, Heath Ledger, Gary Oldman, Aaron Eckhart, Maggie Gyllenhaal, and Morgan Freeman.",
Instructor = "Christopher Nolan",
ReleaseDate = new DateTime(2008, 07, 18),
SuperheroId = _ids[0]
},
new Movie
{
Id = Guid.NewGuid(),
Title = "The Dark Knight Rises",
Description = "The Dark Knight Rises is a 2012 superhero film directed by Christopher Nolan, who co-wrote the screenplay with his brother Jonathan Nolan, and the story with David S. Goyer.",
Instructor = "Christopher Nolan",
ReleaseDate = new DateTime(2012, 07, 20),
SuperheroId = _ids[0]
},
new Movie
{
Id = Guid.NewGuid(),
Title = "Star Wars: Episode IV – A New Hope",
Description = "Star Wars (retroactively titled Star Wars: Episode IV – A New Hope) is a 1977 American epic space opera film written and directed by George Lucas, produced by Lucasfilm and distributed by 20th Century Fox.",
Instructor = "George Lucas",
ReleaseDate = new DateTime(1977, 05, 25),
SuperheroId = _ids[1]
},
new Movie
{
Id = Guid.NewGuid(),
Title = "Star Wars: Episode V – The Empire Strikes Back",
Description = "The Empire Strikes Back (also known as Star Wars: Episode V – The Empire Strikes Back) is a 1980 American epic space opera film directed by Irvin Kershner and written by Leigh Brackett and Lawrence Kasdan, based on a story by George Lucas.",
Instructor = "Irvin Kershner",
ReleaseDate = new DateTime(1980, 05, 21),
SuperheroId = _ids[1]
},
new Movie
{
Id = Guid.NewGuid(),
Title = "Star Wars: Episode VI – Return of the Jedi",
Description = "Return of the Jedi (also known as Star Wars: Episode VI – Return of the Jedi) is a 1983 American epic space opera film directed by Richard Marquand. The screenplay is by Lawrence Kasdan and George Lucas from a story by Lucas, who was also the executive producer.",
Instructor = "Richard Marquand",
ReleaseDate = new DateTime(1983, 05, 25),
SuperheroId = _ids[1]
},
new Movie
{
Id = Guid.NewGuid(),
Title = "Black Widow",
Description = "Black Widow is a 2021 American superhero film based on Marvel Comics featuring the character of the same name. Produced by Marvel Studios and distributed by Walt Disney Studios Motion Pictures, it is the 24th film in the Marvel Cinematic Universe (MCU).",
Instructor = "Cate Shortland",
ReleaseDate = new DateTime(2021, 06, 29),
SuperheroId= _ids[2]
});
}
}
}
@@ -0,0 +1,43 @@
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
using SuperHeroApi.Models;

namespace SuperHeroApi.Data.ContextConfigurations
{
public class SuperheroContextConfiguration : IEntityTypeConfiguration<Superhero>
{
private Guid[] _ids;

public SuperheroContextConfiguration(Guid[] ids)
{
_ids = ids;
}

public void Configure(EntityTypeBuilder<Superhero> builder)
{
builder
.HasData(
new Superhero
{
Id = _ids[0],
Name = "Batman",
Description = "Batman was originally introduced as a ruthless vigilante who frequently killed or maimed criminals, but evolved into a character with a stringent moral code and strong sense of justice. Unlike most superheroes, Batman does not possess any superpowers, instead relying on his intellect, fighting skills, and wealth.",
Height = 1.93
},
new Superhero
{
Id = _ids[1],
Name = "Luke Skywalker",
Description = "Luke Skywalker was a Tatooine farmboy who rose from humble beginnings to become one of the greatest Jedi the galaxy has ever known. Along with his friends Princess Leia and Han Solo, Luke battled the evil Empire, discovered the truth of his parentage, and ended the tyranny of the Sith.",
Height = 1.70
},
new Superhero
{
Id = _ids[2],
Name = "Black Widow",
Description = "Black Widow, real name Natasha Romanoff, is a trained female secret agent and superhero that appears in Marvel Comics. Associated with the superhero teams S.H.I.E.L.D. and the Avengers, Black Widow makes up for her lack of superpowers with world class training as an athlete, acrobat, and expert martial artist and weapon specialist.",
Height = 1.70
});
}
}
}
@@ -0,0 +1,71 @@
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
using SuperHeroApi.Models;

namespace SuperHeroApi.Data.ContextConfigurations
{
public class SuperpowerContextConfiguration : IEntityTypeConfiguration<Superpower>
{
private Guid[] _ids;

public SuperpowerContextConfiguration(Guid[] ids)
{
_ids = ids;
}

public void Configure(EntityTypeBuilder<Superpower> builder)
{
builder
.HasData(
new Superpower
{
Id = Guid.NewGuid(),
SuperPower = "Intellect.",
Description = "He's always a step ahead.",
SuperheroId = _ids[0]
},
new Superpower
{
Id = Guid.NewGuid(),
SuperPower = "Fighting",
Description = "Sublime fighting skills.",
SuperheroId = _ids[0]
},
new Superpower
{
Id = Guid.NewGuid(),
SuperPower = "Wealth.",
Description = "He got a lot of money",
SuperheroId = _ids[0]
},
new Superpower
{
Id = Guid.NewGuid(),
SuperPower = "Deflect blaster power.",
Description = "Skywalker is able to deflect fire from a blaster back at the opponent firing. This enables Luke to turn someone else's weapon against them.",
SuperheroId = _ids[1]
},
new Superpower
{
Id = Guid.NewGuid(),
SuperPower = "Espionage",
Description = "She's good at spying at people.",
SuperheroId = _ids[2]
},
new Superpower
{
Id = Guid.NewGuid(),
SuperPower = "Infiltration",
Description = "She knows how to infiltrate the enemy.",
SuperheroId = _ids[2]
},
new Superpower
{
Id = Guid.NewGuid(),
SuperPower = "Subterfuge",
Description = "The knowledge of how to undermine others.",
SuperheroId = _ids[2]
});
}
}
}
22 changes: 22 additions & 0 deletions SuperHeroApi/Dockerfile
@@ -0,0 +1,22 @@
#See https://aka.ms/containerfastmode to understand how Visual Studio uses this Dockerfile to build your images for faster debugging.

FROM mcr.microsoft.com/dotnet/aspnet:6.0 AS base
WORKDIR /app
EXPOSE 80
EXPOSE 443

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

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

FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
ENTRYPOINT ["dotnet", "SuperHeroApi.dll"]
6 changes: 6 additions & 0 deletions SuperHeroApi/Interfaces/IMovieRepository.cs
@@ -0,0 +1,6 @@
namespace SuperHeroApi.Interfaces
{
public interface IMovieRepository
{
}
}
7 changes: 7 additions & 0 deletions SuperHeroApi/Interfaces/ISuperheroRepository.cs
@@ -0,0 +1,7 @@
namespace SuperHeroApi.Interfaces
{
public interface ISuperheroRepository
{

}
}
7 changes: 7 additions & 0 deletions SuperHeroApi/Interfaces/ISuperpowerRepository.cs
@@ -0,0 +1,7 @@
namespace SuperHeroApi.Interfaces
{
public interface ISuperpowerRepository
{

}
}

0 comments on commit 706c897

Please sign in to comment.