40 lines
1.3 KiB
C#
40 lines
1.3 KiB
C#
using Dapper;
|
|
using SolarPower.Helper;
|
|
using SolarPower.Models;
|
|
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 OperationRepository : RepositoryBase<Operation>, IOperationRepository
|
|
{
|
|
public OperationRepository(IDatabaseHelper databaseHelper) : base(databaseHelper)
|
|
{
|
|
tableName = "operation_plan_create";
|
|
}
|
|
public async Task<List<PowerStationIdList>> GetPowerStationIdList(int UserId)
|
|
{
|
|
List<PowerStationIdList> result;
|
|
using (IDbConnection conn = this._databaseHelper.GetConnection())
|
|
{
|
|
try
|
|
{
|
|
var sql = @$"SELECT tn.Id AS Value, tn.Name AS Text FROM {tableName} tn LEFT JOIN power_station_operation_personnel pp
|
|
ON tn.Id=pp.PowerStationId
|
|
WHERE pp.UserId = @userid";
|
|
result = (await conn.QueryAsync<PowerStationIdList>(sql, new { userid = UserId })).ToList();
|
|
}
|
|
catch (Exception exception)
|
|
{
|
|
throw exception;
|
|
}
|
|
return result;
|
|
}
|
|
}
|
|
}
|
|
}
|