Skip to content

Commit

Permalink
Merge pull request #326 from kalilventura/CorrectionsVersionMigration
Browse files Browse the repository at this point in the history
Corrections version migration
  • Loading branch information
raffacabofrio authored Apr 19, 2020
2 parents 5e49484 + 017f135 commit 8714a8f
Show file tree
Hide file tree
Showing 7 changed files with 17 additions and 82 deletions.
16 changes: 0 additions & 16 deletions ShareBook/ShareBook.Api/AutoMapper/AutoMapperConfig.cs

This file was deleted.

10 changes: 4 additions & 6 deletions ShareBook/ShareBook.Api/Configuration/SwaggerConfiguration.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
using Microsoft.Extensions.DependencyInjection;
using Microsoft.OpenApi.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;

namespace ShareBook.Api.Configuration
{
Expand All @@ -13,10 +11,10 @@ public static IServiceCollection RegisterSwagger(this IServiceCollection service
{
services.AddSwaggerGen(swagger =>
{
swagger.SwaggerDoc("v2", new OpenApiInfo
swagger.SwaggerDoc("v1", new OpenApiInfo
{
Title = "SHAREBOOK API",
Version = "v2",
Version = "v1",
Description = "Open Source project",
Contact = new OpenApiContact
{
Expand All @@ -25,8 +23,8 @@ public static IServiceCollection RegisterSwagger(this IServiceCollection service
},
License = new OpenApiLicense
{
Name = "",
//Url = new Uri("")
Name = "MIT License",
Url = new Uri("https://opensource.org/licenses/MIT")
}
});
swagger.ResolveConflictingActions(x => x.First());
Expand Down
19 changes: 10 additions & 9 deletions ShareBook/ShareBook.Api/Controllers/CategoryController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,17 @@
using ShareBook.Domain.Common;
using ShareBook.Service;

namespace ShareBook.Api.Controllers {
[Route ("api/[controller]")]
public class CategoryController : BaseCrudController<Category> {
private readonly IMapper _mapper;
public CategoryController (ICategoryService categoryService,
IMapper mapper) : base (categoryService, mapper) {
_mapper = mapper;
SetDefault (x => x.Name);
namespace ShareBook.Api.Controllers
{
[Route("api/[controller]")]
public class CategoryController : BaseCrudController<Category>
{
public CategoryController(ICategoryService categoryService,
IMapper mapper) : base(categoryService, mapper)
{
SetDefault(x => x.Name);
}

public override PagedList<Category> GetAll () => Paged (1, 50);
public override PagedList<Category> GetAll() => Paged(1, 50);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,7 @@ namespace ShareBook.Api.Controllers
public class BaseCrudController<T> : BaseCrudController<T, T, T>
where T : BaseEntity
{
protected readonly IMapper _mapper;

public BaseCrudController(IBaseService<T> service, IMapper mapper) : base(service, mapper)
{
_mapper = mapper;
}
public BaseCrudController(IBaseService<T> service, IMapper mapper) : base(service, mapper) { }
}

public class BaseCrudController<T, R> : BaseDeleteController<T, R, T>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@

namespace ShareBook.Api.Middleware
{
// You may need to install the Microsoft.AspNetCore.Http.Abstractions package into your project
public class ExceptionHandlerMiddleware
{
private readonly RequestDelegate _next;
Expand Down Expand Up @@ -60,7 +59,7 @@ private void SendErrorToRollbar(Exception ex)
StackTrace = ex.StackTrace,
Source = ex.Source
};

RollbarLocator.RollbarInstance.Log(ErrorLevel.Critical, error);
}
}
Expand Down
41 changes: 0 additions & 41 deletions ShareBook/ShareBook.Api/Startup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,13 @@
using Microsoft.AspNetCore.Diagnostics.HealthChecks;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Diagnostics.HealthChecks;
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Logging;
using Rollbar.NetCore.AspNet;
using ShareBook.Api.AutoMapper;
using ShareBook.Api.Configuration;
using ShareBook.Api.Middleware;
using ShareBook.Api.Services;
Expand All @@ -21,10 +19,7 @@
using ShareBook.Service.Notification;
using ShareBook.Service.Server;
using ShareBook.Service.Upload;
using Swashbuckle.AspNetCore.Swagger;
using System;
using System.Collections.Generic;
using System.Linq;

namespace ShareBook.Api
{
Expand All @@ -37,25 +32,19 @@ public Startup(IConfiguration 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)
{
RegisterHealthChecks(services, Configuration.GetConnectionString("DefaultConnection"));

services.RegisterRepositoryServices();
//auto mapper start
//AutoMapperConfig.RegisterMappings();

services.AddAutoMapper(typeof(Startup));

services
.AddControllers()
.AddJsonOptions(options =>
{
options.JsonSerializerOptions.IgnoreNullValues = true;
//options.SerializerSettings.NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore;
});
//.SetCompatibilityVersion(CompatibilityVersion.Version_2_2);

services
.AddHttpContextAccessor()
Expand All @@ -76,21 +65,6 @@ public void ConfigureServices(IServiceCollection services)

services.RegisterSwagger();

//services.AddSwaggerGen(c =>
//{
// c.SwaggerDoc("v1", new Info { Title = "SHAREBOOK API", Version = "v1" });
// c.ResolveConflictingActions(x => x.First());
// c.AddSecurityDefinition("Bearer", new ApiKeyScheme
// {
// Description = "JWT Authorization header using the Bearer scheme. Example: \"Authorization: Bearer {token}\"",
// Name = "Authorization",
// In = "header",
// Type = "apiKey"
// });
// c.AddSecurityRequirement(new Dictionary<string, IEnumerable<string>> { { "Bearer", Enumerable.Empty<string> () },
// });
//});

services.AddCors(options =>
{
options.AddPolicy("AllowAllHeaders",
Expand All @@ -112,8 +86,6 @@ public void ConfigureServices(IServiceCollection services)
MuambatorConfigurator.Configure(Configuration.GetSection("Muambator:Token").Value, Configuration.GetSection("Muambator:IsActive").Value);
}

// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
//public void Configure(IApplicationBuilder app, IHostingEnvironment env)
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
{
bool rollbarActive = Convert.ToBoolean(Configuration.GetSection("Rollbar:IsActive").Value.ToLower());
Expand All @@ -123,8 +95,6 @@ public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
}

app.UseHealthChecks("/hc");
//app.UseCors("AllowAllHeaders");

app.UseDeveloperExceptionPage();
app.UseExceptionHandlerMiddleware();

Expand All @@ -143,17 +113,6 @@ public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
c.SwaggerEndpoint("/swagger/v1/swagger.json", "SHAREBOOK API V1");
});

// IMPORTANT: Make sure UseCors() is called BEFORE this
//app.UseMvc(routes =>
//{
// routes.MapRoute(
// name: "default",
// template: "{controller=Book}/{action=Index}/{id?}");

// routes.MapSpaFallbackRoute(
// name: "spa-fallback",
// defaults: new { controller = "ClientSpa", action = "Index" });
//});
app.UseRouting();

app.UseCors("AllowAllHeaders");
Expand Down
3 changes: 1 addition & 2 deletions ShareBook/ShareBook.Api/ViewModels/AddFaciclitatorNotesVM.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using ShareBook.Domain.Enums;
using System;
using System;

namespace ShareBook.Api.ViewModels
{
Expand Down

0 comments on commit 8714a8f

Please sign in to comment.