Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
Bryce Coon committed Mar 21, 2024
2 parents 0684d4d + 3fa9845 commit 092f771
Show file tree
Hide file tree
Showing 11 changed files with 332 additions and 12 deletions.
10 changes: 10 additions & 0 deletions BlazorTickets/Components/Layout/NavMenu.razor
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,16 @@
<span class="bi bi-list-nested-nav-menu" aria-hidden="true"></span> Events
</NavLink>
</div>
<div class="nav-item px-3">
<NavLink class="nav-link" href="weather">
<span class="bi bi-list-nested-nav-menu" aria-hidden="true"></span> Weather
</NavLink>
</div>
<div class="nav-item px-3">
<NavLink class="nav-link" href="counter">
<span class="bi bi-list-nested-nav-menu" aria-hidden="true"></span> Counter
</NavLink>
</div>
</nav>
</div>

5 changes: 5 additions & 0 deletions BlazorTickets/Components/Pages/Counter.razor
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
@page "/counter"
@rendermode InteractiveServer
@inject ILogger<Counter> logger;

<PageTitle>Counter</PageTitle>

Expand All @@ -12,6 +13,10 @@
@code {
private int currentCount = 0;

protected override void OnInitialized()
{
}

private void IncrementCount()
{
currentCount++;
Expand Down
1 change: 0 additions & 1 deletion BlazorTickets/Components/Pages/WebTickets.razor
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,3 @@
<h3>WebTickets</h3>

<TicketLibrary.Pages.Tickets></TicketLibrary.Pages.Tickets>

2 changes: 0 additions & 2 deletions BlazorTickets/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,9 @@
builder.Services.AddRazorComponents()
.AddInteractiveServerComponents();

//int aaronsBadWarn = 7;

builder.Services.AddScoped<ITicketService, WebTicketService>();
builder.Services.AddScoped<IEventService, WebEventService>();
//builder.Services.AddScoped<ILogger, ILogger>();
builder.Services.AddControllers();
builder.Services.AddScoped<MailMailMail>();
builder.Services.AddDbContext<PostgresContext>(options => options.UseNpgsql(builder.Configuration["Postgres"]));
Expand Down
33 changes: 31 additions & 2 deletions BlazorTickets/Services/WebEventService.cs
Original file line number Diff line number Diff line change
@@ -1,18 +1,47 @@
using BlazorTickets.Data;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Logging;
using TicketLibrary.Data;
using TicketLibrary.Services;
namespace BlazorTickets.Services;

public class WebEventService : IEventService


public partial class WebEventService : IEventService
{
private readonly ILogger<WebEventService> _logger;


[LoggerMessage(Level = LogLevel.Information, Message = "Getting All Events.")]
static partial void GetAllEvents(ILogger logger, string description);

Check warning on line 16 in BlazorTickets/Services/WebEventService.cs

View workflow job for this annotation

GitHub Actions / test

Argument 'description' is not referenced from the logging message (https://learn.microsoft.com/dotnet/fundamentals/syslib-diagnostics/syslib1015)

Check warning on line 16 in BlazorTickets/Services/WebEventService.cs

View workflow job for this annotation

GitHub Actions / build

Argument 'description' is not referenced from the logging message (https://learn.microsoft.com/dotnet/fundamentals/syslib-diagnostics/syslib1015)

Check warning on line 16 in BlazorTickets/Services/WebEventService.cs

View workflow job for this annotation

GitHub Actions / build

Argument 'description' is not referenced from the logging message (https://learn.microsoft.com/dotnet/fundamentals/syslib-diagnostics/syslib1015)

[LoggerMessage(Level = LogLevel.Error, Message = "Testing the events.")]
static partial void TestEvents1(ILogger logger, string description);

Check warning on line 19 in BlazorTickets/Services/WebEventService.cs

View workflow job for this annotation

GitHub Actions / test

Argument 'description' is not referenced from the logging message (https://learn.microsoft.com/dotnet/fundamentals/syslib-diagnostics/syslib1015)

Check warning on line 19 in BlazorTickets/Services/WebEventService.cs

View workflow job for this annotation

GitHub Actions / build

Argument 'description' is not referenced from the logging message (https://learn.microsoft.com/dotnet/fundamentals/syslib-diagnostics/syslib1015)

Check warning on line 19 in BlazorTickets/Services/WebEventService.cs

View workflow job for this annotation

GitHub Actions / build

Argument 'description' is not referenced from the logging message (https://learn.microsoft.com/dotnet/fundamentals/syslib-diagnostics/syslib1015)

[LoggerMessage(Level = LogLevel.Warning, Message = "Something about events.")]
static partial void TestEvents2(ILogger logger, string description);

Check warning on line 22 in BlazorTickets/Services/WebEventService.cs

View workflow job for this annotation

GitHub Actions / test

Argument 'description' is not referenced from the logging message (https://learn.microsoft.com/dotnet/fundamentals/syslib-diagnostics/syslib1015)

Check warning on line 22 in BlazorTickets/Services/WebEventService.cs

View workflow job for this annotation

GitHub Actions / build

Argument 'description' is not referenced from the logging message (https://learn.microsoft.com/dotnet/fundamentals/syslib-diagnostics/syslib1015)

Check warning on line 22 in BlazorTickets/Services/WebEventService.cs

View workflow job for this annotation

GitHub Actions / build

Argument 'description' is not referenced from the logging message (https://learn.microsoft.com/dotnet/fundamentals/syslib-diagnostics/syslib1015)


PostgresContext _context;
public WebEventService(PostgresContext context)
public WebEventService(PostgresContext context, ILogger<WebEventService> logger)
{
_context = context;
_logger = logger;
}
public async Task<List<Event>> GetAllEventsAsync()
{
GetAllEvents(_logger, $"Inside getAllEvents now. Number of events is {_context.Events.Count()}");
return await _context.Events.ToListAsync<Event>();
}

public void InvokeEventsLogger1(int num1)
{
TestEvents1(_logger, $"Inside invokeEvents now. {num1}");
}

public void InvokeEventsLogger2(int num2)
{
TestEvents2(_logger, $"invoking events again. {num2}");

}
}
44 changes: 38 additions & 6 deletions BlazorTickets/Services/WebTicketService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,26 @@
using TicketLibrary.Services;
namespace BlazorTickets.Services;

public class WebTicketService : ITicketService
public partial class WebTicketService : ITicketService
{
private readonly ILogger<WebTicketService> _logger;


[LoggerMessage(Level = LogLevel.Information, Message = "Getting All Tickets.")]
static partial void GetAllTickets(ILogger logger, string description);

Check warning on line 13 in BlazorTickets/Services/WebTicketService.cs

View workflow job for this annotation

GitHub Actions / test

Argument 'description' is not referenced from the logging message (https://learn.microsoft.com/dotnet/fundamentals/syslib-diagnostics/syslib1015)

Check warning on line 13 in BlazorTickets/Services/WebTicketService.cs

View workflow job for this annotation

GitHub Actions / build

Argument 'description' is not referenced from the logging message (https://learn.microsoft.com/dotnet/fundamentals/syslib-diagnostics/syslib1015)

[LoggerMessage(Level = LogLevel.Error, Message = "Testing the tickets.")]
static partial void TestTickets1(ILogger logger, string description);

Check warning on line 16 in BlazorTickets/Services/WebTicketService.cs

View workflow job for this annotation

GitHub Actions / test

Argument 'description' is not referenced from the logging message (https://learn.microsoft.com/dotnet/fundamentals/syslib-diagnostics/syslib1015)

Check warning on line 16 in BlazorTickets/Services/WebTicketService.cs

View workflow job for this annotation

GitHub Actions / build

Argument 'description' is not referenced from the logging message (https://learn.microsoft.com/dotnet/fundamentals/syslib-diagnostics/syslib1015)

[LoggerMessage(Level = LogLevel.Warning, Message = "Something about tickets.")]
static partial void TestTickets2(ILogger logger, string description);

Check warning on line 19 in BlazorTickets/Services/WebTicketService.cs

View workflow job for this annotation

GitHub Actions / test

Argument 'description' is not referenced from the logging message (https://learn.microsoft.com/dotnet/fundamentals/syslib-diagnostics/syslib1015)

Check warning on line 19 in BlazorTickets/Services/WebTicketService.cs

View workflow job for this annotation

GitHub Actions / build

Argument 'description' is not referenced from the logging message (https://learn.microsoft.com/dotnet/fundamentals/syslib-diagnostics/syslib1015)


PostgresContext _context;
public WebTicketService(PostgresContext context)
public WebTicketService(PostgresContext context, ILogger<WebTicketService> logger)
{
_context = context;
_logger = logger;
}

public Task AddATicket(Ticket t)
Expand All @@ -24,21 +38,39 @@ public Task AddATicket(Ticket t)
return Task.CompletedTask;
}

public void ChangeBaseAddress(string newBaseAddress)
public void InvokeTicketsLogger1(int number1)
{
throw new NotImplementedException();
TestTickets1(_logger, $"Inside invokeTickets now. {number1}");
}

public void ChangeConnectivity(bool _IsConnected)
public void InvokeTicketsLogger2(int number2)
{
throw new NotImplementedException();
TestTickets1(_logger, $"Invoke number 2 for tickets {number2}");
}

public async Task<List<Ticket>> GetAllTicketsAsync()
{
GetAllTickets(_logger, $"Inside of getAllTickets. Number of tickets is {_context.Tickets.Count()}");
return await _context.Tickets.ToListAsync<Ticket>();
}







public void ChangeBaseAddress(string newBaseAddress)
{
throw new NotImplementedException();
}

public void ChangeConnectivity(bool _IsConnected)
{
throw new NotImplementedException();
}


public Task ResetLocalTicketsDB()
{
throw new NotImplementedException();
Expand Down
Loading

0 comments on commit 092f771

Please sign in to comment.