Skip to content

Commit

Permalink
Run Visual Studio code cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
romandykyi committed Mar 3, 2024
1 parent 56defd7 commit 70ea3c9
Show file tree
Hide file tree
Showing 34 changed files with 218 additions and 419 deletions.
2 changes: 1 addition & 1 deletion AdvancedTodoList.Core/Dtos/TodoListDtos.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ public record TodoListCreateDto(string Name, string Description);
/// <summary>
/// DTO for a full view of a to-do list.
/// </summary>
public record TodoListGetByIdDto(string Id, string Name, string Description, ApplicationUserPreviewDto Owner);
public record TodoListGetByIdDto(string Id, string Name, string Description);
2 changes: 1 addition & 1 deletion AdvancedTodoList.Core/Dtos/TodoListItemDtos.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public record TodoItemUpdateStateDto(TodoItemState State);
public record TodoItemGetByIdDto(
int Id, string TodoListId, string Name,
string Description, DateTime? DeadlineDate,
TodoItemState State, ApplicationUserPreviewDto Owner
TodoItemState State
);

/// <summary>
Expand Down
1 change: 0 additions & 1 deletion AdvancedTodoList.Core/Mapping/MappingGlobalSettings.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
using AdvancedTodoList.Core.Dtos;
using AdvancedTodoList.Core.Models.TodoLists.Members;
using Mapster;
using System.Text.RegularExpressions;

namespace AdvancedTodoList.Core.Mapping;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,4 @@ public record struct RolePermissions(
bool RemoveMembers = false,
bool AssignRoles = false,
bool EditRoles = false
)
{
/// <summary>
/// Instance of a structure with all permissions.
/// </summary>
public static readonly RolePermissions All = new(true, true, true, true, true, true, true, true);
}
);
22 changes: 6 additions & 16 deletions AdvancedTodoList.Core/Models/TodoLists/TodoItem.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using AdvancedTodoList.Core.Models.Auth;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;

namespace AdvancedTodoList.Core.Models.TodoLists;
Expand Down Expand Up @@ -38,20 +37,6 @@ public class TodoItem : IEntity<int>, ITodoListDependant
/// </summary>
[ForeignKey(nameof(TodoList))]
public required string TodoListId { get; set; }
/// <summary>
/// Navigation property to the to-do list associated with this to-do item.
/// </summary>
public TodoList TodoList { get; set; } = null!;

/// <summary>
/// Foreign key referencing the user who created this item.
/// </summary>
[ForeignKey(nameof(Owner))]
public required string? OwnerId { get; set; } = null!;
/// <summary>
/// Navigation property to the user who created this item.
/// </summary>
public ApplicationUser? Owner { get; set; }

/// <summary>
/// Maximum allowed length of <see cref="Name"/>.
Expand All @@ -61,6 +46,11 @@ public class TodoItem : IEntity<int>, ITodoListDependant
/// Maximum allowed length of <see cref="Description"/>.
/// </summary>
public const int DescriptionMaxLength = 10_000;

/// <summary>
/// To-do list associated with this to-do item.
/// </summary>
public TodoList TodoList { get; set; } = null!;
}

/// <summary>
Expand Down
13 changes: 1 addition & 12 deletions AdvancedTodoList.Core/Models/TodoLists/TodoList.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using AdvancedTodoList.Core.Models.Auth;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;

namespace AdvancedTodoList.Core.Models.TodoLists;
Expand Down Expand Up @@ -27,16 +26,6 @@ public class TodoList : IEntity<string>
[MaxLength(DescriptionMaxLength)]
public required string Description { get; set; } = null!;

/// <summary>
/// Foreign key referencing the user who created this to-do list.
/// </summary>
[ForeignKey(nameof(Owner))]
public required string? OwnerId { get; set; } = null!;
/// <summary>
/// Navigation property to the user who created this to-do list.
/// </summary>
public ApplicationUser? Owner { get; set; }

/// <summary>
/// Maximum allowed length of <see cref="Name"/>.
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using AdvancedTodoList.Core.Models.Auth;
using AdvancedTodoList.Core.Models.TodoLists.Members;
using AdvancedTodoList.Core.Models.TodoLists.Members;

namespace AdvancedTodoList.Core.Repositories;

