Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added CQRS, MediatR & React SemanticUI #6

Merged
merged 3 commits into from
Dec 17, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
added MediatR pattern & React SemanticUI
  • Loading branch information
bahmani00 committed Dec 17, 2020
commit 67341aa95891db6bfa007c4beba332d9a9099d34
63 changes: 63 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
###############################################################################
# Set default behavior to automatically normalize line endings.
###############################################################################
* text=auto

###############################################################################
# Set default behavior for command prompt diff.
#
# This is need for earlier builds of msysgit that does not have it on by
# default for csharp files.
# Note: This is only used by command line
###############################################################################
#*.cs diff=csharp

###############################################################################
# Set the merge driver for project and solution files
#
# Merging from the command prompt will add diff markers to the files if there
# are conflicts (Merging from VS is not affected by the settings below, in VS
# the diff markers are never inserted). Diff markers may cause the following
# file extensions to fail to load in VS. An alternative would be to treat
# these files as binary and thus will always conflict and require user
# intervention with every merge. To do so, just uncomment the entries below
###############################################################################
#*.sln merge=binary
#*.csproj merge=binary
#*.vbproj merge=binary
#*.vcxproj merge=binary
#*.vcproj merge=binary
#*.dbproj merge=binary
#*.fsproj merge=binary
#*.lsproj merge=binary
#*.wixproj merge=binary
#*.modelproj merge=binary
#*.sqlproj merge=binary
#*.wwaproj merge=binary

###############################################################################
# behavior for image files
#
# image files are treated as binary by default.
###############################################################################
#*.jpg binary
#*.png binary
#*.gif binary

###############################################################################
# diff behavior for common document formats
#
# Convert binary document formats to text before diffing them. This feature
# is only available from the command line. Turn it on by uncommenting the
# entries below.
###############################################################################
#*.doc diff=astextplain
#*.DOC diff=astextplain
#*.docx diff=astextplain
#*.DOCX diff=astextplain
#*.dot diff=astextplain
#*.DOT diff=astextplain
#*.pdf diff=astextplain
#*.PDF diff=astextplain
#*.rtf diff=astextplain
#*.RTF diff=astextplain
5 changes: 5 additions & 0 deletions API/API.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@
<TargetFramework>netcoreapp3.1</TargetFramework>
</PropertyGroup>
<ItemGroup>
<None Remove="facebuk.db" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="MediatR" Version="9.0.0" />
<PackageReference Include="MediatR.Extensions.Microsoft.DependencyInjection" Version="7.0.0"/>
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="3.1.10" />
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="5.0.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="5.0.0">
Expand Down
27 changes: 27 additions & 0 deletions API/Controllers/ActivityContoller.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
using Application.Activities;
using Domain;
using MediatR;
using Microsoft.AspNetCore.Mvc;
using System.Collections.Generic;
using System.Threading.Tasks;

namespace API.Controllers
{
[ApiController]
[Route("api/[controller]")]
public class ActivityContoller : ControllerBase
{
private readonly IMediator mediator;

public ActivityContoller(IMediator mediator)
{
this.mediator = mediator;
}

[HttpGet]
public async Task<List<Activity>> Get()
{
return await mediator.Send(new List.Query());
}
}
}
55 changes: 25 additions & 30 deletions API/Program.cs
Original file line number Diff line number Diff line change
@@ -1,44 +1,39 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Hosting;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Logging;
using Persistence;

namespace API
{
public class Program
{
public static void Main(string[] args)
{
var host = CreateHostBuilder(args).Build();
using(var scope = host.Services.CreateScope()){
var services = scope.ServiceProvider;
try
{
var context = services.GetRequiredService<FacebukDbContext>();
context.Database.Migrate();
}
catch (Exception ex)
{
var logger = services.GetRequiredService<ILogger<Program>>();
logger.LogError(ex, "Error occured during Facebuk db migration.");
}
};
public class Program
{
public static async Task Main(string[] args)
{
var host = CreateHostBuilder(args).Build();
using (var scope = host.Services.CreateScope()) {
var services = scope.ServiceProvider;
try {
var context = services.GetRequiredService<FacebukDbContext>();
await context.Database.MigrateAsync();
await DbSeeder.SeedAsync(context);

host.Run();
}
} catch (Exception ex) {
var logger = services.GetRequiredService<ILogger<Program>>();
logger.LogError(ex, "Error occured during Facebuk db migration.");
}
};

public static IHostBuilder CreateHostBuilder(string[] args) =>
Host.CreateDefaultBuilder(args)
.ConfigureWebHostDefaults(webBuilder =>
{
webBuilder.UseStartup<Startup>();
});
}
host.Run();
}

public static IHostBuilder CreateHostBuilder(string[] args) =>
Host.CreateDefaultBuilder(args)
.ConfigureWebHostDefaults(webBuilder => {
webBuilder.UseStartup<Startup>();
});
}
}
13 changes: 6 additions & 7 deletions API/Startup.cs
Original file line number Diff line number Diff line change
@@ -1,22 +1,18 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Application.Activities;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.HttpsPolicy;
using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Logging;
using Microsoft.OpenApi.Models;
using Persistence;
using MediatR;

namespace API
{
public class Startup
public class Startup
{
public Startup(IConfiguration configuration)
{
Expand All @@ -42,6 +38,9 @@ public void ConfigureServices(IServiceCollection services)
policyBuilder.AllowAnyHeader().AllowAnyMethod().AllowCredentials()
.WithOrigins("http://localhost:3000")
));

services.AddMediatR(typeof(List.Handler).Assembly);
services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_2);
}

// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
Expand Down
1 change: 0 additions & 1 deletion API/client-app/.eslintcache

This file was deleted.

23 changes: 0 additions & 23 deletions API/client-app/.gitignore

This file was deleted.

70 changes: 0 additions & 70 deletions API/client-app/README.md

This file was deleted.

Loading