Created
August 22, 2017 07:49
-
-
Save k4m4r82/6398e259ef86dcf1a3386a2e3cd55215 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using Dapper; | |
using log4net; | |
using WindowsServiceGammu.Model; | |
namespace WindowsServiceGammu.Repository | |
{ | |
public interface ISiswaRepository | |
{ | |
Siswa GetByNIS(string nis); | |
} | |
public class SiswaRepository : ISiswaRepository | |
{ | |
private IDapperContext _context; | |
private ILog _log; | |
public SiswaRepository(IDapperContext context, ILog log) | |
{ | |
this._context = context; | |
this._log = log; | |
} | |
public Siswa GetByNIS(string nis) | |
{ | |
Siswa siswa = null; | |
try | |
{ | |
var sql = @"select nis, nama | |
from siswa | |
where nis = @nis"; | |
siswa = _context.db.QuerySingleOrDefault<Siswa>(sql, new { nis }); | |
} | |
catch (Exception ex) | |
{ | |
_log.Error("Error:", ex); | |
} | |
return siswa; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment