Skip to content

Commit

Permalink
ref(issue-149): update classes for gateway web-api
Browse files Browse the repository at this point in the history
  • Loading branch information
live-dev999 committed Jan 14, 2022
1 parent 3188b2b commit de2ab3a
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public async Task<IActionResult> GetAllAsync()
[Route("{id}")]
public async Task<IActionResult> GetByIdAsync(long id, CancellationToken ct)
{
var result = _senderService.GetAsync(id, ct);
var result =await _senderService.GetAsync(id, ct);
return Ok(result);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public async Task<MailRequestViewModel> AddAsync(MailRequestViewModel model, Can

public async Task<MailRequestViewModel> GetAsync(long id, CancellationToken ct)
{
var response = await _httpClient.GetAsync(_config.Value.ESenderUrl+"/api/emailsender",ct);
var response = await _httpClient.GetAsync(_config.Value.ESenderUrl+$"/api/emailsender/{id}",ct);
return await response.Content.ReadAsAsync<MailRequestViewModel>(ct);

}
Expand Down
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("board")]
public class BoardController : Controller
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ public async Task<IActionResult> UpdateAsync(long id, [FromBody]MailRequestViewM
public async Task<IActionResult> AddAsync([FromBody]MailRequestViewModel model, CancellationToken ct)
{
var emailRequest = await _emailSenderService.AddAsync(model.ToModel(), ct);
await _emailSender.Send(model.To, model.Subject, model.Body);
return CreatedAtAction(nameof(GetByIdAsync), new {id = emailRequest.Id}, emailRequest);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,26 @@ public static IServiceCollection AddBusiness(this IServiceCollection services)
public static IServiceCollection AddRequiredMvcComponents(this IServiceCollection services)
{
services.AddTransient<ApiExceptionFilter>();
var mvcBuilder = services.AddMvcCore(options =>

var mvcBuilder = services.AddMvc(options =>
{
options.Filters.Add<ApiExceptionFilter>();
});
mvcBuilder.SetCompatibilityVersion(CompatibilityVersion.Version_2_2);
mvcBuilder.AddJsonFormatters();
//var mvcBuilder = services.AddMvcCore(options =>
//{
// options.Filters.Add<ApiExceptionFilter>();
//});
//mvcBuilder.AddJsonFormatters();

//mvcBuilder.AddAuthorization();
// mvcBuilder.AddFormatterMappings();
//mvcBuilder.AddRazorViewEngine();
//mvcBuilder.AddRazorPages();
//mvcBuilder.AddCacheTagHelper();
//mvcBuilder.AddDataAnnotations();

//mvcBuilder.AddCors();
return services;
}
}
Expand Down
1 change: 1 addition & 0 deletions src/Services/e-sender/O2NextGen.ESender.Api/Startup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ public void Configure(IApplicationBuilder app, IHostingEnvironment env)
await next.Invoke();
});
app.UseAuthentication();
app.UseHttpsRedirection();
app.UseMvc();
}
Expand Down

0 comments on commit de2ab3a

Please sign in to comment.