Skip to content

Commit

Permalink
Merge pull request #30 from BellumGens/user-viewmodel-updates
Browse files Browse the repository at this point in the history
feat(*): updating viewmodel for users
  • Loading branch information
kdinev authored Nov 30, 2024
2 parents 4f63880 + cce6d88 commit 4cb6d00
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 19 deletions.
2 changes: 1 addition & 1 deletion BellumGens.Api.Core/Controllers/AccountController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -331,7 +331,7 @@ public async Task<IActionResult> SetPassword(RegisterBindingModel model)
}

[AllowAnonymous]
[Route("Twitch", Name = "ExternalCallback")]
[Route("ExternalCallback")]
public async Task<IActionResult> ExternalCallback(string error = null, string returnUrl = "", string userId = null)
{
if (error != null)
Expand Down
34 changes: 16 additions & 18 deletions BellumGens.Api.Core/Controllers/TournamentController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -215,36 +215,34 @@ public async Task<IActionResult> GetTotalRegistrationsCount(Guid tournamentId)
}

[Route("AllRegistrations")]
[Authorize(Roles = "admin")]
public async Task<IActionResult> GetAllApplications()
{
return await UserIsInRole("admin") ? Ok(await _dbContext.TournamentApplications.Include(a => a.Tournament).ToListAsync()) : Unauthorized();
return Ok(await _dbContext.TournamentApplications.Include(a => a.Tournament).ToListAsync());
}

[HttpPut]
[Route("Confirm")]
[Authorize(Roles = "admin")]
public async Task<IActionResult> ConfirmRegistration(Guid id, TournamentApplication application)
{
if (await UserIsInRole("admin"))
TournamentApplication entity = await _dbContext.TournamentApplications.FindAsync(id);
if (entity != null)
{
TournamentApplication entity = await _dbContext.TournamentApplications.FindAsync(id);
if (entity != null)
{
_dbContext.Entry(entity).CurrentValues.SetValues(application);
_dbContext.Entry(entity).CurrentValues.SetValues(application);

try
{
await _dbContext.SaveChangesAsync();
}
catch (DbUpdateException e)
{
System.Diagnostics.Trace.TraceError("Tournament registration update error: " + e.Message);
return BadRequest("Something went wrong!");
}
return Ok(application);
try
{
await _dbContext.SaveChangesAsync();
}
return NotFound();
catch (DbUpdateException e)
{
System.Diagnostics.Trace.TraceError("Tournament registration update error: " + e.Message);
return BadRequest("Something went wrong!");
}
return Ok(application);
}
return Unauthorized();
return NotFound();
}

[AllowAnonymous]
Expand Down
1 change: 1 addition & 0 deletions BellumGens.Api.Core/Models/ViewModels/AccountViewModels.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ public UserInfoViewModel() : base() { }

public UserInfoViewModel(ApplicationUser user, bool isAuthUser = false)
{
this.user = user;
_isAuthUser = isAuthUser;
}

Expand Down

0 comments on commit 4cb6d00

Please sign in to comment.