using Dapper; using Repository.BackendRepository.Interface; using Repository.Helper; using System; using System.Collections.Generic; using System.Data; using System.Linq; using System.Threading.Tasks; namespace Repository.BackendRepository.Implement { public class UserInfoRepository : BackendRepository, IUserInfoRepository { public UserInfoRepository(IDatabaseHelper databaseHelper) : base(databaseHelper) { //con = databaseHelper.GetMSSqlConnection(); } public async Task GetOneByAccountAsync(string account) { A result; using (IDbConnection conn = GetDbConnection()) { try { var sql = $"SELECT * FROM userinfo WHERE deleted = 0 AND status = @Status AND account = @Account"; result = await conn.QueryFirstOrDefaultAsync(sql, new { Status = 0, Account = account }); } catch (Exception exception) { throw exception; } return result; } } public A GetMyUserInfoByAccount(string account) { A result; using (IDbConnection conn = GetDbConnection()) { conn.Open(); try { var sql = $@"SELECT a.*,b.layer FROM userinfo a left join role b on a.role_guid = b.role_guid WHERE a.deleted = 0 AND a.status = @Status AND account = @Account "; result = conn.QueryFirstOrDefault(sql, new { Status = 0, Account = account }); } catch (Exception exception) { throw exception; } finally { conn.Close(); } return result; } } } }