Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/prevent-env-file.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ jobs:
- name: Search for .env files
run: |
if git diff --name-only origin/main...HEAD | grep -E '(^|/)\.env'; then
echo " PR contain .env file, merge is forbiden."
echo "This PR contains .env file(s), merge is forbiden."
exit 1
else
echo "There are no .env files in this PR-u."
echo "There are no .env files in this PR."
fi
Binary file removed Fitness/.vs/Fitness/DesignTimeBuild/.dtbcache.v2
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file removed Fitness/.vs/Fitness/v17/.futdcache.v2
Binary file not shown.
Binary file removed Fitness/.vs/Fitness/v17/.wsuo
Binary file not shown.
37 changes: 0 additions & 37 deletions Fitness/.vs/Fitness/v17/DocumentLayout.json

This file was deleted.

15 changes: 0 additions & 15 deletions Fitness/.vs/VSWorkspaceState.json

This file was deleted.

Binary file removed Fitness/.vs/slnx.sqlite
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
EMAIL_PASSWORD=<YOUR-EMAIL-PASSWORD-HERE>
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,14 @@

namespace NotificationService.API.Controller;

/// <summary>
/// Provides REST API endpoints for fetching and modifying notification data.
/// </summary>
/// <remarks>
/// This controller exposes operations for fetching and modyfing notification data.
///
/// All routes are secured and require authorization with roles <c>Admin</c>, <c>Trainer</c>, or <c>Client</c>.
/// </remarks>
[Authorize]
[ApiController]
[Route("api/v1/[controller]")]
Expand All @@ -18,6 +26,10 @@ public NotificationController(IRepository repository, IMapper mapper)
_repository = repository ?? throw new ArgumentNullException(nameof(repository));
}

/// <summary>
/// API for fetching all notifications.
/// </summary>
/// <returns><c>IEnumerable</c> of all notifications.</returns>
[Authorize(Roles = "Admin")]
[HttpGet]
[ProducesResponseType(typeof(IEnumerable<Notification>), StatusCodes.Status200OK)]
Expand All @@ -27,6 +39,11 @@ public async Task<ActionResult<IEnumerable<Notification>>> GetNotifications()
return Ok(notifications);
}

/// <summary>
/// API for fetching all notifications associated with a given user.
/// </summary>
/// <param name="userId">Unique identifier of the desired user</param>
/// <returns><c>IEnumerable</c> of notifications for the given user.</returns>
[Authorize(Roles = "Admin, Trainer, Client")]
[HttpGet("user/{userId}")]
[ProducesResponseType(typeof(IEnumerable<Notification>), StatusCodes.Status200OK)]
Expand All @@ -36,6 +53,11 @@ public async Task<ActionResult<IEnumerable<Notification>>> GetNotificationsByUse
return Ok(notifications);
}

/// <summary>
/// API for fetching a notification with the given identifier.
/// </summary>
/// <param name="id">Unique identifier of the notification</param>
/// <returns>Notification with the given identifier.</returns>
[Authorize(Roles = "Admin, Trainer, Client")]
[HttpGet("{id}")]
[ProducesResponseType(typeof(Notification), StatusCodes.Status200OK)]
Expand All @@ -45,6 +67,11 @@ public async Task<ActionResult<Notification>> GetNotificationById(string id)
return Ok(notification);
}

/// <summary>
/// API for updating a notification.
/// </summary>
/// <param name="notification">Notification object containing updated values.</param>
/// <returns>Updated notification object.</returns>
[Authorize(Roles = "Admin, Trainer, Client")]
[HttpPut]
[ProducesResponseType(typeof(Notification), StatusCodes.Status200OK)]
Expand All @@ -53,7 +80,11 @@ public async Task<IActionResult> UpdateNotification([FromBody] Notification noti
return Ok(await _repository.UpdateNotification(notification));
}

// PUT api/notifications/{id}/read
/// <summary>
/// API for marking a notification (with the given identifier) as read.
/// </summary>
/// <param name="id">Unique identifier of the notification to be marked as read.</param>
/// <returns>200 OK if successful, 404 NotFound if notification does not exist.</returns>
[Authorize(Roles = "Trainer, Client")]
[HttpPut("{id}/read")]
[ProducesResponseType(StatusCodes.Status200OK)]
Expand All @@ -68,7 +99,10 @@ public async Task<IActionResult> MarkAsRead(string id)
return Ok(new { Message = "Notification marked as read" });
}


/// <summary>
/// API for deleting all notifications.
/// </summary>
/// <returns>200 OK when all notifications are deleted.</returns>
[Authorize(Roles = "Admin")]
[HttpDelete]
[ProducesResponseType(typeof(Notification), StatusCodes.Status200OK)]
Expand All @@ -78,14 +112,24 @@ public async Task<IActionResult> DeleteNotifications()
return Ok();
}

/// <summary>
/// API for deleting all notifications for a given user.
/// </summary>
/// <param name="userId">Unique identifier of the user whose notifications should be deleted.</param>
/// <returns>200 OK when notifications are deleted.</returns>
[Authorize(Roles = "Admin, Trainer, Client")]
[HttpDelete("/user/{userId}")]
[ProducesResponseType(typeof(Notification), StatusCodes.Status200OK)]
public async Task<IActionResult> DeleteNotificationsByUserTypeAndUserId(string userId)
{
return Ok( await _repository.DeleteNotificationsByUserId(userId));
return Ok(await _repository.DeleteNotificationsByUserId(userId));
}

/// <summary>
/// API for deleting a notification with the given identifier.
/// </summary>
/// <param name="id">Unique identifier of the notification.</param>
/// <returns>200 OK when the notification is deleted.</returns>
[Authorize(Roles = "Admin, Trainer, Client")]
[HttpDelete("{id}")]
[ProducesResponseType(typeof(Notification), StatusCodes.Status200OK)]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ public EmailService(IFluentEmail fluentEmail)

public async Task<bool> SendEmailAsync(string to, string subject, string body)
{
// Clear all previous recipients -- ADDED AFTER THE DEADLINE -- minor addition
_fluentEmail.Data.ToAddresses.Clear();

var response = await _fluentEmail
.To(to)
.Subject(subject)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
PayPalSettings__ClientId=<YOUR-PAY-PAL-ID-HERE>
PayPalSettings__ClientSecret=<YOUR-PAY-PAL-SECRET-HERE>
Loading