diff --git a/src/Api/Controllers/AuthController.cs b/src/Api/Controllers/AuthController.cs index 51c3d93c..c4e980c8 100644 --- a/src/Api/Controllers/AuthController.cs +++ b/src/Api/Controllers/AuthController.cs @@ -2,7 +2,9 @@ using System.Security.Authentication; using Api.Controllers.Payload.Requests.Auth; using Api.Controllers.Payload.Responses; +using Application.Common.Extensions.Logging; using Application.Common.Interfaces; +using Application.Common.Logging; using Application.Common.Models; using Application.Common.Models.Dtos; using Application.Users.Queries; @@ -18,10 +20,14 @@ namespace Api.Controllers; public class AuthController : ControllerBase { private readonly IIdentityService _identityService; + private readonly ILogger _logger; + private readonly IDateTimeProvider _dateTimeProvider; - public AuthController(IIdentityService identityService) + public AuthController(IIdentityService identityService, ILogger logger, IDateTimeProvider dateTimeProvider) { _identityService = identityService; + _logger = logger; + _dateTimeProvider = dateTimeProvider; } /// @@ -54,6 +60,11 @@ public async Task Login([FromBody] LoginModel loginModel) LastName = loginSuccess.UserCredentials.LastName, }; + var dateTimeNow = _dateTimeProvider.DateTimeNow; + using (Logging.PushProperties("Login", loginResult.Id, loginResult.Id)) + { + _logger.LogLogin(loginResult.Username, dateTimeNow.ToString("yyyy-MM-dd HH:mm:ss")); + } return Ok(Result.Succeed(loginResult)); }, token => diff --git a/src/Api/Controllers/DashboardController.cs b/src/Api/Controllers/DashboardController.cs index 35ced3e8..cc1c7428 100644 --- a/src/Api/Controllers/DashboardController.cs +++ b/src/Api/Controllers/DashboardController.cs @@ -1,4 +1,8 @@ +using Api.Controllers.Payload.Requests.Dashboard; +using Application.Common.Interfaces; using Application.Common.Models; +using Application.Common.Models.Dtos.DashBoard; +using Application.Dashboards.Queries; using Application.Identity; using Infrastructure.Identity.Authorization; using Microsoft.AspNetCore.Mvc; @@ -7,6 +11,62 @@ namespace Api.Controllers; public class DashboardController : ApiControllerBase { + private readonly ICurrentUserService _currentUserService; + + public DashboardController(ICurrentUserService currentUserService) + { + _currentUserService = currentUserService; + } + + [RequiresRole(IdentityData.Roles.Admin)] + [HttpPost("import-documents")] + [ProducesResponseType(StatusCodes.Status200OK)] + [ProducesResponseType(StatusCodes.Status401Unauthorized)] + public async Task>>> GetImportDocuments( + [FromBody] GetImportedDocumentsMetricsRequest request) + { + var query = new GetImportDocuments.Query() + { + StartDate = request.StartDate, + EndDate = request.EndDate + }; + + var result = await Mediator.Send(query); + return Ok(Result>.Succeed(result)); + } + + [RequiresRole(IdentityData.Roles.Admin)] + [HttpPost("logins")] + [ProducesResponseType(StatusCodes.Status200OK)] + [ProducesResponseType(StatusCodes.Status401Unauthorized)] + public async Task>> GetLoggedInUsers( + [FromBody] DateTime date) + { + var query = new GetLoggedInUser.Query() + { + Date = date + }; + + var result = await Mediator.Send(query); + return Ok(Result.Succeed(result)); + } + + [RequiresRole(IdentityData.Roles.Admin)] + [HttpPost("largest-drive")] + [ProducesResponseType(StatusCodes.Status200OK)] + [ProducesResponseType(StatusCodes.Status401Unauthorized)] + public async Task>> GetUserWithLargestDrive( + [FromBody] DateTime date) + { + var query = new GetUserWithLargestDriveData.Query() + { + Date = date + }; + + var result = await Mediator.Send(query); + return Ok(Result.Succeed(result)); + } + [RequiresRole(IdentityData.Roles.Admin)] [HttpGet("online-users")] [ProducesResponseType(StatusCodes.Status200OK)] diff --git a/src/Api/Controllers/Payload/Requests/Dashboard/GetImportedDocumentsMetricsRequest.cs b/src/Api/Controllers/Payload/Requests/Dashboard/GetImportedDocumentsMetricsRequest.cs new file mode 100644 index 00000000..95283540 --- /dev/null +++ b/src/Api/Controllers/Payload/Requests/Dashboard/GetImportedDocumentsMetricsRequest.cs @@ -0,0 +1,9 @@ +namespace Api.Controllers.Payload.Requests.Dashboard; + +public class GetImportedDocumentsMetricsRequest +{ + + public DateTime StartDate { get; set; } + + public DateTime EndDate { get; set; } +} \ No newline at end of file diff --git a/src/Application/Borrows/Commands/ApproveOrRejectBorrowRequest.cs b/src/Application/Borrows/Commands/ApproveOrRejectBorrowRequest.cs index ec9397ac..60a9e295 100644 --- a/src/Application/Borrows/Commands/ApproveOrRejectBorrowRequest.cs +++ b/src/Application/Borrows/Commands/ApproveOrRejectBorrowRequest.cs @@ -120,7 +120,7 @@ is BorrowRequestStatus.Approved using (Logging.PushProperties("BorrowRequest", borrowRequest.Id, request.CurrentUserId)) { - _logger.LogApproveBorrowRequest(borrowRequest.Document.Id.ToString(), borrowRequest.Id.ToString()); + Common.Extensions.Logging.BorrowLogExtensions.LogApproveBorrowRequest(_logger, borrowRequest.Document.Id.ToString(), borrowRequest.Id.ToString()); } } @@ -130,7 +130,7 @@ is BorrowRequestStatus.Approved using (Logging.PushProperties("BorrowRequest", borrowRequest.Id, request.CurrentUserId)) { - _logger.LogRejectBorrowRequest(borrowRequest.Document.Id.ToString(), borrowRequest.Id.ToString()); + Common.Extensions.Logging.BorrowLogExtensions.LogRejectBorrowRequest(_logger, borrowRequest.Document.Id.ToString(), borrowRequest.Id.ToString()); } } diff --git a/src/Application/Borrows/Commands/BorrowDocument.cs b/src/Application/Borrows/Commands/BorrowDocument.cs index 79a7de68..7c7eddad 100644 --- a/src/Application/Borrows/Commands/BorrowDocument.cs +++ b/src/Application/Borrows/Commands/BorrowDocument.cs @@ -164,7 +164,7 @@ is BorrowRequestStatus.Approved await _context.SaveChangesAsync(cancellationToken); using (Logging.PushProperties("Request", document.Id, user.Id)) { - _logger.LogBorrowDocument(document.Id.ToString(), result.Entity.Id.ToString()); + Common.Extensions.Logging.BorrowLogExtensions.LogBorrowDocument(_logger, document.Id.ToString(), result.Entity.Id.ToString()); } return _mapper.Map(result.Entity); } diff --git a/src/Application/Borrows/Commands/CancelBorrowRequest.cs b/src/Application/Borrows/Commands/CancelBorrowRequest.cs index 6f9ffd79..135d05ef 100644 --- a/src/Application/Borrows/Commands/CancelBorrowRequest.cs +++ b/src/Application/Borrows/Commands/CancelBorrowRequest.cs @@ -65,7 +65,7 @@ public async Task Handle(Command request, CancellationToken cancellat await _context.SaveChangesAsync(cancellationToken); using (Logging.PushProperties("BorrowRequest", borrowRequest.Id, request.CurrentUserId)) { - _logger.LogCancelBorrowRequest(borrowRequest.Document.Id.ToString(), borrowRequest.Id.ToString()); + Common.Extensions.Logging.BorrowLogExtensions.LogCancelBorrowRequest(_logger, borrowRequest.Document.Id.ToString(), borrowRequest.Id.ToString()); } return _mapper.Map(result.Entity); } diff --git a/src/Application/Borrows/Commands/CheckoutDocument.cs b/src/Application/Borrows/Commands/CheckoutDocument.cs index 275b344f..0dd95d0a 100644 --- a/src/Application/Borrows/Commands/CheckoutDocument.cs +++ b/src/Application/Borrows/Commands/CheckoutDocument.cs @@ -90,7 +90,7 @@ public async Task Handle(Command request, CancellationToken cancellat await _context.SaveChangesAsync(cancellationToken); using (Logging.PushProperties("BorrowRequest", borrowRequest.Id, request.CurrentStaff.Id)) { - _logger.LogCheckoutDocument(borrowRequest.Document.Id.ToString(), borrowRequest.Id.ToString()); + Common.Extensions.Logging.BorrowLogExtensions.LogCheckoutDocument(_logger, borrowRequest.Document.Id.ToString(), borrowRequest.Id.ToString()); } return _mapper.Map(result.Entity); } diff --git a/src/Application/Borrows/Commands/ReturnDocument.cs b/src/Application/Borrows/Commands/ReturnDocument.cs index d2e3cc37..2ee6da97 100644 --- a/src/Application/Borrows/Commands/ReturnDocument.cs +++ b/src/Application/Borrows/Commands/ReturnDocument.cs @@ -91,7 +91,7 @@ public async Task Handle(Command request, CancellationToken cancellat await _context.SaveChangesAsync(cancellationToken); using (Logging.PushProperties("BorrowRequest", borrowRequest.Id, request.CurrentUser.Id)) { - _logger.LogReturnDocument(borrowRequest.Document.Id.ToString(), borrowRequest.Id.ToString()); + Common.Extensions.Logging.BorrowLogExtensions.LogReturnDocument(_logger, borrowRequest.Document.Id.ToString(), borrowRequest.Id.ToString()); } return _mapper.Map(result.Entity); } diff --git a/src/Application/Borrows/Commands/UpdateBorrow.cs b/src/Application/Borrows/Commands/UpdateBorrow.cs index 0d1d9512..cdbf0d9e 100644 --- a/src/Application/Borrows/Commands/UpdateBorrow.cs +++ b/src/Application/Borrows/Commands/UpdateBorrow.cs @@ -115,7 +115,7 @@ is BorrowRequestStatus.Approved using (Logging.PushProperties("BorrowRequest", borrowRequest.Id, request.CurrentUser.Id)) { - _logger.LogUpdateBorrow(borrowRequest.Document.Id.ToString(), borrowRequest.Id.ToString()); + Common.Extensions.Logging.BorrowLogExtensions.LogUpdateBorrow(_logger, borrowRequest.Document.Id.ToString(), borrowRequest.Id.ToString()); } return _mapper.Map(result.Entity); diff --git a/src/Application/Borrows/BorrowLogExtensions.cs b/src/Application/Common/Extensions/Logging/BorrowLogExtensions.cs similarity index 97% rename from src/Application/Borrows/BorrowLogExtensions.cs rename to src/Application/Common/Extensions/Logging/BorrowLogExtensions.cs index 04df6443..cd33de16 100644 --- a/src/Application/Borrows/BorrowLogExtensions.cs +++ b/src/Application/Common/Extensions/Logging/BorrowLogExtensions.cs @@ -1,7 +1,7 @@ using Application.Common.Messages; using Microsoft.Extensions.Logging; -namespace Application.Borrows; +namespace Application.Common.Extensions.Logging; public static partial class BorrowLogExtensions { diff --git a/src/Application/Documents/DocumentLogExtensions.cs b/src/Application/Common/Extensions/Logging/DocumentLogExtensions.cs similarity index 96% rename from src/Application/Documents/DocumentLogExtensions.cs rename to src/Application/Common/Extensions/Logging/DocumentLogExtensions.cs index 790b5479..13e8a07b 100644 --- a/src/Application/Documents/DocumentLogExtensions.cs +++ b/src/Application/Common/Extensions/Logging/DocumentLogExtensions.cs @@ -2,7 +2,7 @@ using Microsoft.Extensions.Logging; using EventId = Application.Common.Logging.EventId; -namespace Application.Documents; +namespace Application.Common.Extensions.Logging; public static partial class DocumentLogExtensions { diff --git a/src/Application/Entries/EntryLogExtension.cs b/src/Application/Common/Extensions/Logging/EntryLogExtension.cs similarity index 97% rename from src/Application/Entries/EntryLogExtension.cs rename to src/Application/Common/Extensions/Logging/EntryLogExtension.cs index e2f850b4..d99b237e 100644 --- a/src/Application/Entries/EntryLogExtension.cs +++ b/src/Application/Common/Extensions/Logging/EntryLogExtension.cs @@ -2,7 +2,7 @@ using Microsoft.Extensions.Logging; using EventId = Application.Common.Logging.EventId; -namespace Application.Entries; +namespace Application.Common.Extensions.Logging; public static partial class EntryLogExtension { diff --git a/src/Application/Folders/FolderLogExtension.cs b/src/Application/Common/Extensions/Logging/FolderLogExtension.cs similarity index 94% rename from src/Application/Folders/FolderLogExtension.cs rename to src/Application/Common/Extensions/Logging/FolderLogExtension.cs index aca354d6..e5da414c 100644 --- a/src/Application/Folders/FolderLogExtension.cs +++ b/src/Application/Common/Extensions/Logging/FolderLogExtension.cs @@ -2,7 +2,7 @@ using Microsoft.Extensions.Logging; using EventId = Application.Common.Logging.EventId; -namespace Application.Folders; +namespace Application.Common.Extensions.Logging; public static partial class FolderLogExtension { diff --git a/src/Application/ImportRequests/ImportRequestLogExtensions.cs b/src/Application/Common/Extensions/Logging/ImportRequestLogExtensions.cs similarity index 97% rename from src/Application/ImportRequests/ImportRequestLogExtensions.cs rename to src/Application/Common/Extensions/Logging/ImportRequestLogExtensions.cs index 6719dde6..5143dc19 100644 --- a/src/Application/ImportRequests/ImportRequestLogExtensions.cs +++ b/src/Application/Common/Extensions/Logging/ImportRequestLogExtensions.cs @@ -1,9 +1,8 @@ using Application.Common.Messages; -using Domain.Entities.Physical; using Microsoft.Extensions.Logging; using EventId = Application.Common.Logging.EventId; -namespace Application.ImportRequests; +namespace Application.Common.Extensions.Logging; public static partial class ImportRequestLogExtensions { // Approve or reject document diff --git a/src/Application/Lockers/LockerLogExtension.cs b/src/Application/Common/Extensions/Logging/LockerLogExtension.cs similarity index 94% rename from src/Application/Lockers/LockerLogExtension.cs rename to src/Application/Common/Extensions/Logging/LockerLogExtension.cs index f38951ce..db6d4505 100644 --- a/src/Application/Lockers/LockerLogExtension.cs +++ b/src/Application/Common/Extensions/Logging/LockerLogExtension.cs @@ -2,7 +2,7 @@ using Microsoft.Extensions.Logging; using EventId = Application.Common.Logging.EventId; -namespace Application.Lockers; +namespace Application.Common.Extensions.Logging; public static partial class LockerLogExtension { diff --git a/src/Application/Common/Extensions/Logging/LoginLogExtension.cs b/src/Application/Common/Extensions/Logging/LoginLogExtension.cs new file mode 100644 index 00000000..0bd03761 --- /dev/null +++ b/src/Application/Common/Extensions/Logging/LoginLogExtension.cs @@ -0,0 +1,11 @@ +using Application.Common.Messages; +using Microsoft.Extensions.Logging; +using EventId = Application.Common.Logging.EventId; + +namespace Application.Common.Extensions.Logging; + +public static partial class LoginLogExtension +{ + [LoggerMessage(Level = LogLevel.Information, Message = LoginLogMessages.Login, EventId = EventId.Approve)] + public static partial void LogLogin(this ILogger logger, string username, string time); +} \ No newline at end of file diff --git a/src/Application/Rooms/RoomLogExtension.cs b/src/Application/Common/Extensions/Logging/RoomLogExtension.cs similarity index 94% rename from src/Application/Rooms/RoomLogExtension.cs rename to src/Application/Common/Extensions/Logging/RoomLogExtension.cs index 13d5f9fe..d1cd8f9f 100644 --- a/src/Application/Rooms/RoomLogExtension.cs +++ b/src/Application/Common/Extensions/Logging/RoomLogExtension.cs @@ -2,7 +2,7 @@ using Microsoft.Extensions.Logging; using EventId = Application.Common.Logging.EventId; -namespace Application.Rooms; +namespace Application.Common.Extensions.Logging; public static partial class RoomLogExtension { [LoggerMessage(Level = LogLevel.Information, Message = RoomLogMessage.Add, EventId = EventId.Add)] diff --git a/src/Application/Staffs/StaffLogExtensions.cs b/src/Application/Common/Extensions/Logging/StaffLogExtensions.cs similarity index 92% rename from src/Application/Staffs/StaffLogExtensions.cs rename to src/Application/Common/Extensions/Logging/StaffLogExtensions.cs index 8577103e..071fd548 100644 --- a/src/Application/Staffs/StaffLogExtensions.cs +++ b/src/Application/Common/Extensions/Logging/StaffLogExtensions.cs @@ -2,7 +2,7 @@ using Microsoft.Extensions.Logging; using EventId = Application.Common.Logging.EventId; -namespace Application.Staffs; +namespace Application.Common.Extensions.Logging; public static partial class StaffLogExtensions { [LoggerMessage(Level = LogLevel.Information, Message = UserLogMessages.Staff.AssignStaff, EventId = EventId.Add)] diff --git a/src/Application/Users/UserLogExtensions.cs b/src/Application/Common/Extensions/Logging/UserLogExtensions.cs similarity index 90% rename from src/Application/Users/UserLogExtensions.cs rename to src/Application/Common/Extensions/Logging/UserLogExtensions.cs index 7607bc02..7dd99cc7 100644 --- a/src/Application/Users/UserLogExtensions.cs +++ b/src/Application/Common/Extensions/Logging/UserLogExtensions.cs @@ -1,7 +1,7 @@ using Application.Common.Messages; using Microsoft.Extensions.Logging; -namespace Application.Users; +namespace Application.Common.Extensions.Logging; public static partial class UserLogExtensions { diff --git a/src/Application/Common/Messages/LoginLogMessages.cs b/src/Application/Common/Messages/LoginLogMessages.cs new file mode 100644 index 00000000..102e3e4b --- /dev/null +++ b/src/Application/Common/Messages/LoginLogMessages.cs @@ -0,0 +1,6 @@ +namespace Application.Common.Messages; + +public class LoginLogMessages +{ + public const string Login = "User with username {Username} Log in at {Time}"; +} \ No newline at end of file diff --git a/src/Application/Common/Models/Dtos/DashBoard/LargestDriveDto.cs b/src/Application/Common/Models/Dtos/DashBoard/LargestDriveDto.cs new file mode 100644 index 00000000..b7ce4c77 --- /dev/null +++ b/src/Application/Common/Models/Dtos/DashBoard/LargestDriveDto.cs @@ -0,0 +1,10 @@ +using Application.Users.Queries; + +namespace Application.Common.Models.Dtos.DashBoard; + +public class LargestDriveDto +{ + public string Label { get; set; } + public long Value { get; set; } + public UserDto User { get; set; } +} \ No newline at end of file diff --git a/src/Application/Common/Models/Dtos/DashBoard/MetricResultDto.cs b/src/Application/Common/Models/Dtos/DashBoard/MetricResultDto.cs new file mode 100644 index 00000000..0c98f1e2 --- /dev/null +++ b/src/Application/Common/Models/Dtos/DashBoard/MetricResultDto.cs @@ -0,0 +1,7 @@ +namespace Application.Common.Models.Dtos.DashBoard; + +public class MetricResultDto +{ + public string Label { get; set; } + public int Value { get; set; } +} \ No newline at end of file diff --git a/src/Application/Dashboards/Queries/GetImportDocuments.cs b/src/Application/Dashboards/Queries/GetImportDocuments.cs new file mode 100644 index 00000000..1c4b12cd --- /dev/null +++ b/src/Application/Dashboards/Queries/GetImportDocuments.cs @@ -0,0 +1,74 @@ +using Application.Common.Interfaces; +using Application.Common.Models.Dtos.DashBoard; +using Domain.Statuses; +using FluentValidation; +using MediatR; +using Microsoft.EntityFrameworkCore; +using NodaTime; + +namespace Application.Dashboards.Queries; + +public class GetImportDocuments +{ + public class Validator : AbstractValidator + { + public Validator() + { + RuleLevelCascadeMode = CascadeMode.Stop; + + RuleFor(x => x.StartDate) + .NotEmpty().WithMessage("Start date can not be empty."); + + RuleFor(x => x.EndDate) + .NotEmpty().WithMessage("End date can not be empty."); + } + } + public record Query : IRequest> + { + public DateTime StartDate { get; init; } + public DateTime EndDate { get; init; } + + } + + public class QueryHandler : IRequestHandler> + { + private readonly IApplicationDbContext _context; + + public QueryHandler(IApplicationDbContext context) + { + _context = context; + } + + public async Task> Handle(Query request, CancellationToken cancellationToken) + { + var result = new List(); + + var currentDate = request.StartDate.Date; + var endDate = request.EndDate.Date; + + while (currentDate <= endDate) + { + var nextDate = currentDate.AddDays(1); + var label = $"{currentDate:dd-MM} to {nextDate:dd-MM}"; + if (nextDate <= endDate) + { + var date = currentDate; + var importedDocumentsCount = await _context.Documents + .Where(x => x.Created >= LocalDateTime.FromDateTime(date) + && x.Created <= LocalDateTime.FromDateTime(nextDate) + && x.Status != DocumentStatus.Issued) + .CountAsync(cancellationToken); + + result.Add(new MetricResultDto() + { + Label = label, + Value = importedDocumentsCount + }); + } + currentDate = nextDate; + } + + return result; + } + } +} \ No newline at end of file diff --git a/src/Application/Dashboards/Queries/GetLoggedInUser.cs b/src/Application/Dashboards/Queries/GetLoggedInUser.cs new file mode 100644 index 00000000..0abd755e --- /dev/null +++ b/src/Application/Dashboards/Queries/GetLoggedInUser.cs @@ -0,0 +1,55 @@ +using Application.Common.Interfaces; +using Application.Common.Models.Dtos.DashBoard; +using Domain.Statuses; +using FluentValidation; +using MediatR; +using Microsoft.EntityFrameworkCore; +using NodaTime; + +namespace Application.Dashboards.Queries; + +public class GetLoggedInUser +{ + public class Validator : AbstractValidator + { + public Validator() + { + RuleLevelCascadeMode = CascadeMode.Stop; + + RuleFor(x => x.Date) + .NotEmpty().WithMessage("Date can not be empty."); + } + } + public record Query : IRequest + { + public DateTime Date { get; init; } + } + + public class QueryHandler : IRequestHandler + { + private readonly IApplicationDbContext _context; + + public QueryHandler(IApplicationDbContext context) + { + _context = context; + } + + public async Task Handle(Query request, CancellationToken cancellationToken) + { + var currentDate = request.Date.Date; + + var label = $"{currentDate:dd-MM}"; + var loggedinUsersCount = await _context.Logs + .Where(x => x.ObjectType!.Equals("Login") + && x.Time >= Instant.FromDateTimeUtc(currentDate) + && x.Time < Instant.FromDateTimeUtc(currentDate.AddDays(1))) + .CountAsync(cancellationToken); + + return new MetricResultDto() + { + Label = label, + Value = loggedinUsersCount + }; + } + } +} \ No newline at end of file diff --git a/src/Application/Dashboards/Queries/GetUserWithLargestDriveData.cs b/src/Application/Dashboards/Queries/GetUserWithLargestDriveData.cs new file mode 100644 index 00000000..d5a2be1e --- /dev/null +++ b/src/Application/Dashboards/Queries/GetUserWithLargestDriveData.cs @@ -0,0 +1,60 @@ +using Application.Common.Interfaces; +using Application.Common.Models.Dtos.DashBoard; +using Application.Users.Queries; +using AutoMapper; +using FluentValidation; +using MediatR; +using Microsoft.EntityFrameworkCore; +using NodaTime; + +namespace Application.Dashboards.Queries; + +public class GetUserWithLargestDriveData +{ + public class Validator : AbstractValidator + { + public Validator() + { + RuleLevelCascadeMode = CascadeMode.Stop; + + RuleFor(x => x.Date) + .NotEmpty().WithMessage("Date can not be empty."); + } + } + public record Query : IRequest + { + public DateTime Date { get; init; } + } + + public class QueryHandler : IRequestHandler + { + private readonly IApplicationDbContext _context; + private readonly IMapper _mapper; + + public QueryHandler(IApplicationDbContext context, IMapper mapper) + { + _context = context; + _mapper = mapper; + } + + public async Task Handle(Query request, CancellationToken cancellationToken) + { + var currentDate = request.Date.Date; + var nextDate = currentDate.AddDays(1); + + var usersWithFileData = await _context.Entries + .Where(x => x.FileId != null && x.Created >= LocalDateTime.FromDateTime(currentDate) + && x.Created < LocalDateTime.FromDateTime(nextDate)) + .GroupBy(entry => entry.Uploader) + .Select(group => new LargestDriveDto() + { + User = _mapper.Map(group.Key), + Label = $"{currentDate:dd-MM}", + Value = group.Sum(x => x.File!.FileData.Length) + }) + .OrderByDescending(x => x.Value) + .FirstOrDefaultAsync(cancellationToken); + return usersWithFileData; + } + } +} \ No newline at end of file diff --git a/src/Application/Documents/Commands/DeleteDocument.cs b/src/Application/Documents/Commands/DeleteDocument.cs index 176a6845..6331ff18 100644 --- a/src/Application/Documents/Commands/DeleteDocument.cs +++ b/src/Application/Documents/Commands/DeleteDocument.cs @@ -1,3 +1,4 @@ +using Application.Common.Extensions.Logging; using Application.Common.Interfaces; using Application.Common.Logging; using Application.Common.Models.Dtos.Physical; diff --git a/src/Application/Documents/Commands/ImportDocument.cs b/src/Application/Documents/Commands/ImportDocument.cs index b105ff93..9a3ac6ee 100644 --- a/src/Application/Documents/Commands/ImportDocument.cs +++ b/src/Application/Documents/Commands/ImportDocument.cs @@ -1,4 +1,5 @@ using Application.Common.Exceptions; +using Application.Common.Extensions.Logging; using Application.Common.Interfaces; using Application.Common.Logging; using Application.Common.Models.Dtos.Physical; diff --git a/src/Application/Documents/Commands/ShareDocument.cs b/src/Application/Documents/Commands/ShareDocument.cs index c1359f80..9fd5e7bb 100644 --- a/src/Application/Documents/Commands/ShareDocument.cs +++ b/src/Application/Documents/Commands/ShareDocument.cs @@ -1,4 +1,5 @@ using Application.Common.Exceptions; +using Application.Common.Extensions.Logging; using Application.Common.Interfaces; using Application.Common.Logging; using Application.Common.Models.Dtos.Physical; diff --git a/src/Application/Documents/Commands/UpdateDocument.cs b/src/Application/Documents/Commands/UpdateDocument.cs index fc8e5aea..c67a6cdd 100644 --- a/src/Application/Documents/Commands/UpdateDocument.cs +++ b/src/Application/Documents/Commands/UpdateDocument.cs @@ -1,5 +1,6 @@ using Application.Common.Exceptions; using Application.Common.Extensions; +using Application.Common.Extensions.Logging; using Application.Common.Interfaces; using Application.Common.Logging; using Application.Common.Models.Dtos.Physical; diff --git a/src/Application/Entries/Commands/CreateEntry.cs b/src/Application/Entries/Commands/CreateEntry.cs index 7cb67e6c..86647ee2 100644 --- a/src/Application/Entries/Commands/CreateEntry.cs +++ b/src/Application/Entries/Commands/CreateEntry.cs @@ -1,4 +1,5 @@ using Application.Common.Exceptions; +using Application.Common.Extensions.Logging; using Application.Common.Interfaces; using Application.Common.Logging; using Application.Common.Models.Dtos.Digital; diff --git a/src/Application/Entries/Commands/CreateSharedEntry.cs b/src/Application/Entries/Commands/CreateSharedEntry.cs index 5fe9d8f0..ebefb8b7 100644 --- a/src/Application/Entries/Commands/CreateSharedEntry.cs +++ b/src/Application/Entries/Commands/CreateSharedEntry.cs @@ -1,4 +1,5 @@ using Application.Common.Exceptions; +using Application.Common.Extensions.Logging; using Application.Common.Interfaces; using Application.Common.Logging; using Application.Common.Models.Dtos.Digital; diff --git a/src/Application/Entries/Commands/DeleteBinEntry.cs b/src/Application/Entries/Commands/DeleteBinEntry.cs index 10379f82..0b4ff8cb 100644 --- a/src/Application/Entries/Commands/DeleteBinEntry.cs +++ b/src/Application/Entries/Commands/DeleteBinEntry.cs @@ -1,4 +1,5 @@ using Application.Common.Exceptions; +using Application.Common.Extensions.Logging; using Application.Common.Interfaces; using Application.Common.Logging; using Application.Common.Models.Dtos.Digital; diff --git a/src/Application/Entries/Commands/DownloadDigitalFile.cs b/src/Application/Entries/Commands/DownloadDigitalFile.cs index 85048f97..88ecfe3f 100644 --- a/src/Application/Entries/Commands/DownloadDigitalFile.cs +++ b/src/Application/Entries/Commands/DownloadDigitalFile.cs @@ -1,4 +1,5 @@ using Application.Common.Exceptions; +using Application.Common.Extensions.Logging; using Application.Common.Interfaces; using Application.Common.Logging; using Application.Common.Models.Operations; diff --git a/src/Application/Entries/Commands/MoveEntryToBin.cs b/src/Application/Entries/Commands/MoveEntryToBin.cs index 1361eae9..4ec05da9 100644 --- a/src/Application/Entries/Commands/MoveEntryToBin.cs +++ b/src/Application/Entries/Commands/MoveEntryToBin.cs @@ -1,4 +1,5 @@ using Application.Common.Exceptions; +using Application.Common.Extensions.Logging; using Application.Common.Interfaces; using Application.Common.Logging; using Application.Common.Models.Dtos.Digital; diff --git a/src/Application/Entries/Commands/RestoreBinEntry.cs b/src/Application/Entries/Commands/RestoreBinEntry.cs index 4daf9698..413ebab5 100644 --- a/src/Application/Entries/Commands/RestoreBinEntry.cs +++ b/src/Application/Entries/Commands/RestoreBinEntry.cs @@ -1,4 +1,5 @@ using Application.Common.Exceptions; +using Application.Common.Extensions.Logging; using Application.Common.Interfaces; using Application.Common.Logging; using Application.Common.Models.Dtos.Digital; diff --git a/src/Application/Entries/Commands/ShareEntry.cs b/src/Application/Entries/Commands/ShareEntry.cs index 5ca36e64..6d6deb73 100644 --- a/src/Application/Entries/Commands/ShareEntry.cs +++ b/src/Application/Entries/Commands/ShareEntry.cs @@ -1,5 +1,6 @@ using System.Configuration; using Application.Common.Exceptions; +using Application.Common.Extensions.Logging; using Application.Common.Interfaces; using Application.Common.Logging; using Application.Common.Models.Dtos.Digital; diff --git a/src/Application/Entries/Commands/UpdateEntry.cs b/src/Application/Entries/Commands/UpdateEntry.cs index e8c6c007..f4571d80 100644 --- a/src/Application/Entries/Commands/UpdateEntry.cs +++ b/src/Application/Entries/Commands/UpdateEntry.cs @@ -1,4 +1,5 @@ using Application.Common.Exceptions; +using Application.Common.Extensions.Logging; using Application.Common.Interfaces; using Application.Common.Logging; using Application.Common.Models.Dtos.Digital; diff --git a/src/Application/Folders/Commands/AddFolder.cs b/src/Application/Folders/Commands/AddFolder.cs index 2810e5f0..59bc069c 100644 --- a/src/Application/Folders/Commands/AddFolder.cs +++ b/src/Application/Folders/Commands/AddFolder.cs @@ -1,5 +1,6 @@ using Application.Common.Exceptions; using Application.Common.Extensions; +using Application.Common.Extensions.Logging; using Application.Common.Interfaces; using Application.Common.Logging; using Application.Common.Models.Dtos.Physical; diff --git a/src/Application/Folders/Commands/RemoveFolder.cs b/src/Application/Folders/Commands/RemoveFolder.cs index d9d24596..557fe4c4 100644 --- a/src/Application/Folders/Commands/RemoveFolder.cs +++ b/src/Application/Folders/Commands/RemoveFolder.cs @@ -1,5 +1,6 @@ using Application.Common.Exceptions; using Application.Common.Extensions; +using Application.Common.Extensions.Logging; using Application.Common.Interfaces; using Application.Common.Logging; using Application.Common.Models.Dtos.Physical; diff --git a/src/Application/Folders/Commands/UpdateFolder.cs b/src/Application/Folders/Commands/UpdateFolder.cs index ce5c058d..8338cebb 100644 --- a/src/Application/Folders/Commands/UpdateFolder.cs +++ b/src/Application/Folders/Commands/UpdateFolder.cs @@ -1,5 +1,6 @@ using Application.Common.Exceptions; using Application.Common.Extensions; +using Application.Common.Extensions.Logging; using Application.Common.Interfaces; using Application.Common.Logging; using Application.Common.Models.Dtos.Physical; diff --git a/src/Application/ImportRequests/Commands/ApproveOrRejectDocument.cs b/src/Application/ImportRequests/Commands/ApproveOrRejectDocument.cs index 9beb97d5..f93c2dfa 100644 --- a/src/Application/ImportRequests/Commands/ApproveOrRejectDocument.cs +++ b/src/Application/ImportRequests/Commands/ApproveOrRejectDocument.cs @@ -1,5 +1,6 @@ using Application.Common.Exceptions; using Application.Common.Extensions; +using Application.Common.Extensions.Logging; using Application.Common.Interfaces; using Application.Common.Logging; using Application.Common.Models.Dtos.ImportDocument; diff --git a/src/Application/ImportRequests/Commands/AssignDocument.cs b/src/Application/ImportRequests/Commands/AssignDocument.cs index 1397f4b5..e134f927 100644 --- a/src/Application/ImportRequests/Commands/AssignDocument.cs +++ b/src/Application/ImportRequests/Commands/AssignDocument.cs @@ -1,4 +1,5 @@ using Application.Common.Exceptions; +using Application.Common.Extensions.Logging; using Application.Common.Interfaces; using Application.Common.Logging; using Application.Common.Models.Dtos.ImportDocument; diff --git a/src/Application/ImportRequests/Commands/CheckinDocument.cs b/src/Application/ImportRequests/Commands/CheckinDocument.cs index 39b78f6c..fa30b592 100644 --- a/src/Application/ImportRequests/Commands/CheckinDocument.cs +++ b/src/Application/ImportRequests/Commands/CheckinDocument.cs @@ -1,4 +1,5 @@ using Application.Common.Exceptions; +using Application.Common.Extensions.Logging; using Application.Common.Interfaces; using Application.Common.Logging; using Application.Common.Models.Dtos.Physical; diff --git a/src/Application/ImportRequests/Commands/RequestImportDocument.cs b/src/Application/ImportRequests/Commands/RequestImportDocument.cs index 2e768164..ef1b088e 100644 --- a/src/Application/ImportRequests/Commands/RequestImportDocument.cs +++ b/src/Application/ImportRequests/Commands/RequestImportDocument.cs @@ -1,4 +1,5 @@ using Application.Common.Exceptions; +using Application.Common.Extensions.Logging; using Application.Common.Interfaces; using Application.Common.Logging; using Application.Common.Models.Dtos.ImportDocument; diff --git a/src/Application/Lockers/Commands/AddLocker.cs b/src/Application/Lockers/Commands/AddLocker.cs index 41c558e6..f2123351 100644 --- a/src/Application/Lockers/Commands/AddLocker.cs +++ b/src/Application/Lockers/Commands/AddLocker.cs @@ -1,4 +1,5 @@ using Application.Common.Exceptions; +using Application.Common.Extensions.Logging; using Application.Common.Interfaces; using Application.Common.Logging; using Application.Common.Models.Dtos.Physical; diff --git a/src/Application/Lockers/Commands/RemoveLocker.cs b/src/Application/Lockers/Commands/RemoveLocker.cs index 9860aea9..f5c3cb55 100644 --- a/src/Application/Lockers/Commands/RemoveLocker.cs +++ b/src/Application/Lockers/Commands/RemoveLocker.cs @@ -1,4 +1,5 @@ using Application.Common.Exceptions; +using Application.Common.Extensions.Logging; using Application.Common.Interfaces; using Application.Common.Logging; using Application.Common.Models.Dtos.Physical; diff --git a/src/Application/Lockers/Commands/UpdateLocker.cs b/src/Application/Lockers/Commands/UpdateLocker.cs index 45b5aed9..d4db5580 100644 --- a/src/Application/Lockers/Commands/UpdateLocker.cs +++ b/src/Application/Lockers/Commands/UpdateLocker.cs @@ -1,4 +1,5 @@ using Application.Common.Exceptions; +using Application.Common.Extensions.Logging; using Application.Common.Interfaces; using Application.Common.Logging; using Application.Common.Models.Dtos.Physical; diff --git a/src/Application/Rooms/Commands/AddRoom.cs b/src/Application/Rooms/Commands/AddRoom.cs index 9dff5688..e6692789 100644 --- a/src/Application/Rooms/Commands/AddRoom.cs +++ b/src/Application/Rooms/Commands/AddRoom.cs @@ -1,4 +1,5 @@ using Application.Common.Exceptions; +using Application.Common.Extensions.Logging; using Application.Common.Interfaces; using Application.Common.Logging; using Application.Common.Models.Dtos.Physical; diff --git a/src/Application/Rooms/Commands/RemoveRoom.cs b/src/Application/Rooms/Commands/RemoveRoom.cs index 4619d011..73d7579c 100644 --- a/src/Application/Rooms/Commands/RemoveRoom.cs +++ b/src/Application/Rooms/Commands/RemoveRoom.cs @@ -1,4 +1,5 @@ using Application.Common.Exceptions; +using Application.Common.Extensions.Logging; using Application.Common.Interfaces; using Application.Common.Logging; using Application.Common.Models.Dtos.Physical; diff --git a/src/Application/Rooms/Commands/UpdateRoom.cs b/src/Application/Rooms/Commands/UpdateRoom.cs index b630cdaa..0cdea5ff 100644 --- a/src/Application/Rooms/Commands/UpdateRoom.cs +++ b/src/Application/Rooms/Commands/UpdateRoom.cs @@ -1,4 +1,5 @@ using Application.Common.Exceptions; +using Application.Common.Extensions.Logging; using Application.Common.Interfaces; using Application.Common.Logging; using Application.Common.Models.Dtos.Physical; diff --git a/src/Application/Staffs/Commands/AssignStaff.cs b/src/Application/Staffs/Commands/AssignStaff.cs index e8dd03ef..32f99ee9 100644 --- a/src/Application/Staffs/Commands/AssignStaff.cs +++ b/src/Application/Staffs/Commands/AssignStaff.cs @@ -1,4 +1,5 @@ using Application.Common.Exceptions; +using Application.Common.Extensions.Logging; using Application.Common.Interfaces; using Application.Common.Logging; using Application.Common.Models.Dtos.Physical; diff --git a/src/Application/Staffs/Commands/RemoveStaffFromRoom.cs b/src/Application/Staffs/Commands/RemoveStaffFromRoom.cs index c87aec9f..fdd95573 100644 --- a/src/Application/Staffs/Commands/RemoveStaffFromRoom.cs +++ b/src/Application/Staffs/Commands/RemoveStaffFromRoom.cs @@ -1,4 +1,5 @@ using Application.Common.Exceptions; +using Application.Common.Extensions.Logging; using Application.Common.Interfaces; using Application.Common.Logging; using Application.Common.Models.Dtos.Physical; diff --git a/src/Application/Users/Commands/AddUser.cs b/src/Application/Users/Commands/AddUser.cs index 269c3d91..17dd5b03 100644 --- a/src/Application/Users/Commands/AddUser.cs +++ b/src/Application/Users/Commands/AddUser.cs @@ -1,5 +1,6 @@ using Application.Common.Exceptions; using Application.Common.Extensions; +using Application.Common.Extensions.Logging; using Application.Common.Interfaces; using Application.Common.Logging; using Application.Helpers; diff --git a/src/Application/Users/Commands/UpdateUser.cs b/src/Application/Users/Commands/UpdateUser.cs index 805b0202..584f57d2 100644 --- a/src/Application/Users/Commands/UpdateUser.cs +++ b/src/Application/Users/Commands/UpdateUser.cs @@ -1,4 +1,5 @@ using Application.Common.Extensions; +using Application.Common.Extensions.Logging; using Application.Common.Interfaces; using Application.Common.Logging; using Application.Common.Messages;