Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit c3f71e6

Browse files
committed
correção no backend e implementação do frontend
1 parent 615be58 commit c3f71e6

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

52 files changed

+11478
-36
lines changed
Binary file not shown.
4 KB
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.

‎SignalRNotificationsApi/.vs/config/applicationhost.config‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<?xml version="1.0" encoding="UTF-8"?>
1+
<?xml version="1.0" encoding="UTF-8"?>
22
<!--
33
44
IIS configuration sections.
@@ -156,7 +156,7 @@
156156
</site>
157157
<site name="SignalRNotificationsApi" id="2">
158158
<application path="/" applicationPool="Clr4IntegratedAppPool">
159-
<virtualDirectory path="/" physicalPath="C:\Projetos\aspnet\Git\SignalRNotifications\SignalRNotificationsApi\SignalRNotificationsApi" />
159+
<virtualDirectory path="/" physicalPath="C:\Projetos\aspnet\Git\SignalRNotifications\src\SignalRNotificationsApi\SignalRNotificationsApi" />
160160
</application>
161161
<bindings>
162162
<binding protocol="http" bindingInformation="*:25050:localhost" />

‎SignalRNotificationsApi/SignalRNotificationsApi/Controllers/CustomersController.cs‎

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,10 @@ namespace SignalRNotificationsApi.Controllers
1111
[ApiController]
1212
public class CustomersController : ControllerBase
1313
{
14-
private readonly IHubContext<NotifyHub,ITypedHubClient> _notifyHub;
14+
private readonly IHubContext<NotifyHub> _notifyHub;
1515
private readonly ICustomerRepository _repository;
1616

17-
public CustomersController(ICustomerRepository repository, IHubContext<NotifyHub,ITypedHubClient> notifyHub)
17+
public CustomersController(ICustomerRepository repository, IHubContext<NotifyHub> notifyHub)
1818
{
1919
_repository = repository;
2020
_notifyHub = notifyHub;
@@ -44,8 +44,7 @@ public async Task<IActionResult> Post([FromBody] Customer customer)
4444

4545
await _repository.Add(customer);
4646

47-
await _notifyHub.Clients.All.BroadcastMessage(
48-
$"Customer: {customer.Name} created at {DateTime.Now.ToShortDateString()}");
47+
await _notifyHub.Clients.All.SendAsync("Notify", $"Customer: {customer.Name} created at {DateTime.Now.ToShortDateString()}");
4948

5049
return CreatedAtAction("GetCustomer", new { id = customer.Id }, customer);
5150
}
Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,13 @@
11
using Microsoft.AspNetCore.SignalR;
2+
using System.Threading.Tasks;
23

34
namespace SignalRNotificationsApi.Core
45
{
5-
public class NotifyHub : Hub<ITypedHubClient>
6+
public class NotifyHub : Hub
67
{
8+
public Task Notify(string message)
9+
{
10+
return Clients.All.SendAsync("Notify", message);
11+
}
712
}
813
}

‎SignalRNotificationsApi/SignalRNotificationsApi/SignalRNotificationsApi.csproj.user‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,9 @@
99
<WebStackScaffolding_IsReferencingScriptLibrariesSelected>True</WebStackScaffolding_IsReferencingScriptLibrariesSelected>
1010
<WebStackScaffolding_LayoutPageFile />
1111
<WebStackScaffolding_IsAsyncSelected>False</WebStackScaffolding_IsAsyncSelected>
12+
<ActiveDebugProfile>SignalRNotificationsApi</ActiveDebugProfile>
13+
</PropertyGroup>
14+
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
15+
<DebuggerFlavor>ProjectDebugger</DebuggerFlavor>
1216
</PropertyGroup>
1317
</Project>

‎SignalRNotificationsApi/SignalRNotificationsApi/Startup.cs‎

Lines changed: 16 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
using Microsoft.AspNetCore.Mvc;
44
using Microsoft.Extensions.Configuration;
55
using Microsoft.Extensions.DependencyInjection;
6-
using Newtonsoft.Json;
76
using SignalRNotificationsApi.Core;
87

98
namespace SignalRNotificationsApi
@@ -19,36 +18,33 @@ public Startup(IConfiguration configuration)
1918

2019
public void ConfigureServices(IServiceCollection services)
2120
{
22-
services.AddCors(options => options.AddPolicy("CorsPolicy", policy =>
23-
{
24-
policy
25-
.WithOrigins(Configuration["angular-web"])
26-
.AllowAnyHeader()
27-
.AllowAnyMethod();
28-
}));
21+
services.AddCors(o => o.AddPolicy("CorsPolicy", builder =>
22+
{
23+
builder.AllowAnyHeader().AllowAnyMethod().AllowAnyOrigin().AllowCredentials();
24+
}));
25+
26+
// Setup options with DI
27+
services.AddOptions();
2928

3029
services.AddSingleton<InMemoryContext>();
3130
services.AddScoped<ICustomerRepository, CustomerRepository>();
31+
3232
services.AddSignalR();
3333

34-
services.AddMvc().AddJsonOptions(options =>
35-
{
36-
options.SerializerSettings.NullValueHandling = NullValueHandling.Ignore;
37-
options.SerializerSettings.ReferenceLoopHandling = ReferenceLoopHandling.Ignore;
38-
})
39-
.SetCompatibilityVersion(CompatibilityVersion.Version_2_1);
34+
services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_1);
4035
}
4136

4237
public void Configure(IApplicationBuilder app, IHostingEnvironment env)
4338
{
44-
if (env.IsDevelopment())
45-
app.UseDeveloperExceptionPage();
46-
else
47-
app.UseHsts();
4839
app.UseCors("CorsPolicy");
40+
4941
app.UseHttpsRedirection();
50-
app.UseFileServer();
51-
app.UseSignalR(root => root.MapHub<NotifyHub>("/notifications"));
42+
43+
app.UseSignalR(routes =>
44+
{
45+
routes.MapHub<NotifyHub>("/notifications");
46+
});
47+
5248
app.UseMvc();
5349
}
5450
}

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /