Shares can be handled by owners

This commit is contained in:
2021-03-13 17:06:01 +01:00
parent b25c6fd538
commit a99115a031
12 changed files with 213 additions and 49 deletions

View File

@ -20,6 +20,15 @@ namespace StockDAL
return connections;
}
public IEnumerable<PersonStock> GetAllConnectedStocks()
{
using var context = new StockContext();
var entities = (from spc in context.PersonStocks
where spc.PersonId != 0
select spc).ToList();
return entities;
}
public PersonStock SavePersonStockConnection(PersonStock personStock)
{
using var context = new StockContext();
@ -46,5 +55,18 @@ namespace StockDAL
return entity;
}
public void RemoveConnectedShare(PersonStock personStock)
{
using var context = new StockContext();
var entity = (from ps in context.PersonStocks
where ps.StockId == personStock.StockId
select ps).FirstOrDefault();
if (entity != null)
{
context.PersonStocks.Remove(entity);
context.SaveChanges();
}
}
}
}
}