Skip to main content

Definition

Assembly: CloudNimble.EasyAF.Business.EF6.dll Namespace: CloudNimble.EasyAF.Business Inheritance: System.Object

Syntax

CloudNimble.EasyAF.Business.ManagerBase<TContext>

Summary

Represents the base class for all EasyAF business logic managers. Provides access to a database context and message publishing capabilities for implementing business operations and workflows.

Remarks

This base class is designed to encapsulate business logic that requires database access and messaging capabilities. It’s particularly useful for implementing complex business processes such as user registration, order processing, or any workflow that needs to coordinate database operations with message publishing for event-driven architectures.

Type Parameters

  • TContext - The type of the database context (DbContext) used for data operations.

Examples

public class UserRegistrationManager : ManagerBase&lt;MyDbContext&gt;
{
    public UserRegistrationManager(MyDbContext context, IMessagePublisher publisher)
        : base(context, publisher) { }

    public async Task&lt;User&gt; RegisterUserAsync(string email, string password)
    {
        var user = new User { Email = email, Password = HashPassword(password) };
        DataContext.Users.Add(user);
        await DataContext.SaveChangesAsync();

        await MessagePublisher.PublishAsync(new UserRegisteredEvent { UserId = user.Id });
        return user;
    }
}

Constructors

.ctor

Initializes a new instance of the ManagerBase1` class.

Syntax

public ManagerBase(TContext dataContext, CloudNimble.SimpleMessageBus.Publish.IMessagePublisher messagePublisher)

Parameters

NameTypeDescription
dataContextTContextThe database context instance for data operations. Should be injected by the DI container.
messagePublisherCloudNimble.SimpleMessageBus.Publish.IMessagePublisherThe message publisher instance for publishing events. Should be injected by the DI container.

.ctor Inherited

Inherited from object

Syntax

public Object()

Properties

DataContext

Gets the database context instance used for data operations. This context is injected through the constructor and provides access to the database.

Syntax

public TContext DataContext { get; private set; }

Property Value

Type: TContext

MessagePublisher

Gets the message publisher instance used for publishing events and messages to the message bus. This publisher is injected through the constructor and enables event-driven architecture patterns.

Syntax

public CloudNimble.SimpleMessageBus.Publish.IMessagePublisher MessagePublisher { get; private set; }

Property Value

Type: CloudNimble.SimpleMessageBus.Publish.IMessagePublisher

Methods

Equals Inherited Virtual

Inherited from object

Syntax

public virtual bool Equals(object obj)

Parameters

NameTypeDescription
objobject?-

Returns

Type: bool

Equals Inherited

Inherited from object

Syntax

public static bool Equals(object objA, object objB)

Parameters

NameTypeDescription
objAobject?-
objBobject?-

Returns

Type: bool

GetHashCode Inherited Virtual

Inherited from object

Syntax

public virtual int GetHashCode()

Returns

Type: int

GetType Inherited

Inherited from object

Syntax

public System.Type GetType()

Returns

Type: System.Type

MemberwiseClone Inherited

Inherited from object

Syntax

protected internal object MemberwiseClone()

Returns

Type: object

ReferenceEquals Inherited

Inherited from object

Syntax

public static bool ReferenceEquals(object objA, object objB)

Parameters

NameTypeDescription
objAobject?-
objBobject?-

Returns

Type: bool

ToString Inherited Virtual

Inherited from object

Syntax

public virtual string ToString()

Returns

Type: string?