Exemplo n.º 1
0
 /// <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);
     }
 }
Exemplo n.º 2
0
 /// <summary>
 /// The method to create
 /// </summary>
 /// <param name="buyingTransaction"></param>
 /// <returns>Return true or false; true indicates the the creation is successful.</returns>
 public bool CreateBuyingTransaction(Domain.Layer.Transactions.BuyingTransaction buyingTransaction)
 {
     buyingTransactionRep = new BuyingTransactionRepository();
     return(buyingTransactionRep.CreateBuyingTransaction(buyingTransaction));
 }