Add project files.

This commit is contained in:
2021-03-02 17:44:53 +01:00
parent 961fc862e5
commit fe65037c76
37 changed files with 2656 additions and 0 deletions

View 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();
}
}
}