Skip to content

Commit

Permalink
feat: Implement workspaces
Browse files Browse the repository at this point in the history
  • Loading branch information
data-miner00 committed Feb 10, 2024
1 parent 02872d3 commit 65276ab
Show file tree
Hide file tree
Showing 12 changed files with 1,158 additions and 3 deletions.
13 changes: 13 additions & 0 deletions src/Linker.Core/ApiModels/CreateWorkspaceMembershipRequest.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
namespace Linker.Core.ApiModels;

using Linker.Core.Models;
using System;

public sealed class CreateWorkspaceMembershipRequest
{
required public Guid WorkspaceId { get; set; }

required public Guid UserId { get; set; }

required public WorkspaceRole WorkspaceRole { get; set; }
}
24 changes: 24 additions & 0 deletions src/Linker.Core/ApiModels/CreateWorkspaceRequest.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
namespace Linker.Core.ApiModels;

using Linker.Core.Models;

/// <summary>
/// The request model to create a <see cref="Workspace"/>.
/// </summary>
public class CreateWorkspaceRequest
{
/// <summary>
/// Gets or sets the handle of the workspace.
/// </summary>
required public string Handle { get; set; }

/// <summary>
/// Gets or sets the name of the workspace.
/// </summary>
required public string Name { get; set; }

/// <summary>
/// Gets or sets the description of the workspace.
/// </summary>
required public string Description { get; set; }
}
10 changes: 10 additions & 0 deletions src/Linker.Core/ApiModels/UpdateWorkspaceRequest.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
namespace Linker.Core.ApiModels;

public sealed class UpdateWorkspaceRequest
{
required public string Handle { get; set; }

required public string Name { get; set; }

required public string Description { get; set; }
}
138 changes: 138 additions & 0 deletions src/Linker.Core/Controllers/IWorkspaceController.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,138 @@
namespace Linker.Core.Controllers;

using Linker.Core.ApiModels;
using Microsoft.AspNetCore.Mvc;
using System;
using System.Threading.Tasks;

/// <summary>
/// The interface for the workspace controller.
/// </summary>
public interface IWorkspaceController
{
/// <summary>
/// Get the workspace by ID.
/// </summary>
/// <param name="id">The workspace Id.</param>
/// <returns>The found workspace.</returns>
Task<IActionResult> GetByIdAsync(Guid id);

/// <summary>
/// Get all the existing workspaces.
/// </summary>
/// <returns>A list of workspaces.</returns>
Task<IActionResult> GetAllAsync();

/// <summary>
/// Create a new workspace.
/// </summary>
/// <param name="request">The workspace creation request.</param>
/// <returns>The Http response. </returns>
Task<IActionResult> CreateAsync(CreateWorkspaceRequest request);

/// <summary>
/// Delete an existing workspace.
/// </summary>
/// <param name="id">The workspace ID.</param>
/// <returns>The Http response.</returns>
Task<IActionResult> DeleteAsync(Guid id);

/// <summary>
/// Update an existing workspace.
/// </summary>
/// <param name="id">The workspace ID.</param>
/// <param name="request">The update workspace request.</param>
/// <returns>The Http response.</returns>
Task<IActionResult> UpdateAsync(Guid id, UpdateWorkspaceRequest request);

/// <summary>
/// Get all the workspace that the user has access to.
/// </summary>
/// <param name="userId">The user ID.</param>
/// <returns>A list of user accessible workspaces.</returns>
Task<IActionResult> GetWorkspaceByUserAsync(Guid userId);

/// <summary>
/// Adds a user into a workspace.
/// </summary>
/// <param name="request">The workspace membership creation request.</param>
/// <returns>Http response.</returns>
Task<IActionResult> AddWorkspaceMembershipAsync(CreateWorkspaceMembershipRequest request);

/// <summary>
/// Deletes a user from a workspace.
/// </summary>
/// <param name="workspaceId">The workspace ID.</param>
/// <param name="userId">The user ID.</param>
/// <returns>Http response.</returns>
Task<IActionResult> DeleteWorkspaceMembershipAsync(Guid workspaceId, Guid userId);

/// <summary>
/// Retrieves all the articles that the workspace has.
/// </summary>
/// <param name="workspaceId">The workspace ID.</param>
/// <returns>The list of articles that the workspace has.</returns>
Task<IActionResult> GetWorkspaceArticlesAsync(Guid workspaceId);

/// <summary>
/// Adds an article into the workspace.
/// </summary>
/// <param name="workspaceId">The workspace ID.</param>
/// <param name="articleId">The article ID.</param>
/// <returns>Http response.</returns>
Task<IActionResult> AddWorkspaceArticleAsync(Guid workspaceId, Guid articleId);

/// <summary>
/// Removes a article from a workspace.
/// </summary>
/// <param name="workspaceId">The workspace ID.</param>
/// <param name="articleId">The article ID.</param>
/// <returns>Http response.</returns>
Task<IActionResult> DeleteWorkspaceArticleAsync(Guid workspaceId, Guid articleId);

/// <summary>
/// Retrieves the list of websites within a workspace.
/// </summary>
/// <param name="workspaceId">The workspace ID.</param>
/// <returns>Http response.</returns>
Task<IActionResult> GetWorkspaceWebsitesAsync(Guid workspaceId);

/// <summary>
/// Adds a website into a workspace.
/// </summary>
/// <param name="workspaceId">The workspace ID.</param>
/// <param name="websiteId">The website ID.</param>
/// <returns>Http response.</returns>
Task<IActionResult> AddWorkspaceWebsiteAsync(Guid workspaceId, Guid websiteId);

/// <summary>
/// Removes a website from a workspace.
/// </summary>
/// <param name="workspaceId">The workspace ID.</param>
/// <param name="websiteId">The website ID.</param>
/// <returns>Http response.</returns>
Task<IActionResult> DeleteWorkspaceWebsiteAsync(Guid workspaceId, Guid websiteId);

/// <summary>
/// Retrieves a list of youtube links that a workspace has.
/// </summary>
/// <param name="workspaceId">The workspace ID.</param>
/// <returns>The list of youtube links.</returns>
Task<IActionResult> GetWorkspaceYoutubesAsync(Guid workspaceId);

/// <summary>
/// Adds a youtube link into a workspace.
/// </summary>
/// <param name="workspaceId">The workspace ID.</param>
/// <param name="youtubeId">The youtube ID.</param>
/// <returns>Http response.</returns>
Task<IActionResult> AddWorkspaceYoutubeAsync(Guid workspaceId, Guid youtubeId);

/// <summary>
/// Removes a youtube link from a workspace.
/// </summary>
/// <param name="workspaceId">The workspace ID.</param>
/// <param name="youtubeId">The youtube ID.</param>
/// <returns>Http response.</returns>
Task<IActionResult> DeleteWorkspaceYoutubeAsync(Guid workspaceId, Guid youtubeId);
}
6 changes: 4 additions & 2 deletions src/Linker.Core/Models/Workspace.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
#nullable disable
namespace Linker.Core.Models;

using System;

/// <summary>
/// Allow users to create meaningful collection and making sense of the links.
/// </summary>
Expand Down Expand Up @@ -34,10 +36,10 @@ public class Workspace
/// <summary>
/// Gets or sets the creation date.
/// </summary>
public string CreatedAt { get; set; }
public DateTime CreatedAt { get; set; }

/// <summary>
/// Gets or sets the last modified date.
/// </summary>
public string ModifiedAt { get; set; }
public DateTime ModifiedAt { get; set; }
}
16 changes: 16 additions & 0 deletions src/Linker.Core/Models/WorkspaceMembership.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
namespace Linker.Core.Models;

using System;

public class WorkspaceMembership
{
required public string WorkspaceId { get; set; }

required public string UserId { get; set; }

required public WorkspaceRole WorkspaceRole { get; set; }

required public DateTime CreatedAt { get; set; }

required public DateTime ModifiedAt { get; set; }
}
22 changes: 22 additions & 0 deletions src/Linker.Core/Models/WorkspaceRole.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
namespace Linker.Core.Models;

/// <summary>
/// The workspace role.
/// </summary>
public enum WorkspaceRole
{
/// <summary>
/// The owner of the workspace.
/// </summary>
Owner,

/// <summary>
/// The admin of the workspace.
/// </summary>
Admin,

/// <summary>
/// Regular members of the workspace.
/// </summary>
User,
}
Loading

0 comments on commit 65276ab

Please sign in to comment.