private static decimal?CalculateProfit(Owning owning, List <StockCodeRate> bist)
        {
            var stock = bist.FirstOrDefault(x => x.Code == owning.Name);

            if (stock != null)
            {
                var currentValue  = stock.Rate;
                var purchaseValue = owning.PurchaseValue;
                return(owning.PurchaseQuantity * (currentValue - purchaseValue));
            }
            return(null);
        }
 public static OwningDto ConvertToDto(this Owning owning, List <StockCodeRate> bist)
 {
     return(new OwningDto
     {
         Name = owning.Name,
         SellCommission = owning.SellCommission,
         SellDate = owning.SellDate,
         PurchaseDate = owning.PurchaseDate,
         SellValue = owning.SellValue,
         PurchaseCommission = owning.PurchaseCommission,
         PurchaseQuantity = owning.PurchaseQuantity,
         PurchaseValue = owning.PurchaseValue,
         CurrentValue = bist.FirstOrDefault(x => x.Code == owning.Name)?.Rate,
         Profit = CalculateProfit(owning, bist)
     });
 }