/// <summary> /// The method to calculate profit or loss. /// </summary> /// <param name="userId">The User id.</param> /// <returns>The profi or loss object.</returns> public ProfitOrLoss GetProfitOrLoss(short userId) { try { buyingTransactionRep = new BuyingTransactionRepository(); Domain.Layer.Transactions.BuyingTransaction buyingTransaction = buyingTransactionRep.GetLastBuyingTransaction(userId); if (buyingTransaction != null) { productRep = new ProductRepository(); //Hard coded the product since we have only oone product with ID as 1 now. if (CurrentGoldPricePerGram.Instance.currentGoldPricePerGram == null) { CurrentGoldPricePerGram.Instance.currentGoldPricePerGram = productRep.GetProduct(buyingTransaction.ProductId).PricePerGram; } sellingTransaction = new SellingTransaction(); return(sellingTransaction.GetProfitOrLoss(buyingTransaction)); } else { return(null); } } catch (Exception ex) { return(null); } }
/// <summary> /// The method to get last buying transaction. /// </summary> /// <returns>The buying transaction domain object.</returns> public Domain.Layer.Transactions.BuyingTransaction GetLastBuyingTransaction(short userId) { return(buyingTransactionRep.GetLastBuyingTransaction(userId)); }