-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Renamed projects and added to slides
- Loading branch information
Showing
57 changed files
with
862 additions
and
189 deletions.
There are no files selected for viewing
15 changes: 15 additions & 0 deletions
15
FunctionalCarterProject/Features/NamedDelegatesFilms/CastMembers/GetCastByFilmIdQuery.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,15 @@ | ||
namespace FunctionalCarterProject.Features.NamedDelegatesFilms.CastMembers | ||
{ | ||
using System.Collections.Generic; | ||
using Models; | ||
|
||
public static class GetCastByFilmIdQuery | ||
{ | ||
public static IEnumerable<CastMember> Execute(int filmId) | ||
{ | ||
//Do some SQL | ||
|
||
return new[] { new CastMember { Name = "John Travolta" }, new CastMember { Name = "Samuel L Jackson" } }; | ||
} | ||
} | ||
} |
14 changes: 14 additions & 0 deletions
14
FunctionalCarterProject/Features/NamedDelegatesFilms/Directors/GetDirectorByIdQuery.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,14 @@ | ||
namespace FunctionalCarterProject.Features.NamedDelegatesFilms.Directors | ||
{ | ||
using Models; | ||
|
||
public static class GetDirectorByIdQuery | ||
{ | ||
public static Director Execute(int id) | ||
{ | ||
//Do some SQL | ||
|
||
return new Director { Name = "Steven Spielberg" }; | ||
} | ||
} | ||
} |
20 changes: 20 additions & 0 deletions
20
FunctionalCarterProject/Features/NamedDelegatesFilms/Films/CreateFilm/CreateFilmRoute.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,20 @@ | ||
namespace FunctionalCarterProject.Features.NamedDelegatesFilms.Films.CreateFilm | ||
{ | ||
using System; | ||
using Models; | ||
|
||
public static class CreateFilmRoute | ||
{ | ||
public static void Handle(Film film, ValidUserDelegate validUserQuery) | ||
{ | ||
if (!validUserQuery()) | ||
{ | ||
throw new InvalidOperationException(); | ||
} | ||
|
||
//Do some special MEGA CORP business validation | ||
|
||
//Save to database by writing SQL here | ||
} | ||
} | ||
} |
21 changes: 21 additions & 0 deletions
21
FunctionalCarterProject/Features/NamedDelegatesFilms/Films/Delegates.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,21 @@ | ||
namespace FunctionalCarterProject.Features.NamedDelegatesFilms.Films | ||
{ | ||
using System.Collections.Generic; | ||
using Models; | ||
|
||
public delegate Film ListFilmByIdDelegate(int id); | ||
|
||
public delegate void CreateFilmDelegate(Film film); | ||
|
||
public delegate void DeleteFilmDelegate(int id); | ||
|
||
public delegate IEnumerable<Film> ListFilmsDelegate(); | ||
|
||
public delegate void UpdateFilmDelegate(int id, Film film); | ||
|
||
public delegate bool ValidUserDelegate(); | ||
|
||
public delegate Director GetDirectorByIdDelegate(int id); | ||
|
||
public delegate IEnumerable<CastMember> GetCastByFilmIdDelegate(int filmId); | ||
} |
17 changes: 17 additions & 0 deletions
17
FunctionalCarterProject/Features/NamedDelegatesFilms/Films/DeleteFilm/DeleteFilmRoute.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,17 @@ | ||
namespace FunctionalCarterProject.Features.NamedDelegatesFilms.Films.DeleteFilm | ||
{ | ||
using System; | ||
|
||
public static class DeleteFilmRoute | ||
{ | ||
public static void Handle(int id, ValidUserDelegate validUserQuery) | ||
{ | ||
if (!validUserQuery()) | ||
{ | ||
throw new InvalidOperationException(); | ||
} | ||
|
||
//Write some SQL to delete from DB | ||
} | ||
} | ||
} |
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
25 changes: 25 additions & 0 deletions
25
FunctionalCarterProject/Features/NamedDelegatesFilms/Films/ListFilmById/ListFilmByIdRoute.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,25 @@ | ||
namespace FunctionalCarterProject.Features.NamedDelegatesFilms.Films.ListFilmById | ||
{ | ||
using Models; | ||
|
||
public static class ListFilmByIdRoute | ||
{ | ||
public static Film Handle(int id, ListFilmByIdDelegate listFilmById, GetDirectorByIdDelegate getDirectorByIdDelegate, GetCastByFilmIdDelegate getCastByFilmIdDelegateQuery) | ||
{ | ||
var film = listFilmById(id); | ||
|
||
if (film == null) | ||
{ | ||
return null; | ||
} | ||
|
||
var director = getDirectorByIdDelegate(film.DirectorId); | ||
film.Director = director; | ||
|
||
var cast = getCastByFilmIdDelegateQuery(id); | ||
film.Cast = cast; | ||
|
||
return film; | ||
} | ||
} | ||
} |
13 changes: 13 additions & 0 deletions
13
FunctionalCarterProject/Features/NamedDelegatesFilms/Films/ListFilms/ListFilmsRoute.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,13 @@ | ||
namespace FunctionalCarterProject.Features.NamedDelegatesFilms.Films.ListFilms | ||
{ | ||
using System.Collections.Generic; | ||
using Models; | ||
|
||
public static class ListFilmsRoute | ||
{ | ||
public static IEnumerable<Film> Handle() | ||
{ | ||
return new[] { new Film { Id = 1, Name = "Pulp Fiction" }, new Film { Id = 2, Name = "Trainspotting" } }; | ||
} | ||
} | ||
} |
12 changes: 12 additions & 0 deletions
12
...CarterProject/Features/NamedDelegatesFilms/Films/ListFilmsByIdQuery/ListFilmsByIdQuery.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,12 @@ | ||
namespace FunctionalCarterProject.Features.NamedDelegatesFilms.Films.ListFilmsByIdQuery | ||
{ | ||
using Models; | ||
|
||
public static class ListFilmsByIdQuery | ||
{ | ||
public static Film Execute(int id) | ||
{ | ||
return new Film { Id = 1, Name = "Pulp Fiction", DirectorId = 1 }; | ||
} | ||
} | ||
} |
12 changes: 12 additions & 0 deletions
12
FunctionalCarterProject/Features/NamedDelegatesFilms/Films/Permissions/ValidUserQuery.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,12 @@ | ||
namespace FunctionalCarterProject.Features.NamedDelegatesFilms.Films.Permissions | ||
{ | ||
using System; | ||
|
||
public static class ValidUserQuery | ||
{ | ||
public static bool Execute() | ||
{ | ||
return new Random().Next() % 2 == 0; | ||
} | ||
} | ||
} |
46 changes: 46 additions & 0 deletions
46
FunctionalCarterProject/Features/NamedDelegatesFilms/Films/RouteHandlers.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,46 @@ | ||
namespace FunctionalCarterProject.Features.NamedDelegatesFilms.Films | ||
{ | ||
using FunctionalCarterProject.Features.NamedDelegatesFilms.CastMembers; | ||
using FunctionalCarterProject.Features.NamedDelegatesFilms.Directors; | ||
using FunctionalCarterProject.Features.NamedDelegatesFilms.Films.CreateFilm; | ||
using FunctionalCarterProject.Features.NamedDelegatesFilms.Films.DeleteFilm; | ||
using FunctionalCarterProject.Features.NamedDelegatesFilms.Films.ListFilmById; | ||
using FunctionalCarterProject.Features.NamedDelegatesFilms.Films.ListFilms; | ||
using FunctionalCarterProject.Features.NamedDelegatesFilms.Films.Permissions; | ||
using FunctionalCarterProject.Features.NamedDelegatesFilms.Films.UpdateFilm; | ||
|
||
public static class RouteHandlers | ||
{ | ||
public static CreateFilmDelegate CreateFilmHandler; | ||
|
||
public static ListFilmByIdDelegate ListFilmByIdHandler; | ||
|
||
public static DeleteFilmDelegate DeleteFilmHandler; | ||
|
||
public static ListFilmsDelegate ListFilmsHandler; | ||
|
||
public static UpdateFilmDelegate UpdateFilmHandler; | ||
|
||
static RouteHandlers() | ||
{ | ||
CreateFilmHandler = film => CreateFilmRoute.Handle(film, () => ValidUserQuery.Execute()); | ||
|
||
DeleteFilmHandler = id => DeleteFilmRoute.Handle(id, () => ValidUserQuery.Execute()); | ||
|
||
ListFilmByIdHandler = id => ListFilmByIdRoute.Handle( | ||
id, | ||
filmId => ListFilmsByIdQuery.ListFilmsByIdQuery.Execute(id), | ||
dirId => GetDirectorByIdQuery.Execute(dirId), | ||
filmId => GetCastByFilmIdQuery.Execute(id) | ||
); | ||
|
||
ListFilmsHandler = () => ListFilmsRoute.Handle(); | ||
|
||
UpdateFilmHandler = (id, film) => UpdateFilmRoute.Handle( | ||
id, | ||
film, | ||
() => ValidUserQuery.Execute(), | ||
filmId => ListFilmsByIdQuery.ListFilmsByIdQuery.Execute(filmId)); | ||
} | ||
} | ||
} |
26 changes: 26 additions & 0 deletions
26
FunctionalCarterProject/Features/NamedDelegatesFilms/Films/UpdateFilm/UpdateFilmRoute.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,26 @@ | ||
namespace FunctionalCarterProject.Features.NamedDelegatesFilms.Films.UpdateFilm | ||
{ | ||
using System; | ||
using Models; | ||
|
||
public static class UpdateFilmRoute | ||
{ | ||
public static void Handle(int id, Film film, ValidUserDelegate validUserQuery, ListFilmByIdDelegate listFilmById) | ||
{ | ||
if (!validUserQuery()) | ||
{ | ||
throw new InvalidOperationException(); | ||
} | ||
|
||
//Do some special MEGA CORP business validation | ||
|
||
var existingFilm = listFilmById(id); | ||
|
||
existingFilm.Name = film.Name; | ||
existingFilm.Budget = film.Budget; | ||
existingFilm.Language = film.Language; | ||
|
||
//Write some SQL to store in db | ||
} | ||
} | ||
} |
5 changes: 2 additions & 3 deletions
5
BotwinMediator/BotwinMediator.csproj → ...terProject/FunctionalCarterProject.csproj
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
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,16 @@ | ||
namespace FunctionalCarterProject | ||
{ | ||
using Microsoft.AspNetCore; | ||
using Microsoft.AspNetCore.Hosting; | ||
|
||
public class Program | ||
{ | ||
public static void Main(string[] args) | ||
{ | ||
WebHost.CreateDefaultBuilder(args) | ||
.UseStartup<Startup>() | ||
.Build() | ||
.Run(); | ||
} | ||
} | ||
} |
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,20 @@ | ||
namespace FunctionalCarterProject | ||
{ | ||
using Carter; | ||
using Microsoft.AspNetCore.Builder; | ||
using Microsoft.Extensions.DependencyInjection; | ||
|
||
public class Startup | ||
{ | ||
public void ConfigureServices(IServiceCollection services) | ||
{ | ||
//services.AddCarter(Assembly.GetCallingAssembly(), typeof(FilmValidator).Assembly); | ||
services.AddCarter(); | ||
} | ||
|
||
public void Configure(IApplicationBuilder app) | ||
{ | ||
app.UseCarter(); | ||
} | ||
} | ||
} |
Oops, something went wrong.