Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System.Threading;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using O2NextGen.ESender.Api.Helpers;
using O2NextGen.ESender.Api.Mappings;
Expand All @@ -8,6 +9,7 @@

namespace O2NextGen.ESender.Api.Controllers
{
[AllowAnonymous]
[Route("api/[controller]")]
public class EmailSenderController : ControllerBase
{
Expand Down Expand Up @@ -48,7 +50,7 @@ public async Task<IActionResult> GetByIdAsync(long id, CancellationToken ct)

[HttpPut]
[Route("id")]
public async Task<IActionResult> UpdateAsync(long id, MailRequestViewModel model, CancellationToken ct)
public async Task<IActionResult> UpdateAsync(long id, [FromBody]MailRequestViewModel model, CancellationToken ct)
{
var certificate = await _emailSenderService.UpdateAsync(model.ToModel(), ct);
return Ok(certificate.ToViewModel());
Expand All @@ -57,10 +59,10 @@ public async Task<IActionResult> UpdateAsync(long id, MailRequestViewModel model
[HttpPost]
[HttpPut]
[Route("")]
public async Task<IActionResult> AddAsync(MailRequestViewModel model, CancellationToken ct)
public async Task<IActionResult> AddAsync([FromBody]MailRequestViewModel model, CancellationToken ct)
{
var certificate = await _emailSenderService.AddAsync(model.ToModel(), ct);
return CreatedAtAction(nameof(GetByIdAsync), new {id = certificate.Id}, certificate);
var emailRequest = await _emailSenderService.AddAsync(model.ToModel(), ct);
return CreatedAtAction(nameof(GetByIdAsync), new {id = emailRequest.Id}, emailRequest);
}

#endregion
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
using System;
using System.Linq;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.Formatters;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Newtonsoft.Json;
using Newtonsoft.Json.Converters;
using Newtonsoft.Json.Serialization;
using O2NextGen.ESender.Api.Filters;
using O2NextGen.ESender.Api.Helpers;
using O2NextGen.ESender.Business.Services;
Expand Down Expand Up @@ -40,8 +45,10 @@ public static IServiceCollection AddBusiness(this IServiceCollection services)
public static IServiceCollection AddRequiredMvcComponents(this IServiceCollection services)
{
services.AddTransient<ApiExceptionFilter>();

var mvcBuilder = services.AddMvcCore(options => { options.Filters.Add<ApiExceptionFilter>(); });
var mvcBuilder = services.AddMvcCore(options =>
{
options.Filters.Add<ApiExceptionFilter>();
});
mvcBuilder.SetCompatibilityVersion(CompatibilityVersion.Version_2_2);
mvcBuilder.AddJsonFormatters();
return services;
Expand Down
2 changes: 1 addition & 1 deletion src/Services/e-sender/O2NextGen.ESender.Api/Startup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public Startup(IConfiguration appConfiguration)

public void ConfigureServices(IServiceCollection services)
{
services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_1);
services.AddRequiredMvcComponents();
services.AddBusiness();
services.ConfigurePOCO<SenderConfig>(AppConfiguration.GetSection("Sender"));
}
Expand Down