PortiaNet.Helper 1.4.4

dotnet add package PortiaNet.Helper --version 1.4.4
NuGet\Install-Package PortiaNet.Helper -Version 1.4.4
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="PortiaNet.Helper" Version="1.4.4" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add PortiaNet.Helper --version 1.4.4
#r "nuget: PortiaNet.Helper, 1.4.4"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install PortiaNet.Helper as a Cake Addin
#addin nuget:?package=PortiaNet.Helper&version=1.4.4

// Install PortiaNet.Helper as a Cake Tool
#tool nuget:?package=PortiaNet.Helper&version=1.4.4

PortiaNet.Helper

This tool is a .Net class library to provide some functionalities and helper methods in MVC projects. Helpers are as the following:

MasterData

This part contains some master information which doesn't change too much. Currently, the following list of the masters are included:

  • Continent
  • Country
  • Currency
  • Language
  • TimeZone
  • Region

How To Use

You can simply call:

var continents = Continent.GetAll();
// Or
var countries = Country.GetAll();

Security Helper

This helper provides the functionality to inject the encryption and decryption functions into any class using the AES128 algorithm.

How To Use

  1. Configure DI
using PortiaNet.Helper.SecurityHelper

public void ConfigureServices(IConfiguration configuration, IServiceCollection services)
{
    ...
    services.AddEncryptionDecryptionHelper(f =>
    {
        f.Key = 'Enc/Dec Key'; // The key length must be 32 chars
    });
    ...
}
  1. Inject the class

public class AnyService
{
    private readonly EncryptionDecryptionHelper _encDecHelper;

    // Inject the EncryptionDecryptionHelper class
    public AnyService(EncryptionDecryptionHelper encDecHelper)
    {
        _encDecHelper = encDecHelper;
    }

    public void DoSomethingSpecial()
    {
        // Data encryption
        string? encryptedData = _encDecHelper.EncryptString("data");
    
        // Data decryption
        string? decryptedData = _encDecHelper.DecryptString(encryptedData);
    }
}

ExtensionMethods.cs

This class contains some of the frequently used static methods. The namespace of this class is System, then it will be available everywhere by default.

string GetControllerName(this string value)
// var controllerName = nameof(HomeController).GetControllerName();

string GetEnumDescription(this Enum value)
// var enumDescription = Gender.Male.GetEnumDescription();

string GetDisplayName(this Enum enumValue)
// var enumDisplayName = Gender.Male.GetDisplayName();

IDictionary<int, String> GetEnumValueNames(Type type)
// var enumWithNames = GetEnumValueNames(typeof(Gender));

string GetDisplayGroup(this Enum value)
// var enumGroupName = Gender.Male.GetDisplayGroup();

Pagination.cs

The Pagination class containes a base class to keep the main pagination information like TotalRecords Count, FilteredRecords Count, PageSize, PageIndex, and CurrentPageRecordsCount, and a derived generic class to keep the fetched and peged information in a list.

There is another static helper class inside this file to decrease the pagination headache and mistakes. It gets the IQueryable<K> as the data source, and filtering , sorting, and mapping functionalities as the input parameter, then returns a PaginationModel<T> as the result.

public Task<PaginationModel<StateViewModel>> GetStatesAsync(string filter, string? countryId, int pageIndex = 1, int pageSize = 10000)
    => PaginationHelper.GetPaginationAsync(_context.States.Include(f => f.Country)
        .Where(f => !f.IsDeleted && !f.Country.IsDeleted),
        query =>
        {
            if (!string.IsNullOrEmpty(filter))
                query = query.Where(f => f.Name.Contains(filter) ||
                    f.RefNo.Contains(filter));

            if (!string.IsNullOrEmpty(countryId))
                query = query.Where(f => f.CountryId == countryId);

            return query;
        },
        sort =>
        {
            return sort.OrderBy(f => f.Name);
        },
        mapping =>
        {
            return mapping.Select(f => new StateViewModel
            {
                Id = f.Id,
                Name = f.Name,
                RefNo = f.RefNo,
                Country = f.Country?.Name,
                CountryId = f.CountryId,
                IsGovernorate = f.IsGovernorate
            }).ToList();
        },
        pageSize,
        pageIndex);
Product Compatible and additional computed target framework versions.
.NET net6.0 is compatible.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.4.4 191 10/9/2023
1.4.3 113 10/8/2023
1.4.2 96 9/29/2023
1.4.1 106 9/27/2023
1.4.0 112 9/21/2023
1.3.1 273 2/17/2023
1.3.0 217 2/15/2023
1.2.0 282 1/2/2023
1.1.0 258 12/26/2022
1.0.3 286 12/5/2022
1.0.2 311 12/3/2022
1.0.1 311 12/3/2022
1.0.0 300 12/3/2022