diff --git a/Shared.Models/Ticket.cs b/Shared.Models/Ticket.cs index e02beff..d0e57b6 100644 --- a/Shared.Models/Ticket.cs +++ b/Shared.Models/Ticket.cs @@ -1,14 +1,12 @@ using System; -using System.Collections.Generic; -using System.Text; namespace Shared.Models { - public class Ticket - { - public string UserName { get; set; } - public DateTime BookedOn { get; set; } - public string Boarding { get; set; } - public string Destination { get; set; } - } + public class Ticket + { + public string UserName { get; set; } + public DateTime BookedOn { get; set; } + public string Boarding { get; set; } + public string Destination { get; set; } + } } diff --git a/TicketProcessor.Microservice/Program.cs b/TicketProcessor.Microservice/Program.cs index ef733b8..9e6e3aa 100644 --- a/TicketProcessor.Microservice/Program.cs +++ b/TicketProcessor.Microservice/Program.cs @@ -1,26 +1,20 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Threading.Tasks; using Microsoft.AspNetCore.Hosting; -using Microsoft.Extensions.Configuration; using Microsoft.Extensions.Hosting; -using Microsoft.Extensions.Logging; namespace TicketProcessor.Microservice { - public class Program - { - public static void Main(string[] args) - { - CreateHostBuilder(args).Build().Run(); - } + public class Program + { + public static void Main(string[] args) + { + CreateHostBuilder(args).Build().Run(); + } - public static IHostBuilder CreateHostBuilder(string[] args) => - Host.CreateDefaultBuilder(args) - .ConfigureWebHostDefaults(webBuilder => - { - webBuilder.UseStartup(); - }); - } + public static IHostBuilder CreateHostBuilder(string[] args) => + Host.CreateDefaultBuilder(args) + .ConfigureWebHostDefaults(webBuilder => + { + webBuilder.UseStartup(); + }); + } } diff --git a/TicketProcessor.Microservice/Startup.cs b/TicketProcessor.Microservice/Startup.cs index a7bb605..0e86714 100644 --- a/TicketProcessor.Microservice/Startup.cs +++ b/TicketProcessor.Microservice/Startup.cs @@ -19,7 +19,6 @@ 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) { services.AddMassTransit(x => @@ -45,7 +44,6 @@ public void ConfigureServices(IServiceCollection services) services.AddControllers(); } - // This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IWebHostEnvironment env) { if (env.IsDevelopment()) diff --git a/TicketProcessor.Microservice/TicketProcessor.Microservice.csproj b/TicketProcessor.Microservice/TicketProcessor.Microservice.csproj index 03bfc6e..fdf72f7 100644 --- a/TicketProcessor.Microservice/TicketProcessor.Microservice.csproj +++ b/TicketProcessor.Microservice/TicketProcessor.Microservice.csproj @@ -4,6 +4,13 @@ netcoreapp3.1 + + + + + + + @@ -11,10 +18,6 @@ - - - - diff --git a/Ticketing.Microservice/Controllers/TicketController.cs b/Ticketing.Microservice/Controllers/TicketController.cs index 3f4d68d..ad6e064 100644 --- a/Ticketing.Microservice/Controllers/TicketController.cs +++ b/Ticketing.Microservice/Controllers/TicketController.cs @@ -6,28 +6,28 @@ namespace Ticketing.Microservice.Controllers { - [Route("api/[controller]")] - [ApiController] - public class TicketController : ControllerBase - { - private readonly IBus _bus; + [Route("api/[controller]")] + [ApiController] + public class TicketController : ControllerBase + { + private readonly IBus _bus; - public TicketController(IBus bus) - { - _bus = bus; - } - [HttpPost] - public async Task CreateTicket(Ticket ticket) - { - if (ticket != null) - { - ticket.BookedOn = DateTime.Now; - Uri uri = new Uri("rabbitmq://localhost/ticketQueue"); - var endPoint = await _bus.GetSendEndpoint(uri); - await endPoint.Send(ticket); - return Ok(); - } - return BadRequest(); - } - } + public TicketController(IBus bus) + { + _bus = bus; + } + [HttpPost] + public async Task CreateTicket(Ticket ticket) + { + if (ticket != null) + { + ticket.BookedOn = DateTime.Now; + Uri uri = new Uri("rabbitmq://localhost/ticketQueue"); + var endPoint = await _bus.GetSendEndpoint(uri); + await endPoint.Send(ticket); + return Ok(); + } + return BadRequest(); + } + } } \ No newline at end of file diff --git a/Ticketing.Microservice/Program.cs b/Ticketing.Microservice/Program.cs index 3f0b597..fba5762 100644 --- a/Ticketing.Microservice/Program.cs +++ b/Ticketing.Microservice/Program.cs @@ -1,11 +1,5 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Threading.Tasks; using Microsoft.AspNetCore.Hosting; -using Microsoft.Extensions.Configuration; using Microsoft.Extensions.Hosting; -using Microsoft.Extensions.Logging; namespace Ticketing.Microservice { diff --git a/Ticketing.Microservice/Startup.cs b/Ticketing.Microservice/Startup.cs index 0af655f..3d73ac0 100644 --- a/Ticketing.Microservice/Startup.cs +++ b/Ticketing.Microservice/Startup.cs @@ -14,52 +14,50 @@ namespace Ticketing.Microservice { - public class Startup - { - public Startup(IConfiguration configuration) - { - Configuration = 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) - { - services.AddMassTransit(x => - { - x.AddBus(provider => Bus.Factory.CreateUsingRabbitMq(config => - { - config.UseHealthCheck(provider); - config.Host(new Uri("rabbitmq://localhost"), h => - { - h.Username("guest"); - h.Password("guest"); - }); - })); - }); - services.AddMassTransitHostedService(); - services.AddControllers(); - } - - // This method gets called by the runtime. Use this method to configure the HTTP request pipeline. - public void Configure(IApplicationBuilder app, IWebHostEnvironment env) - { - if (env.IsDevelopment()) - { - app.UseDeveloperExceptionPage(); - } - - app.UseHttpsRedirection(); - - app.UseRouting(); - - app.UseAuthorization(); - - app.UseEndpoints(endpoints => - { - endpoints.MapControllers(); - }); - } - } + public class Startup + { + public Startup(IConfiguration configuration) + { + Configuration = configuration; + } + + public IConfiguration Configuration { get; } + + public void ConfigureServices(IServiceCollection services) + { + services.AddMassTransit(x => + { + x.AddBus(provider => Bus.Factory.CreateUsingRabbitMq(config => + { + config.UseHealthCheck(provider); + config.Host(new Uri("rabbitmq://localhost"), h => + { + h.Username("guest"); + h.Password("guest"); + }); + })); + }); + services.AddMassTransitHostedService(); + services.AddControllers(); + } + + public void Configure(IApplicationBuilder app, IWebHostEnvironment env) + { + if (env.IsDevelopment()) + { + app.UseDeveloperExceptionPage(); + } + + app.UseHttpsRedirection(); + + app.UseRouting(); + + app.UseAuthorization(); + + app.UseEndpoints(endpoints => + { + endpoints.MapControllers(); + }); + } + } }