BeireMKit.Notification 1.0.5

dotnet add package BeireMKit.Notification --version 1.0.5
                    
NuGet\Install-Package BeireMKit.Notification -Version 1.0.5
                    
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="BeireMKit.Notification" Version="1.0.5" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="BeireMKit.Notification" Version="1.0.5" />
                    
Directory.Packages.props
<PackageReference Include="BeireMKit.Notification" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add BeireMKit.Notification --version 1.0.5
                    
#r "nuget: BeireMKit.Notification, 1.0.5"
                    
#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.
#:package BeireMKit.Notification@1.0.5
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=BeireMKit.Notification&version=1.0.5
                    
Install as a Cake Addin
#tool nuget:?package=BeireMKit.Notification&version=1.0.5
                    
Install as a Cake Tool

BeireMKit Notification

The BeireMKit Notification library was developed to facilitate the handling of messages in the project, using the Notification Pattern.

Features

  1. handle system messages in a simplified way.
  2. deal with different message contexts

Requirements

Make sure you have installed the .NET Core 6 SDK on your machine before you start.

How to use

  • Add the notification service to Startup
    • In the ConfigureServices method of the Startup class, add the notification service using the ConfigureNotification() method:
    public void ConfigureServices(IServiceCollection services)
    {
    	services.ConfigureNotification();
      services.ConfigureNotificationContext();
    }
    

Usage example

  • Services example
     using BeireMKit.Notification.Interfaces;
    
     public class Service : IService
     {
         private readonly INotification _notification;
         private readonly IUnitOfWork _uow;
         private readonly IRepository<Entity> _repository;
    
         public Service(
             INotification notification
             IUnitOfWork uow,
             IRepository<Entity> repository,
             )
         {
             _notification = notification;
             _uow = uow;
             _repository = repository;
         }
    
         public void Delete(int? id)
         {
     	// Types
             _notification.AddSuccess("deletion success", "key to identifying msg", "success-custom");
             _notification.AddError("deletion error", "key to identifying msg", "error-custom");
             _notification.AddInfo("deletion info", "key to identifying msg", "info-custom");
             _notification.AddWarning("deletion warning", "key to identifying msg", "warning-custom");
    
             // clear messages
             _notification.ClearMessages();
    
             // verification
             _notification.HasMessages;
             _notification.HasErrors;
         }
     }
    
  • Controller example
     [HttpDelete("delete/{id}")]
     public IActionResult Delete([FromRoute] int id)
     {
         _service.Delete(id);
    
         if (_notification.HasMessages)
         {
     	  return Ok(_notification.Messages);
         }
         if (_notification.HasErrors)
         {
     	  return Ok(_notification.Messages.Any(x => x.Type == MessageType.Error));
         }
     	return Ok();
     }
    
  • notification context example
     using BeireMKit.Notification;
    
     public class OrderService
     {
     	private readonly NotificationContext _notificationContext;
    
     	public OrderService(NotificationContext notificationContext)
     	{
     		_notificationContext = notificationContext;
     	}
    
     	public void CreateOrder()
     	{
     		var orderNotification = _notificationContext.GetNotification("OrderCreated");
    
     		// Another context
     		var orderCancelNotification = _notificationContext.GetNotification("OrderCancel");
    
     		try
     		{
     			// code..
    
     			orderNotification.AddSuccess("Order was created successfully.");
     		}
     		catch (Exception ex)
     		{
     			orderNotification.AddError($"Error creating order: {ex.Message}");
     		}
     	}
    
     	public bool HasOrderCreationErrors()
     	{
     		return _notificationContext.HasErrors("OrderCreated");
     	}
    
     	public IReadOnlyCollection<MessageResult> GetOrderCreationMessages()
     	{
     		return _notificationContext.GetNotifications("OrderCreated");
     	}
    
     	public void ClearOrderCreationMessages()
     	{
     		_notificationContext.ClearMessages("OrderCreated");
     	}
     }
    
    
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 is compatible.  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.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.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.0.5 191 6/11/2024
1.0.4 170 6/10/2024
1.0.3 168 5/30/2024
1.0.2 172 5/16/2024
1.0.1 167 5/14/2024