vendredi 15 avril 2016

How do I enforce a certain type of Service is only used by a certain type of Entity

I am trying to design an application, where in I am stuck at a simple problem. we have two types of Users IUser and IAdministrator and then we have two service classes called IUserOperationsService and IAdministratorOperationsService. Based on what type of user is logged on we want to decide what operations are available. but my question is how do I enforce that Administrative operations are only available to IAdministrator and not IUser

IUser -

public interface IUser
{
    string UserName { get; set; }
    string Name { get; set; }
}

IAdministrator-

public interface IAdministrator : IUser
{
}

IUserOperationsService-

public interface IUserOperationsService
{
    IUser GetUserByUserId(short userId);
}

IAdministratorOperationsService-

 public interface IAdministratorOperationsService
{
    short AddUser(IUser user);
    bool DeleteUser(IUser user);
    bool EditUser(IUser user);
}

Aucun commentaire:

Enregistrer un commentaire