Expand Down
3 changes: 1 addition & 2 deletions AdvancedTodoList.Core/Services/ITodoItemsService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,13 @@ public interface ITodoItemsService
/// </summary>
/// <param name="todoListId">The ID of the to-do list to associate the item with.</param>
/// <param name="dto">The DTO containing information for creating the to-do list item.</param>
/// <param name="callerId">ID of the user who creates the to-do list item.</param>
/// <returns>
/// A task representing the asynchronous operation.
/// The task result contains the created <see cref="TodoItem"/> mapped to
/// <see cref="TodoItemGetByIdDto"/> or <see langword="null" /> if to-do list with ID
/// <paramref name="todoListId"/> does not exist.
/// </returns>
public Task<TodoItemGetByIdDto?> CreateAsync(string todoListId, TodoItemCreateDto dto, string callerId);
public Task<TodoItemGetByIdDto?> CreateAsync(string todoListId, TodoItemCreateDto dto);

/// <summary>
/// Edits a to-do list item asynchronously.
Expand Down
6 changes: 1 addition & 5 deletions AdvancedTodoList.Core/Services/ITodoListsService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,17 +22,13 @@ public interface ITodoListsService
/// <summary>
/// Creates a new to-do list asynchronously.
/// </summary>
/// <remarks>
/// This method should also create an "Owner" role with all permissions and assign the caller to it.
/// </remarks>
/// <param name="dto">The DTO containing information for creating the to-do list.</param>
/// <param name="callerId">ID of the user who creates the to-do list.</param>
/// <returns>
/// A task representing the asynchronous operation.
/// The task result contains the created <see cref="TodoList"/> mapped to
/// <see cref="TodoListGetByIdDto"/>.
/// </returns>
public Task<TodoListGetByIdDto> CreateAsync(TodoListCreateDto dto, string callerId);
public Task<TodoListGetByIdDto> CreateAsync(TodoListCreateDto dto);

/// <summary>
/// Edits a to-do list asynchronously.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,103 +2,102 @@

#nullable disable

namespace AdvancedTodoList.Infrastructure.Migrations
namespace AdvancedTodoList.Infrastructure.Migrations;

/// <inheritdoc />
public partial class AddMembersAndRolesEntities : Migration
{
/// <inheritdoc />
public partial class AddMembersAndRolesEntities : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "TodoListRoles",
columns: table => new
{
Id = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
Name = table.Column<string>(type: "nvarchar(100)", maxLength: 100, nullable: false),
TodoListId = table.Column<string>(type: "nvarchar(450)", nullable: false),
Permissions_AddItems = table.Column<bool>(type: "bit", nullable: false),
Permissions_AddMembers = table.Column<bool>(type: "bit", nullable: false),
Permissions_AssignRoles = table.Column<bool>(type: "bit", nullable: false),
Permissions_DeleteItems = table.Column<bool>(type: "bit", nullable: false),
Permissions_EditItems = table.Column<bool>(type: "bit", nullable: false),
Permissions_EditRoles = table.Column<bool>(type: "bit", nullable: false),
Permissions_RemoveMembers = table.Column<bool>(type: "bit", nullable: false),
Permissions_SetItemsState = table.Column<bool>(type: "bit", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_TodoListRoles", x => x.Id);
table.ForeignKey(
name: "FK_TodoListRoles_TodoLists_TodoListId",
column: x => x.TodoListId,
principalTable: "TodoLists",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "TodoListRoles",
columns: table => new
{
Id = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
Name = table.Column<string>(type: "nvarchar(100)", maxLength: 100, nullable: false),
TodoListId = table.Column<string>(type: "nvarchar(450)", nullable: false),
Permissions_AddItems = table.Column<bool>(type: "bit", nullable: false),
Permissions_AddMembers = table.Column<bool>(type: "bit", nullable: false),
Permissions_AssignRoles = table.Column<bool>(type: "bit", nullable: false),
Permissions_DeleteItems = table.Column<bool>(type: "bit", nullable: false),
Permissions_EditItems = table.Column<bool>(type: "bit", nullable: false),
Permissions_EditRoles = table.Column<bool>(type: "bit", nullable: false),
Permissions_RemoveMembers = table.Column<bool>(type: "bit", nullable: false),
Permissions_SetItemsState = table.Column<bool>(type: "bit", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_TodoListRoles", x => x.Id);
table.ForeignKey(
name: "FK_TodoListRoles_TodoLists_TodoListId",
column: x => x.TodoListId,
principalTable: "TodoLists",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});

migrationBuilder.CreateTable(
name: "TodoListsMembers",
columns: table => new
{
Id = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
UserId = table.Column<string>(type: "nvarchar(450)", nullable: false),
TodoListId = table.Column<string>(type: "nvarchar(450)", nullable: false),
RoleId = table.Column<int>(type: "int", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_TodoListsMembers", x => x.Id);
table.ForeignKey(
name: "FK_TodoListsMembers_AspNetUsers_UserId",
column: x => x.UserId,
principalTable: "AspNetUsers",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_TodoListsMembers_TodoListRoles_RoleId",
column: x => x.RoleId,
principalTable: "TodoListRoles",
principalColumn: "Id");
table.ForeignKey(
name: "FK_TodoListsMembers_TodoLists_TodoListId",
column: x => x.TodoListId,
principalTable: "TodoLists",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "TodoListsMembers",
columns: table => new
{
Id = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
UserId = table.Column<string>(type: "nvarchar(450)", nullable: false),
TodoListId = table.Column<string>(type: "nvarchar(450)", nullable: false),
RoleId = table.Column<int>(type: "int", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_TodoListsMembers", x => x.Id);
table.ForeignKey(
name: "FK_TodoListsMembers_AspNetUsers_UserId",
column: x => x.UserId,
principalTable: "AspNetUsers",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_TodoListsMembers_TodoListRoles_RoleId",
column: x => x.RoleId,
principalTable: "TodoListRoles",
principalColumn: "Id");
table.ForeignKey(
name: "FK_TodoListsMembers_TodoLists_TodoListId",
column: x => x.TodoListId,
principalTable: "TodoLists",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});

migrationBuilder.CreateIndex(
name: "IX_TodoListRoles_TodoListId",
table: "TodoListRoles",
column: "TodoListId");
migrationBuilder.CreateIndex(
name: "IX_TodoListRoles_TodoListId",
table: "TodoListRoles",
column: "TodoListId");

migrationBuilder.CreateIndex(
name: "IX_TodoListsMembers_RoleId",
table: "TodoListsMembers",
column: "RoleId");
migrationBuilder.CreateIndex(
name: "IX_TodoListsMembers_RoleId",
table: "TodoListsMembers",
column: "RoleId");

migrationBuilder.CreateIndex(
name: "IX_TodoListsMembers_TodoListId",
table: "TodoListsMembers",
column: "TodoListId");
migrationBuilder.CreateIndex(
name: "IX_TodoListsMembers_TodoListId",
table: "TodoListsMembers",
column: "TodoListId");

migrationBuilder.CreateIndex(
name: "IX_TodoListsMembers_UserId",
table: "TodoListsMembers",
column: "UserId");
}
migrationBuilder.CreateIndex(
name: "IX_TodoListsMembers_UserId",
table: "TodoListsMembers",
column: "UserId");
}

/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "TodoListsMembers");
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "TodoListsMembers");

migrationBuilder.DropTable(
name: "TodoListRoles");
}
}
migrationBuilder.DropTable(
name: "TodoListRoles");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,28 +2,27 @@

#nullable disable

namespace AdvancedTodoList.Infrastructure.Migrations
namespace AdvancedTodoList.Infrastructure.Migrations;

/// <inheritdoc />
public partial class AddRolePriorityColumn : Migration
{
/// <inheritdoc />
public partial class AddRolePriorityColumn : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AddColumn<int>(
name: "Priority",
table: "TodoListRoles",
type: "int",
nullable: false,
defaultValue: 0);
}
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AddColumn<int>(
name: "Priority",
table: "TodoListRoles",
type: "int",
nullable: false,
defaultValue: 0);
}

/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropColumn(
name: "Priority",
table: "TodoListRoles");
}
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropColumn(
name: "Priority",
table: "TodoListRoles");
}
}
Loading

0 comments on commit 70ea3c9

Please sign in to comment.