Project restructured
This commit is contained in:
14
StockDal/AppConnection.cs
Normal file
14
StockDal/AppConnection.cs
Normal file
@ -0,0 +1,14 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Configuration;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace RepositoryPattern
|
||||
{
|
||||
public class AppConnection
|
||||
{
|
||||
public static string ConnectionString => ConfigurationManager.ConnectionStrings["cn"].ConnectionString;
|
||||
}
|
||||
}
|
||||
37
StockDal/ProductRepository.cs
Normal file
37
StockDal/ProductRepository.cs
Normal file
@ -0,0 +1,37 @@
|
||||
using Dapper;
|
||||
using RepositoryPattern;
|
||||
using StockDal.Interface;
|
||||
using StockDomain;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using System.Data.SqlClient;
|
||||
|
||||
namespace StockDal
|
||||
{
|
||||
public class ProductRepository : IProductRepository
|
||||
{
|
||||
public bool Delete(string productId)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public IEnumerable<Product> GetProducts()
|
||||
{
|
||||
using System.Data.IDbConnection db = new SqlConnection(AppConnection.ConnectionString);
|
||||
if (db.State == ConnectionState.Closed)
|
||||
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);
|
||||
}
|
||||
|
||||
public bool Insert(Product product)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public bool Update(Product product)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
}
|
||||
17
StockDal/StockDal.csproj
Normal file
17
StockDal/StockDal.csproj
Normal 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>
|
||||
Reference in New Issue
Block a user