48 lines
1.5 KiB
C#
48 lines
1.5 KiB
C#
using DataDomain;
|
|
using StockBL.Interface;
|
|
using StockDAL.Interface;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
|
|
namespace StockBL
|
|
{
|
|
public class PersonStockFacade : IPersonStockFacade
|
|
{
|
|
private readonly IStockPersonConnect _stockPersonConnect;
|
|
private readonly IStockRepository _stockRepository;
|
|
|
|
public PersonStockFacade(IStockPersonConnect stockPersonConnect, IStockRepository stockRepository)
|
|
{
|
|
_stockPersonConnect = stockPersonConnect;
|
|
_stockRepository = stockRepository;
|
|
}
|
|
|
|
public IEnumerable<StockMember> GetUnconnectedShares()
|
|
{
|
|
var stockList = _stockRepository.GetAllStocks();
|
|
var connectList = _stockPersonConnect.GetAllConnectedStocks();
|
|
|
|
|
|
var stcList = (from st in stockList
|
|
where connectList.Any(co => st.Id == co.StockId)
|
|
select st).ToList();
|
|
|
|
var sList = stockList.Except(stcList).ToList();
|
|
|
|
return sList;
|
|
}
|
|
|
|
public IEnumerable<StockMember> GetAllSharesConnectedTo(int personId)
|
|
{
|
|
var personConnections = _stockPersonConnect.GetAllConnectionsByPersId(personId);
|
|
var stockList = _stockRepository.GetAllStocks();
|
|
|
|
var stcList = (from st in stockList
|
|
where personConnections.Any(pc => st.Id == pc.StockId)
|
|
select st).ToList();
|
|
return stcList;
|
|
}
|
|
}
|
|
}
|