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, IRoleRepository { public RoleRepository(IDatabaseHelper databaseHelper) : base(databaseHelper) { tableName = "Role"; } public async Task> GetRoleSelectOptionListAsync(int companyId) { List 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(sql, new { CompanyId = companyId })).ToList(); } catch (Exception exception) { throw exception; } return result; } } } }