public List <ThanaModel> GetThana(int districtId = -1, int thanaId = -1) { using (var con = ConnectionGetway.GetConnection()) { var thana = con.Query <ThanaModel>($@"Select * FROM tblThana WHERE DistrictId = (CASE WHEN {districtId}<>-1 THEN {districtId} ELSE DistrictId END) AND Id = (CASE WHEN {thanaId}<>-1 THEN {thanaId} ELSE Id END) ORDER BY Name").ToList(); return(thana); } }
public List <DistrictModel> GetDistrict(int districtId = -1) { using (var con = ConnectionGetway.GetConnection()) { var districts = con.Query <DistrictModel>($"Select * FROM tblDistricts WHERE Id = CASE WHEN {districtId}<>-1 THEN {districtId} ELSE Id END ORDER BY Name").ToList(); return(districts); } }
public UserViewModel Get <UserViewModel>(string userName, string password) { using (var con = ConnectionGetway.GetConnection()) { string query = $"SELECT * FROM tblUsers WHERE Name='{userName}' AND Password='******'"; return(con.Query <UserViewModel>(query).FirstOrDefault()); } }
public UserModel Get(int id) { using (var con = ConnectionGetway.GetConnection()) { string query = $"SELECT * FROM tblUsers WHERE Id={id}"; return(con.Query <UserModel>(query).FirstOrDefault()); } }
public bool ChangePassword(UserModel user) { using (var con = ConnectionGetway.GetConnection()) { string query = $"UPDATE tblUsers SET Password = '******' WHERE Code = '{user.Code}' AND CompanyCode='{user.CompanyCode}'"; return(con.Execute(query) > 0); } }