Project restructured

This commit is contained in:
2021-01-10 12:34:59 +01:00
parent 4c069298f2
commit dd530c02a9
7 changed files with 37 additions and 10 deletions

View File

@ -9,6 +9,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "StockDomain", "StockDomain\
EndProject EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "StockDal.Interface", "StockDal.Interface\StockDal.Interface.csproj", "{65F33E97-16CF-471A-9C59-D0D17287856C}" Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "StockDal.Interface", "StockDal.Interface\StockDal.Interface.csproj", "{65F33E97-16CF-471A-9C59-D0D17287856C}"
EndProject EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "StockDal", "StockDal\StockDal.csproj", "{E3C410EE-5040-48E1-9C87-DC9A0D011DC7}"
EndProject
Global Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU Debug|Any CPU = Debug|Any CPU
@ -27,6 +29,10 @@ Global
{65F33E97-16CF-471A-9C59-D0D17287856C}.Debug|Any CPU.Build.0 = Debug|Any CPU {65F33E97-16CF-471A-9C59-D0D17287856C}.Debug|Any CPU.Build.0 = Debug|Any CPU
{65F33E97-16CF-471A-9C59-D0D17287856C}.Release|Any CPU.ActiveCfg = Release|Any CPU {65F33E97-16CF-471A-9C59-D0D17287856C}.Release|Any CPU.ActiveCfg = Release|Any CPU
{65F33E97-16CF-471A-9C59-D0D17287856C}.Release|Any CPU.Build.0 = Release|Any CPU {65F33E97-16CF-471A-9C59-D0D17287856C}.Release|Any CPU.Build.0 = Release|Any CPU
{E3C410EE-5040-48E1-9C87-DC9A0D011DC7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{E3C410EE-5040-48E1-9C87-DC9A0D011DC7}.Debug|Any CPU.Build.0 = Debug|Any CPU
{E3C410EE-5040-48E1-9C87-DC9A0D011DC7}.Release|Any CPU.ActiveCfg = Release|Any CPU
{E3C410EE-5040-48E1-9C87-DC9A0D011DC7}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection EndGlobalSection
GlobalSection(SolutionProperties) = preSolution GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE HideSolutionNode = FALSE

View File

@ -1,4 +1,5 @@
using Autofac; using Autofac;
using StockDal;
using StockDal.Interface; using StockDal.Interface;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;

View File

@ -1,4 +1,4 @@
<Project Sdk="Microsoft.NET.Sdk.WindowsDesktop"> <Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup> <PropertyGroup>
<OutputType>WinExe</OutputType> <OutputType>WinExe</OutputType>
@ -14,6 +14,7 @@
<ItemGroup> <ItemGroup>
<ProjectReference Include="..\StockDal.Interface\StockDal.Interface.csproj" /> <ProjectReference Include="..\StockDal.Interface\StockDal.Interface.csproj" />
<ProjectReference Include="..\StockDal\StockDal.csproj" />
<ProjectReference Include="..\StockDomain\StockDomain.csproj" /> <ProjectReference Include="..\StockDomain\StockDomain.csproj" />
</ItemGroup> </ItemGroup>

View File

@ -4,6 +4,10 @@
<TargetFramework>netcoreapp3.1</TargetFramework> <TargetFramework>netcoreapp3.1</TargetFramework>
</PropertyGroup> </PropertyGroup>
<ItemGroup>
<PackageReference Include="Dapper" Version="2.0.78" />
</ItemGroup>
<ItemGroup> <ItemGroup>
<ProjectReference Include="..\StockDomain\StockDomain.csproj" /> <ProjectReference Include="..\StockDomain\StockDomain.csproj" />
</ItemGroup> </ItemGroup>

View File

@ -1,15 +1,13 @@
using System; using Dapper;
using RepositoryPattern;
using StockDal.Interface;
using StockDomain;
using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Data; using System.Data;
using System.Data.SqlClient; using System.Data.SqlClient;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Dapper;
using StockDal.Interface;
using StockDomain;
namespace RepositoryPattern namespace StockDal
{ {
public class ProductRepository : IProductRepository public class ProductRepository : IProductRepository
{ {
@ -20,7 +18,7 @@ namespace RepositoryPattern
public IEnumerable<Product> GetProducts() public IEnumerable<Product> GetProducts()
{ {
using IDbConnection db = new SqlConnection(AppConnection.ConnectionString); using System.Data.IDbConnection db = new SqlConnection(AppConnection.ConnectionString);
if (db.State == ConnectionState.Closed) if (db.State == ConnectionState.Closed)
db.Open(); db.Open();
return db.Query<Product>("select ProductId, ProductName, UnitPrice, UnitsInStock ,RIGHT('00000' + cast(ProductId as varchar) , 5) As Barcode from Products", commandType: CommandType.Text); return db.Query<Product>("select ProductId, ProductName, UnitPrice, UnitsInStock ,RIGHT('00000' + cast(ProductId as varchar) , 5) As Barcode from Products", commandType: CommandType.Text);

17
StockDal/StockDal.csproj Normal file
View File

@ -0,0 +1,17 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Dapper" Version="2.0.78" />
<PackageReference Include="System.Configuration.ConfigurationManager" Version="5.0.0" />
<PackageReference Include="System.Data.SqlClient" Version="4.8.2" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\StockDal.Interface\StockDal.Interface.csproj" />
</ItemGroup>
</Project>