diff --git a/src/cappanna-helper-api/CappannaHelper.Api/Common/ErrorManagement/ErrorHandlingMiddleware.cs b/src/cappanna-helper-api/CappannaHelper.Api/Common/ErrorManagement/ErrorHandlingMiddleware.cs index 8698e41..39f4aaa 100644 --- a/src/cappanna-helper-api/CappannaHelper.Api/Common/ErrorManagement/ErrorHandlingMiddleware.cs +++ b/src/cappanna-helper-api/CappannaHelper.Api/Common/ErrorManagement/ErrorHandlingMiddleware.cs @@ -1,10 +1,10 @@ -using System; -using System.Net; -using System.Threading.Tasks; -using Microsoft.AspNetCore.Http; +using Microsoft.AspNetCore.Http; using Microsoft.Extensions.Logging; using Newtonsoft.Json; using Newtonsoft.Json.Serialization; +using System; +using System.Net; +using System.Threading.Tasks; namespace CappannaHelper.Api.Common.ErrorManagement { diff --git a/src/cappanna-helper-api/CappannaHelper.Api/Controllers/AccountController.cs b/src/cappanna-helper-api/CappannaHelper.Api/Controllers/AccountController.cs index 0973bdc..92e1e34 100644 --- a/src/cappanna-helper-api/CappannaHelper.Api/Controllers/AccountController.cs +++ b/src/cappanna-helper-api/CappannaHelper.Api/Controllers/AccountController.cs @@ -22,7 +22,7 @@ namespace CappannaHelper.Api.Controllers { [Route("api/[controller]")] [ApiController] - public class AccountController : Controller + public class AccountController : ControllerBase { private readonly IApplicationUserManager _userManager; private readonly IApplicationSignInManager _signInManager; diff --git a/src/cappanna-helper-api/CappannaHelper.Api/Controllers/DashboardController.cs b/src/cappanna-helper-api/CappannaHelper.Api/Controllers/DashboardController.cs index e4dd821..fa51101 100644 --- a/src/cappanna-helper-api/CappannaHelper.Api/Controllers/DashboardController.cs +++ b/src/cappanna-helper-api/CappannaHelper.Api/Controllers/DashboardController.cs @@ -12,7 +12,7 @@ namespace CappannaHelper.Api.Controllers [Authorize] [Route("api/[controller]")] [ApiController] - public class DashboardController : Controller + public class DashboardController : ControllerBase { private readonly ApplicationDbContext _context; private readonly IShiftManager _shiftManager; diff --git a/src/cappanna-helper-api/CappannaHelper.Api/Controllers/MenuDetailController.cs b/src/cappanna-helper-api/CappannaHelper.Api/Controllers/MenuDetailController.cs index c9cec46..c76e2c5 100644 --- a/src/cappanna-helper-api/CappannaHelper.Api/Controllers/MenuDetailController.cs +++ b/src/cappanna-helper-api/CappannaHelper.Api/Controllers/MenuDetailController.cs @@ -15,7 +15,7 @@ namespace CappannaHelper.Api.Controllers [Authorize] [Route("api/[controller]")] [ApiController] - public class MenuDetailController : Controller + public class MenuDetailController : ControllerBase { private readonly ApplicationDbContext _context; private readonly IHubContext _hub; diff --git a/src/cappanna-helper-api/CappannaHelper.Api/Controllers/NotificationController.cs b/src/cappanna-helper-api/CappannaHelper.Api/Controllers/NotificationController.cs index 1751179..a161f0c 100644 --- a/src/cappanna-helper-api/CappannaHelper.Api/Controllers/NotificationController.cs +++ b/src/cappanna-helper-api/CappannaHelper.Api/Controllers/NotificationController.cs @@ -13,7 +13,7 @@ namespace CappannaHelper.Api.Controllers [Authorize] [Route("api/[controller]")] [ApiController] - public class NotificationController : Controller + public class NotificationController : ControllerBase { private readonly ApplicationDbContext _context; private readonly IShiftManager _shiftManager; diff --git a/src/cappanna-helper-api/CappannaHelper.Api/Controllers/OrderController.cs b/src/cappanna-helper-api/CappannaHelper.Api/Controllers/OrderController.cs index a38975b..b672dee 100644 --- a/src/cappanna-helper-api/CappannaHelper.Api/Controllers/OrderController.cs +++ b/src/cappanna-helper-api/CappannaHelper.Api/Controllers/OrderController.cs @@ -11,7 +11,6 @@ using System; using System.Collections.Generic; using System.Linq; -using System.Security.Claims; using System.Threading.Tasks; namespace CappannaHelper.Api.Controllers @@ -19,7 +18,7 @@ namespace CappannaHelper.Api.Controllers [Authorize] [Route("api/[controller]")] [ApiController] - public class OrderController : Controller + public class OrderController : ControllerBase { private readonly ApplicationDbContext _context; private readonly IPrintService _printService; diff --git a/src/cappanna-helper-api/CappannaHelper.Api/Controllers/PrintController.cs b/src/cappanna-helper-api/CappannaHelper.Api/Controllers/PrintController.cs index 63e3c28..6bb3509 100644 --- a/src/cappanna-helper-api/CappannaHelper.Api/Controllers/PrintController.cs +++ b/src/cappanna-helper-api/CappannaHelper.Api/Controllers/PrintController.cs @@ -1,8 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Threading.Tasks; -using CappannaHelper.Api.Hubs; +using CappannaHelper.Api.Hubs; using CappannaHelper.Api.Models; using CappannaHelper.Api.Persistence; using CappannaHelper.Api.Persistence.Modelling; @@ -11,6 +7,10 @@ using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.SignalR; using Microsoft.EntityFrameworkCore; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; namespace CappannaHelper.Api.Controllers { diff --git a/src/cappanna-helper-api/CappannaHelper.Api/Controllers/SettingController.cs b/src/cappanna-helper-api/CappannaHelper.Api/Controllers/SettingController.cs index efb0500..f5597ea 100644 --- a/src/cappanna-helper-api/CappannaHelper.Api/Controllers/SettingController.cs +++ b/src/cappanna-helper-api/CappannaHelper.Api/Controllers/SettingController.cs @@ -11,7 +11,7 @@ namespace CappannaHelper.Api.Controllers [Authorize] [Route("api/[controller]")] [ApiController] - public class SettingController : Controller + public class SettingController : ControllerBase { private readonly ApplicationDbContext _context; diff --git a/src/cappanna-helper-api/CappannaHelper.Api/Controllers/StandController.cs b/src/cappanna-helper-api/CappannaHelper.Api/Controllers/StandController.cs index 5887a80..3bc82c4 100644 --- a/src/cappanna-helper-api/CappannaHelper.Api/Controllers/StandController.cs +++ b/src/cappanna-helper-api/CappannaHelper.Api/Controllers/StandController.cs @@ -9,7 +9,7 @@ namespace CappannaHelper.Api.Controllers [Authorize] [Route("api/[controller]")] [ApiController] - public class StandController : Controller + public class StandController : ControllerBase { private readonly ApplicationDbContext _context; diff --git a/src/cappanna-helper-api/CappannaHelper.Api/Hubs/IHubExtensions.cs b/src/cappanna-helper-api/CappannaHelper.Api/Hubs/IHubExtensions.cs index 13482b7..9b46cb3 100644 --- a/src/cappanna-helper-api/CappannaHelper.Api/Hubs/IHubExtensions.cs +++ b/src/cappanna-helper-api/CappannaHelper.Api/Hubs/IHubExtensions.cs @@ -1,8 +1,8 @@ -using System.Collections.Generic; +using CappannaHelper.Api.Persistence.Modelling; +using Microsoft.AspNetCore.SignalR; +using System.Collections.Generic; using System.Threading; using System.Threading.Tasks; -using CappannaHelper.Api.Persistence.Modelling; -using Microsoft.AspNetCore.SignalR; namespace CappannaHelper.Api.Hubs { diff --git a/src/cappanna-helper-api/CappannaHelper.Api/Identity/ComponentModel/SignIn/ApplicationSignInManager.cs b/src/cappanna-helper-api/CappannaHelper.Api/Identity/ComponentModel/SignIn/ApplicationSignInManager.cs index 703137e..a741790 100644 --- a/src/cappanna-helper-api/CappannaHelper.Api/Identity/ComponentModel/SignIn/ApplicationSignInManager.cs +++ b/src/cappanna-helper-api/CappannaHelper.Api/Identity/ComponentModel/SignIn/ApplicationSignInManager.cs @@ -1,6 +1,5 @@ using CappannaHelper.Api.Identity.DataModel; using Microsoft.AspNetCore.Identity; -using System; using System.Threading.Tasks; namespace CappannaHelper.Api.Identity.ComponentModel.SignIn diff --git a/src/cappanna-helper-api/CappannaHelper.Api/Identity/ComponentModel/User/IUserManager.cs b/src/cappanna-helper-api/CappannaHelper.Api/Identity/ComponentModel/User/IUserManager.cs index 41f7590..c293936 100644 --- a/src/cappanna-helper-api/CappannaHelper.Api/Identity/ComponentModel/User/IUserManager.cs +++ b/src/cappanna-helper-api/CappannaHelper.Api/Identity/ComponentModel/User/IUserManager.cs @@ -1,11 +1,11 @@ -using System.Threading.Tasks; -using Microsoft.AspNetCore.Identity; - -namespace CappannaHelper.Api.Identity.ComponentModel.User -{ - public interface IUserManager where TUser : class - { - Task CreateAsync(TUser user, string password); - Task FindByNameAsync(string userName); - } +using Microsoft.AspNetCore.Identity; +using System.Threading.Tasks; + +namespace CappannaHelper.Api.Identity.ComponentModel.User +{ + public interface IUserManager where TUser : class + { + Task CreateAsync(TUser user, string password); + Task FindByNameAsync(string userName); + } } \ No newline at end of file diff --git a/src/cappanna-helper-api/CappannaHelper.Api/Identity/DataModel/ApplicationRole.cs b/src/cappanna-helper-api/CappannaHelper.Api/Identity/DataModel/ApplicationRole.cs index ef976d5..cc93b0e 100644 --- a/src/cappanna-helper-api/CappannaHelper.Api/Identity/DataModel/ApplicationRole.cs +++ b/src/cappanna-helper-api/CappannaHelper.Api/Identity/DataModel/ApplicationRole.cs @@ -14,7 +14,7 @@ public class ApplicationRole : IdentityRole public ApplicationRole() { - Claims = new HashSet(); + Claims = []; } } } \ No newline at end of file diff --git a/src/cappanna-helper-api/CappannaHelper.Api/Identity/DataModel/ApplicationUser.cs b/src/cappanna-helper-api/CappannaHelper.Api/Identity/DataModel/ApplicationUser.cs index 08b8c18..fa771a1 100644 --- a/src/cappanna-helper-api/CappannaHelper.Api/Identity/DataModel/ApplicationUser.cs +++ b/src/cappanna-helper-api/CappannaHelper.Api/Identity/DataModel/ApplicationUser.cs @@ -16,7 +16,7 @@ public class ApplicationUser : IdentityUser public ApplicationUser() { - UserRoles = new HashSet(); + UserRoles = []; } } } \ No newline at end of file diff --git a/src/cappanna-helper-api/CappannaHelper.Api/Models/DashboardModel.cs b/src/cappanna-helper-api/CappannaHelper.Api/Models/DashboardModel.cs index bffa783..b2f243f 100644 --- a/src/cappanna-helper-api/CappannaHelper.Api/Models/DashboardModel.cs +++ b/src/cappanna-helper-api/CappannaHelper.Api/Models/DashboardModel.cs @@ -10,8 +10,8 @@ public class DashboardModel public DashboardModel() { - OrderStats = new List(); - WaitersStats = new List(); + OrderStats = []; + WaitersStats = []; } } } diff --git a/src/cappanna-helper-api/CappannaHelper.Api/Models/NotificationModel.cs b/src/cappanna-helper-api/CappannaHelper.Api/Models/NotificationModel.cs index 32970b1..4d13ad8 100644 --- a/src/cappanna-helper-api/CappannaHelper.Api/Models/NotificationModel.cs +++ b/src/cappanna-helper-api/CappannaHelper.Api/Models/NotificationModel.cs @@ -1,6 +1,4 @@ -using CappannaHelper.Printing; - -namespace CappannaHelper.Api.Models +namespace CappannaHelper.Api.Models { public class NotificationModel { diff --git a/src/cappanna-helper-api/CappannaHelper.Api/Persistence/ApplicationDbContext.cs b/src/cappanna-helper-api/CappannaHelper.Api/Persistence/ApplicationDbContext.cs index 826f5a4..544e226 100644 --- a/src/cappanna-helper-api/CappannaHelper.Api/Persistence/ApplicationDbContext.cs +++ b/src/cappanna-helper-api/CappannaHelper.Api/Persistence/ApplicationDbContext.cs @@ -1,4 +1,3 @@ -using System.Linq; using CappannaHelper.Api.Identity.DataModel; using CappannaHelper.Api.Identity.Extensions; using CappannaHelper.Api.Persistence.Mapping; @@ -6,6 +5,7 @@ using Microsoft.AspNetCore.Identity; using Microsoft.AspNetCore.Identity.EntityFrameworkCore; using Microsoft.EntityFrameworkCore; +using System.Linq; namespace CappannaHelper.Api.Persistence { diff --git a/src/cappanna-helper-api/CappannaHelper.Api/Persistence/Modelling/Shift.cs b/src/cappanna-helper-api/CappannaHelper.Api/Persistence/Modelling/Shift.cs index 06658a4..3b3f685 100644 --- a/src/cappanna-helper-api/CappannaHelper.Api/Persistence/Modelling/Shift.cs +++ b/src/cappanna-helper-api/CappannaHelper.Api/Persistence/Modelling/Shift.cs @@ -1,5 +1,4 @@ -using CappannaHelper.Api.Identity.DataModel; -using System; +using System; namespace CappannaHelper.Api.Persistence.Modelling { diff --git a/src/cappanna-helper-api/CappannaHelper.Api/Printing/IPrinterDocumentBuilder.cs b/src/cappanna-helper-api/CappannaHelper.Api/Printing/IPrinterDocumentBuilder.cs index b8ba3c9..ef19bb2 100644 --- a/src/cappanna-helper-api/CappannaHelper.Api/Printing/IPrinterDocumentBuilder.cs +++ b/src/cappanna-helper-api/CappannaHelper.Api/Printing/IPrinterDocumentBuilder.cs @@ -1,9 +1,9 @@ using CappannaHelper.Printing; -namespace CappannaHelper.Api.Printing { - public interface IPrinterDocumentBuilder - { - IDocument Build(); - IPrinterDocumentBuilder SetData(T order); - } +namespace CappannaHelper.Api.Printing; + +public interface IPrinterDocumentBuilder +{ + IDocument Build(); + IPrinterDocumentBuilder SetData(T order); } \ No newline at end of file diff --git a/src/cappanna-helper-api/CappannaHelper.Api/Printing/IPrinterDocumentBuilderFactory.cs b/src/cappanna-helper-api/CappannaHelper.Api/Printing/IPrinterDocumentBuilderFactory.cs index c77b7f9..802b1c3 100644 --- a/src/cappanna-helper-api/CappannaHelper.Api/Printing/IPrinterDocumentBuilderFactory.cs +++ b/src/cappanna-helper-api/CappannaHelper.Api/Printing/IPrinterDocumentBuilderFactory.cs @@ -1,6 +1,6 @@ -using CappannaHelper.Api.Printing; - -public interface IPrinterDocumentBuilderFactory -{ - IPrinterDocumentBuilder Create(); +namespace CappannaHelper.Api.Printing; + +public interface IPrinterDocumentBuilderFactory +{ + IPrinterDocumentBuilder Create(); } \ No newline at end of file diff --git a/src/cappanna-helper-api/CappannaHelper.Api/Printing/OrderDetailsAggregateDocumentBuilder.cs b/src/cappanna-helper-api/CappannaHelper.Api/Printing/OrderDetailsAggregateDocumentBuilder.cs index 1fc365b..5c693c1 100644 --- a/src/cappanna-helper-api/CappannaHelper.Api/Printing/OrderDetailsAggregateDocumentBuilder.cs +++ b/src/cappanna-helper-api/CappannaHelper.Api/Printing/OrderDetailsAggregateDocumentBuilder.cs @@ -53,13 +53,13 @@ private void SetAggregate(OrderDetailsAggregateModel aggregation) var name = aggregation.Name; var dotsLength = 30 - aggregation.Name.Length; var dots = string.Empty.PadLeft(dotsLength > 0 ? dotsLength : 0, '.'); - var dotsSection = _document.LastPage.CreateSection(); + _ = _document.LastPage.CreateSection(); var section = _document.LastPage.CreateSection(); section.SetSize(16); section.CreateLabel().SetContent(name); section.CreateLabel().SetContent($"{dots}"); - section.CreateLabel().SetContent($"{aggregation.Quantity.ToString().PadLeft(2, ' ')}"); + section.CreateLabel().SetContent($"{aggregation.Quantity,2}"); section.NewLine(); } diff --git a/src/cappanna-helper-api/CappannaHelper.Api/Printing/PrintService.cs b/src/cappanna-helper-api/CappannaHelper.Api/Printing/PrintService.cs index 86ea591..d76eae6 100644 --- a/src/cappanna-helper-api/CappannaHelper.Api/Printing/PrintService.cs +++ b/src/cappanna-helper-api/CappannaHelper.Api/Printing/PrintService.cs @@ -1,11 +1,10 @@ -using System; +using CappannaHelper.Printing; using System.Threading; using System.Threading.Tasks; -using CappannaHelper.Printing; namespace CappannaHelper.Api.Printing { - public class PrintService : IPrintService + public sealed class PrintService : IPrintService { private readonly IPrinterDocumentBuilderFactory _factory; private readonly IPrinter _printer; @@ -13,18 +12,13 @@ public class PrintService : IPrintService public PrintService(IPrinterDocumentBuilderFactory factory, IPrinter printer) { - _factory = factory ?? throw new ArgumentNullException(nameof(factory)); - _printer = printer ?? throw new ArgumentNullException(nameof(printer)); + _factory = factory; + _printer = printer; _semaphore = new SemaphoreSlim(1, 1); } public async Task PrintAsync(T data) { - if (data == null) - { - throw new ArgumentNullException(nameof(data)); - } - var builder = _factory.Create(); var document = builder.SetData(data).Build(); diff --git a/src/cappanna-helper-api/CappannaHelper.Api/Printing/PrinterDocumentBuilderFactory.cs b/src/cappanna-helper-api/CappannaHelper.Api/Printing/PrinterDocumentBuilderFactory.cs index 376ec3d..8a3e14f 100644 --- a/src/cappanna-helper-api/CappannaHelper.Api/Printing/PrinterDocumentBuilderFactory.cs +++ b/src/cappanna-helper-api/CappannaHelper.Api/Printing/PrinterDocumentBuilderFactory.cs @@ -1,8 +1,7 @@ -using System; -using System.Collections.Generic; -using System.Threading.Tasks; using CappannaHelper.Api.Models; using CappannaHelper.Api.Persistence.Modelling; +using System; +using System.Collections.Generic; namespace CappannaHelper.Api.Printing { @@ -12,23 +11,23 @@ public IPrinterDocumentBuilder Create() { if (typeof(T) == typeof(ChOrder)) { - return (IPrinterDocumentBuilder) CreateChOrderDocumentBuilder(); + return (IPrinterDocumentBuilder) CreateChOrderDocumentBuilder(); } if(typeof(T) == typeof(List)) { - return (IPrinterDocumentBuilder) CreateOrderAggregateDocumentBuilder>(); + return (IPrinterDocumentBuilder) CreateOrderAggregateDocumentBuilder(); } throw new NotImplementedException($"Document type not implemented: {typeof(T)}"); } - private OrderDocumentBuilder CreateChOrderDocumentBuilder() + private static OrderDocumentBuilder CreateChOrderDocumentBuilder() { return new OrderDocumentBuilder(); } - private OrderDetailsAggregateDocumentBuilder CreateOrderAggregateDocumentBuilder() + private static OrderDetailsAggregateDocumentBuilder CreateOrderAggregateDocumentBuilder() { return new OrderDetailsAggregateDocumentBuilder(); }