Add project files.
This commit is contained in:
89
StockDal/StockMemberRepository.cs
Normal file
89
StockDal/StockMemberRepository.cs
Normal file
@ -0,0 +1,89 @@
|
||||
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 StockMemberRepository : IStockMemberRepository
|
||||
{
|
||||
public bool Delete(string stockMemberId)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void InsertMany(List<StockMember> stockMembers)
|
||||
{
|
||||
using (IDbConnection db = new SqlConnection(StockDBConnection.ConnectionString))
|
||||
{
|
||||
if (db.State == ConnectionState.Closed)
|
||||
db.Open();
|
||||
db.Execute(
|
||||
@"INSERT INTO [dbo].[StockMember]
|
||||
(StockId
|
||||
,StockExtId
|
||||
,BuyValue
|
||||
,BuyDate
|
||||
,ActValue
|
||||
,ActDate
|
||||
,SoldValue
|
||||
,SoldDate
|
||||
,Comment
|
||||
,PostAmount)
|
||||
VALUES
|
||||
(@StockId
|
||||
,@StockExtId
|
||||
,@BuyValue
|
||||
,@BuyDate
|
||||
,@ActValue
|
||||
,@ActDate
|
||||
,@SoldValue
|
||||
,@SoldDate
|
||||
,@Comment
|
||||
,@PostAmount)
|
||||
", stockMembers);
|
||||
}
|
||||
}
|
||||
|
||||
public void UpdateActPrice(int Id, decimal price)
|
||||
{
|
||||
using (IDbConnection db = new SqlConnection(StockDBConnection.ConnectionString))
|
||||
{
|
||||
if (db.State == ConnectionState.Closed)
|
||||
db.Open();
|
||||
|
||||
db.Execute(
|
||||
@"UPDATE [dbo].[StockMember]
|
||||
SET ActValue = @val,
|
||||
ActDate = @date
|
||||
WHERE Id = @id
|
||||
", new { val = price, date = DateTime.Today, id = Id });
|
||||
}
|
||||
}
|
||||
|
||||
IEnumerable<StockMember> IStockMemberRepository.GetStocks()
|
||||
{
|
||||
using (IDbConnection db = new SqlConnection(StockDBConnection.ConnectionString))
|
||||
{
|
||||
if (db.State == ConnectionState.Closed)
|
||||
db.Open();
|
||||
return db.Query<StockMember>(@"SELECT Id
|
||||
,StockId
|
||||
,StockExtId
|
||||
,BuyValue
|
||||
,BuyDate
|
||||
,ActValue
|
||||
,ActDate
|
||||
,SoldValue
|
||||
,SoldDate
|
||||
,Comment
|
||||
,PostAmount
|
||||
FROM dbo.StockMember", commandType: CommandType.Text);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user