public PortfolioPositionModel DeletePortfolioPosition(long id)
        {
            var transaction = PortfolioPositionRepository.GetById(id);

            PortfolioPositionRepository.Delete(transaction);
            PortfolioPositionRepository.Save();
            return(Mapper.Map <PortfolioPositionModel>(transaction));
        }
        public PortfolioPositionModel CreatePortfolioSalePosition(PortfolioPositionModel model)
        {
            var portfolio      = PortfolioRepository.GetById(model.PortfolioId);
            var otherPosOfIsin =
                PortfolioPositionRepository
                .Query()
                .First(positionEntity => positionEntity.Isin == model.Isin && positionEntity.Name != null);
            var entity = new SalePositionEntity
            {
                Amount   = 0,
                DateTime = model.DateTime,
                Isin     = model.Isin,
                Name     = otherPosOfIsin.Name,
                CurrentValueCurrencyIso  = otherPosOfIsin.CurrentValueCurrencyIso,
                OriginalValueCurrencyIso = otherPosOfIsin.OriginalValueCurrencyIso,
                Portfolio = portfolio
            };
            var insertedEntity = PortfolioPositionRepository.Insert(entity);

            PortfolioPositionRepository.Save();
            return(Mapper.Map <PortfolioPositionModel>(insertedEntity));
        }