40 lines
1.2 KiB
C#
40 lines
1.2 KiB
C#
using Dapper;
|
|
using SolarPower.Helper;
|
|
using SolarPower.Models.Role;
|
|
using SolarPower.Repository.Interface;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Data;
|
|
using System.Linq;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace SolarPower.Repository.Implement
|
|
{
|
|
public class RoleRepository : RepositoryBase<Role>, IRoleRepository
|
|
{
|
|
public RoleRepository(IDatabaseHelper databaseHelper) : base(databaseHelper)
|
|
{
|
|
tableName = "Role";
|
|
}
|
|
|
|
public async Task<List<RoleSelectItemList>> GetRoleSelectOptionListAsync(int companyId)
|
|
{
|
|
List<RoleSelectItemList> result;
|
|
using (IDbConnection conn = this._databaseHelper.GetConnection())
|
|
{
|
|
try
|
|
{
|
|
var sql = $"SELECT Id AS Value, Name AS Text FROM {tableName} WHERE Deleted = 0 AND CompanyId = @CompanyId";
|
|
|
|
result = (await conn.QueryAsync<RoleSelectItemList>(sql, new { CompanyId = companyId })).ToList();
|
|
}
|
|
catch (Exception exception)
|
|
{
|
|
throw exception;
|
|
}
|
|
return result;
|
|
}
|
|
}
|
|
}
|
|
}
|