Update 20211218
This commit is contained in:
52
WebAPI/Helper/Dal/AccountDAL.cs
Normal file
52
WebAPI/Helper/Dal/AccountDAL.cs
Normal file
@@ -0,0 +1,52 @@
|
||||
|
||||
using APP.Utils;
|
||||
using BWPMModels;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data.SqlClient;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace APP.Dal
|
||||
{
|
||||
public class AccountDAL : IAccountDAL
|
||||
{
|
||||
private IDbHelper _db;
|
||||
public AccountDAL(IDbHelper db)
|
||||
{
|
||||
this._db = db;
|
||||
}
|
||||
|
||||
public async Task<UserModel> GetById(int id)
|
||||
{
|
||||
try
|
||||
{
|
||||
string sp = "Employee_GetById";
|
||||
List<SqlParameter> parms = new List<SqlParameter>();
|
||||
parms.Add(new SqlParameter("Id", id));
|
||||
var data = await _db.ExecuteToTableAsync<UserModel>(sp, parms, DbHelperEnum.StoredProcedure);
|
||||
return data != null ? data.FirstOrDefault() : null;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
throw new Exception(ex.Message);
|
||||
}
|
||||
}
|
||||
|
||||
public async Task<UserModel> GetByEmail(string email)
|
||||
{
|
||||
try
|
||||
{
|
||||
string sp = "Employee_GetByEmail";
|
||||
List<SqlParameter> parms = new List<SqlParameter>();
|
||||
parms.Add(new SqlParameter("Email", email));
|
||||
var data = await _db.ExecuteToTableAsync<UserModel>(sp, parms, DbHelperEnum.StoredProcedure);
|
||||
return data != null ? data.FirstOrDefault() : null;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
throw new Exception(ex.Message);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user