-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
5ebef49
commit 0cdf01f
Showing
74 changed files
with
2,934 additions
and
0 deletions.
There are no files selected for viewing
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added
BIN
+6.32 KB
.vs/TaylorLE2/FileContentIndex/04efa7a0-932d-4266-83e2-9d79dadb9f0a.vsidx
Binary file not shown.
Binary file added
BIN
+9.65 KB
.vs/TaylorLE2/FileContentIndex/1adcee24-176a-4481-a524-fbd4e820ebd6.vsidx
Binary file not shown.
Binary file added
BIN
+7.33 KB
.vs/TaylorLE2/FileContentIndex/ce6a1694-5607-4505-a08f-e1e77b1268ed.vsidx
Binary file not shown.
Binary file added
BIN
+6.9 KB
.vs/TaylorLE2/FileContentIndex/d590926b-5173-4df5-8f5f-fe8fb3961684.vsidx
Binary file not shown.
Empty file.
Binary file not shown.
Binary file not shown.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<TargetFramework>net6.0</TargetFramework> | ||
<ImplicitUsings>enable</ImplicitUsings> | ||
<Nullable>enable</Nullable> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="Dapper" Version="2.0.123" /> | ||
<PackageReference Include="Microsoft.Extensions.Configuration" Version="6.0.1" /> | ||
<PackageReference Include="System.Data.SqlClient" Version="4.8.5" /> | ||
</ItemGroup> | ||
|
||
</Project> |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
using BlogDataLibrary.Database; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace BlogDataLibrary.Data | ||
{ | ||
public class SqlData | ||
{ | ||
private ISqlDataAccess _db; | ||
private const string connectionStringName = "sqlDb"; | ||
|
||
public SqlData(ISqlDataAccess db) | ||
{ | ||
_db = db; | ||
} | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
namespace BlogDataLibrary.Database | ||
{ | ||
public interface ISqlDataAccess | ||
{ | ||
List<T> LoadData<T, U>(string sqlStatement, U parameters, string connectionStringName, bool isStoredProcedure); | ||
void SaveData<T>(string sqlStatement, T parameters, string connectionStringName, bool isStoredProcedure); | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
using Dapper; | ||
using Microsoft.Extensions.Configuration; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Data; | ||
using System.Data.SqlClient; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace BlogDataLibrary.Database | ||
{ | ||
public class SqlDataAccess : ISqlDataAccess | ||
{ | ||
private IConfiguration _config; | ||
|
||
public SqlDataAccess(IConfiguration config) | ||
{ | ||
_config = config; | ||
} | ||
|
||
public List<T> LoadData<T, U>(string sqlStatement, | ||
U parameters, | ||
string connectionStringName, | ||
bool isStoredProcedure) | ||
{ | ||
CommandType commandType = CommandType.Text; | ||
string connectionString = _config.GetConnectionString(connectionStringName); | ||
|
||
if (isStoredProcedure) | ||
{ | ||
commandType = CommandType.StoredProcedure; | ||
} | ||
|
||
using (IDbConnection connection = new SqlConnection(connectionString)) | ||
{ | ||
List<T> rows = connection.Query<T>(sqlStatement, parameters, | ||
commandType: commandType).ToList(); | ||
return rows; | ||
} | ||
} | ||
|
||
public void SaveData<T>(string sqlStatement, | ||
T parameters, | ||
string connectionStringName, | ||
bool isStoredProcedure) | ||
{ | ||
string connectionString = _config.GetConnectionString(connectionStringName); | ||
CommandType commandType = CommandType.Text; | ||
|
||
if (isStoredProcedure) | ||
{ | ||
commandType = CommandType.StoredProcedure; | ||
} | ||
|
||
using (IDbConnection connection = new SqlConnection(connectionString)) | ||
{ | ||
connection.Execute(sqlStatement, parameters, commandType: commandType); | ||
} | ||
} | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace BlogDataLibrary.Models | ||
{ | ||
public class ListPostModel | ||
{ | ||
public int Id { get; set; } | ||
public string Title { get; set; } | ||
public string Body { get; set; } | ||
public DateTime DateCreated { get; set; } | ||
public string UserName { get; set; } | ||
public string FirstName { get; set; } | ||
public string LastName { get; set; } | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace BlogDataLibrary.Models | ||
{ | ||
public class PostModel | ||
{ | ||
public int Id { get; set; } | ||
public int UserId { get; set; } | ||
public string Title { get; set; } | ||
public string Body { get; set; } | ||
public DateTime DateCreated { get; set; } | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace BlogDataLibrary.Models | ||
{ | ||
public class UserModel | ||
{ | ||
public int Id { get; set; } | ||
public string UserName { get; set; } | ||
public string FirstName { get; set; } | ||
public string LastName { get; set; } | ||
public string Password { get; set; } | ||
} | ||
} |
Oops, something went wrong.