diff --git a/src/Api/Controllers/EntriesController.cs b/src/Api/Controllers/EntriesController.cs
index 12ea545d..53556d74 100644
--- a/src/Api/Controllers/EntriesController.cs
+++ b/src/Api/Controllers/EntriesController.cs
@@ -29,7 +29,7 @@ public EntriesController(ICurrentUserService currentUserService)
///
[RequiresRole(IdentityData.Roles.Staff, IdentityData.Roles.Employee)]
[HttpPost]
- public async Task>> UploadDigitalFile(
+ public async Task>> UploadEntry(
[FromForm] UploadDigitalFileRequest request)
{
var currentUser = _currentUserService.GetCurrentUser();
@@ -50,11 +50,11 @@ public async Task>> UploadDigitalFile(
});
}
- UploadDigitalFile.Command command;
+ CreateEntry.Command command;
if (request.IsDirectory)
{
- command = new UploadDigitalFile.Command()
+ command = new CreateEntry.Command()
{
CurrentUser = currentUser,
Path = request.Path,
@@ -72,7 +72,7 @@ public async Task>> UploadDigitalFile(
var lastDotIndex = request.File.FileName.LastIndexOf(".", StringComparison.Ordinal);
var extension =
request.File.FileName.Substring(lastDotIndex + 1, request.File.FileName.Length - lastDotIndex - 1);
- command = new UploadDigitalFile.Command()
+ command = new CreateEntry.Command()
{
CurrentUser = currentUser,
Path = request.Path,
diff --git a/src/Api/Controllers/SharedController.cs b/src/Api/Controllers/SharedController.cs
index 2c10fb15..4e514ed3 100644
--- a/src/Api/Controllers/SharedController.cs
+++ b/src/Api/Controllers/SharedController.cs
@@ -99,11 +99,11 @@ public async Task>> UploadSharedEntry([
});
}
- UploadSharedEntry.Command command;
+ CreateSharedEntry.Command command;
if (request.IsDirectory)
{
- command = new UploadSharedEntry.Command()
+ command = new CreateSharedEntry.Command()
{
Name = request.Name,
CurrentUser = currentUser,
@@ -121,7 +121,7 @@ public async Task>> UploadSharedEntry([
var lastDotIndex = request.File.FileName.LastIndexOf(".", StringComparison.Ordinal);
var extension =
request.File.FileName.Substring(lastDotIndex + 1, request.File.FileName.Length - lastDotIndex - 1);
- command = new UploadSharedEntry.Command()
+ command = new CreateSharedEntry.Command()
{
CurrentUser = currentUser,
EntryId = entryId,
diff --git a/src/Application/Entries/Commands/UploadDigitalFile.cs b/src/Application/Entries/Commands/CreateEntry.cs
similarity index 90%
rename from src/Application/Entries/Commands/UploadDigitalFile.cs
rename to src/Application/Entries/Commands/CreateEntry.cs
index eb6107c7..9de0cac3 100644
--- a/src/Application/Entries/Commands/UploadDigitalFile.cs
+++ b/src/Application/Entries/Commands/CreateEntry.cs
@@ -14,7 +14,7 @@
namespace Application.Entries.Commands;
-public class UploadDigitalFile {
+public class CreateEntry {
public class Validator : AbstractValidator
{
public Validator()
@@ -22,11 +22,12 @@ public Validator()
RuleLevelCascadeMode = CascadeMode.Stop;
RuleFor(x => x.Name)
+ .NotEmpty().WithMessage("Entry's name is required.")
.MaximumLength(256).WithMessage("Name cannot exceed 256 characters.");
RuleFor(x => x.Path)
- .NotEmpty().WithMessage("File's path is required.")
- .Matches("^(/(?!/)[a-z_.\\-0-9]*)+(?
private readonly IApplicationDbContext _context;
private readonly IMapper _mapper;
private readonly IDateTimeProvider _dateTimeProvider;
- private readonly ILogger _logger;
+ private readonly ILogger _logger;
- public Handler(IApplicationDbContext context, IMapper mapper, IDateTimeProvider dateTimeProvider, ILogger logger)
+ public Handler(IApplicationDbContext context, IMapper mapper, IDateTimeProvider dateTimeProvider, ILogger logger)
{
_context = context;
_mapper = mapper;
@@ -122,7 +123,7 @@ public async Task Handle(Command request, CancellationToken cancellati
await _context.SaveChangesAsync(cancellationToken);
using (Logging.PushProperties(nameof(Entry), entryEntity.Id, request.CurrentUser.Id))
{
- _logger.LogUploadDigitalFile(request.CurrentUser.Id.ToString(), entryEntity.Id.ToString());
+ _logger.LogCreateEntry(request.CurrentUser.Id.ToString(), entryEntity.Id.ToString());
}
return _mapper.Map(result.Entity);
}
diff --git a/src/Application/Entries/Commands/UploadSharedEntry.cs b/src/Application/Entries/Commands/CreateSharedEntry.cs
similarity index 95%
rename from src/Application/Entries/Commands/UploadSharedEntry.cs
rename to src/Application/Entries/Commands/CreateSharedEntry.cs
index 9e06a5f0..acdb78b3 100644
--- a/src/Application/Entries/Commands/UploadSharedEntry.cs
+++ b/src/Application/Entries/Commands/CreateSharedEntry.cs
@@ -14,7 +14,7 @@
namespace Application.Entries.Commands;
-public class UploadSharedEntry
+public class CreateSharedEntry
{
public class Validator : AbstractValidator
{
@@ -42,8 +42,8 @@ public class CommandHandler : IRequestHandler
private readonly IApplicationDbContext _context;
private readonly IMapper _mapper;
private readonly IDateTimeProvider _dateTimeProvider;
- private readonly ILogger _logger;
- public CommandHandler(IApplicationDbContext context, IMapper mapper, IDateTimeProvider dateTimeProvider, ILogger logger)
+ private readonly ILogger _logger;
+ public CommandHandler(IApplicationDbContext context, IMapper mapper, IDateTimeProvider dateTimeProvider, ILogger logger)
{
_context = context;
_mapper = mapper;
@@ -129,7 +129,7 @@ public async Task Handle(Command request, CancellationToken cancellati
await _context.SaveChangesAsync(cancellationToken);
using (Logging.PushProperties(nameof(Entry), entity.Id, request.CurrentUser.Id))
{
- _logger.LogUploadSharedEntry(request.CurrentUser.Id.ToString(), entity.Id.ToString());
+ _logger.LogCreateSharedEntry(request.CurrentUser.Id.ToString(), entity.Id.ToString());
}
return _mapper.Map(result.Entity);
}
diff --git a/src/Application/Entries/Commands/UpdateEntry.cs b/src/Application/Entries/Commands/UpdateEntry.cs
index 9341746f..b8318982 100644
--- a/src/Application/Entries/Commands/UpdateEntry.cs
+++ b/src/Application/Entries/Commands/UpdateEntry.cs
@@ -5,6 +5,7 @@
using Application.Common.Models.Operations;
using AutoMapper;
using Domain.Entities.Digital;
+using FluentValidation;
using MediatR;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Logging;
@@ -14,6 +15,18 @@ namespace Application.Entries.Commands;
public class UpdateEntry
{
+ public class Validator : AbstractValidator
+ {
+ public Validator()
+ {
+ RuleLevelCascadeMode = CascadeMode.Stop;
+
+ RuleFor(x => x.Name)
+ .NotEmpty().WithMessage("Entry's name is required.")
+ .MaximumLength(256).WithMessage("Name cannot exceed 256 characters.");
+ }
+ }
+
public record Command : IRequest
{
public Guid CurrentUserId { get; init; }
diff --git a/src/Application/Entries/EntryLogExtension.cs b/src/Application/Entries/EntryLogExtension.cs
index 28e4d2c1..3605ad4d 100644
--- a/src/Application/Entries/EntryLogExtension.cs
+++ b/src/Application/Entries/EntryLogExtension.cs
@@ -19,10 +19,10 @@ public static partial class EntryLogExtension
public static partial void LogUpdateEntry(this ILogger logger, string userId, string entryId);
[LoggerMessage(Level = LogLevel.Information, Message = EntryLogMessages.UploadDigitalFile, EventId = EventId.Add)]
- public static partial void LogUploadDigitalFile(this ILogger logger, string userId, string entryId);
+ public static partial void LogCreateEntry(this ILogger logger, string userId, string entryId);
[LoggerMessage(Level = LogLevel.Information, Message = EntryLogMessages.UploadSharedEntry, EventId = EventId.Add)]
- public static partial void LogUploadSharedEntry(this ILogger logger, string userId, string entryId);
+ public static partial void LogCreateSharedEntry(this ILogger logger, string userId, string entryId);
[LoggerMessage(Level = LogLevel.Information, Message = EntryLogMessages.DeleteBinEntry, EventId = EventId.Remove)]
public static partial void LogDeleteBinEntry(this ILogger logger, string userId, string entryId);
diff --git a/src/Application/Entries/Queries/GetAllEntriesPaginated.cs b/src/Application/Entries/Queries/GetAllEntriesPaginated.cs
index 1efa66fc..0c345df2 100644
--- a/src/Application/Entries/Queries/GetAllEntriesPaginated.cs
+++ b/src/Application/Entries/Queries/GetAllEntriesPaginated.cs
@@ -19,7 +19,7 @@ public Validator()
RuleFor(x => x.EntryPath)
.NotEmpty().WithMessage("File's path is required.")
- .Matches("^(/(?!/)[a-z_.\\-0-9]*)+(?