Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
02a145f
commit 706c897
Showing
25 changed files
with
1,243 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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; } | ||
} | ||
} |
85 changes: 85 additions & 0 deletions
85
SuperHeroApi/Data/ContextConfigurations/MovieContextConfiguration.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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] | ||
}); | ||
} | ||
} | ||
} |
43 changes: 43 additions & 0 deletions
43
SuperHeroApi/Data/ContextConfigurations/SuperheroContextConfiguration.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
}); | ||
} | ||
} | ||
} |
71 changes: 71 additions & 0 deletions
71
SuperHeroApi/Data/ContextConfigurations/SuperpowerContextConfiguration.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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] | ||
}); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
namespace SuperHeroApi.Interfaces | ||
{ | ||
public interface IMovieRepository | ||
{ | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
namespace SuperHeroApi.Interfaces | ||
{ | ||
public interface ISuperheroRepository | ||
{ | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
namespace SuperHeroApi.Interfaces | ||
{ | ||
public interface ISuperpowerRepository | ||
{ | ||
|
||
} | ||
} |
Oops, something went wrong.