Add project files.
This commit is contained in:
60
StockDAL/StockRepository.cs
Normal file
60
StockDAL/StockRepository.cs
Normal file
@ -0,0 +1,60 @@
|
||||
using DataDomain;
|
||||
using DatamodelLibrary;
|
||||
using StockDAL.Interface;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace StockDAL
|
||||
{
|
||||
public class StockRepository : IStockRepository
|
||||
{
|
||||
public void SaveStockMember(StockMember stockMember)
|
||||
{
|
||||
using (var context = new StockContext())
|
||||
{
|
||||
var sm = context.Stocks.Add(stockMember);
|
||||
context.SaveChanges();
|
||||
}
|
||||
}
|
||||
|
||||
public void UpdateActualPrice(int id, decimal price)
|
||||
{
|
||||
using var context = new StockContext();
|
||||
var entity = (from stk in context.Stocks
|
||||
where stk.Id == id
|
||||
select stk).FirstOrDefault();
|
||||
|
||||
entity.ActValue = price;
|
||||
entity.ActDate = DateTime.Today;
|
||||
|
||||
context.SaveChanges();
|
||||
}
|
||||
|
||||
public IEnumerable<StockMember> GetAllStocks()
|
||||
{
|
||||
using var context = new StockContext();
|
||||
var output = context.Stocks;
|
||||
return output.ToList();
|
||||
}
|
||||
|
||||
public IEnumerable<StockMember> GetAllRemainingStocks()
|
||||
{
|
||||
using var context = new StockContext();
|
||||
var output = (from stk in context.Stocks
|
||||
where stk.SoldDate == null
|
||||
select stk).ToList();
|
||||
return output;
|
||||
}
|
||||
|
||||
public void InsertMany(List<StockMember> stockMembers)
|
||||
{
|
||||
using var context = new StockContext();
|
||||
context.Stocks.AddRange(stockMembers);
|
||||
context.SaveChanges();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user