interface:
public interface IAuthenticationRepository
{
Task<IEnumerable<dynamic>> GetMenuItems(string groupIds);
}
class:
public class AuthenticationRepository : Base, IAuthenticationRepository
{
public AuthenticationRepository(string sqlConnRep) : base(sqlConnRep) { }
public async Task<IEnumerable<dynamic>> GetMenuItems(string groupIds)
{
var menuAndFunctions = $@"select gfm.GroupId, fmm.MenuId, cm.MenuType, cm.MenuName, fmm.FunctionId,cf.FunctionName,
cf.Description, cf.IsDefault from FunctionMenuMapping fmm
inner join CoCMenu cm
on cm.Id = fmm.MenuId
inner join CoCFunction cf
on cf.Id = fmm.FunctionId
inner join GroupFunctionMapping gfm
on gfm.FunctionId = fmm.FunctionId
where gfm.GroupId in (" + groupIds + ")";
return await ExecQueryDynamic<dynamic>(menuAndFunctions);
}
Create an instance for AuthenticationRepository
class and assigned the instance to the AuthenticationRepository
class object
public class AuthenticationLogic : IAuthenticationLogic
{
readonly AuthenticationRepository authenticationRepository;
public AuthenticationLogic( AuthenticationRepository authenticationRepository)
{
this.authenticationRepository = new AuthenticationRepository("");
}
}
Create an instance for AuthenticationRepository
class and assigned the instance to IAuthenticationRepository
interface
public class AuthenticationLogic : IAuthenticationLogic
{
readonly IAuthenticationRepository IauthenticationRepository;
public AuthenticationLogic(IAuthenticationRepository IauthenticationRepository)
{
this.IauthenticationRepository = new AuthenticationRepository("");
}
}
What is the difference between them? both are doing the same. Is any permanence difference for it? and which one is best approach?