public Transaction registerTransaction(CalculResultBean calculBean, TransactionTypeEnum transactionType)
        {
            using (var context = new bourseContainer())
            {
                decimal giftCouponValue = calculBean.totalBonCadeau;
                decimal couponValue = calculBean.totalAvoir;
                decimal usedCouponExchangeValue = calculBean.totalEchangeAndAvoirUtil;
                decimal exchangeValue = calculBean.totalEchange;
                decimal convertedCouponExchangeValue = calculBean.avoirEchangeConverti;
                decimal discountOfferValue = calculBean.totalRemise;
                decimal payCardValue = calculBean.monnaiePayeeCB;
                decimal cashValue = calculBean.monnaiePayeeESP;
                decimal realCashValue = calculBean.monnaiePayeeReelESP;
                decimal emittedCouponValue = calculBean.ARendreAvoir;
                decimal emittedCashValue = calculBean.ARendreESP;
                decimal realEmittedCashValue = calculBean.ARendreReelESP;
                decimal totalSalesValue = calculBean.totalProduits;
                decimal totalBuyValue = calculBean.totalEchange;
                int productCount = calculBean.productCount;
                string store = ""; //TODO

                Transaction transaction = new Transaction
                {
                    giftCouponValue = giftCouponValue,
                    couponValue = couponValue,
                    usedCouponExchangeValue = usedCouponExchangeValue,
                    exchangeValue = exchangeValue,
                    convertedCouponExchangeValue = convertedCouponExchangeValue,
                    discountOfferValue = discountOfferValue,
                    paycardValue = payCardValue,
                    cashValue = cashValue,
                    realCashValue = realCashValue,
                    emittedCashValue = emittedCashValue,
                    realEmittedCashValue = realEmittedCashValue,
                    totalSalesValue = totalSalesValue,
                    totalBuyValue = totalBuyValue,
                    productCount = productCount,
                    store = store,
                    datetime = DateTime.Now,
                    transactionType = transactionType.ToString()
                };

                context.Entry(transaction).State = EntityState.Added;
                context.SaveChanges();
                context.Entry(transaction).State = EntityState.Detached;

                return transaction;
            }
        }
 public void LoadData(CalculResultBean _calculBean)
 {
     this.calulBean = _calculBean;
     ValeurAAtteindre.Text = VALEUR_A_ATTEINDRE_PREFIX + _calculBean.resteAPayer;
 }
 public void registerEmittedCouponForVente(CalculResultBean calculBean, Transaction transaction, AvoirTypeEnum transactionSpecificity, ProductTypeEnum onlyOn)
 {
     using (var context = new bourseContainer())
     {
         EmittedCoupon emittedCoupon = new EmittedCoupon
         {
             datetime = DateTime.Now,
             value = calculBean.ARendreAvoir,
             Transaction = transaction,
             onlyOn = onlyOn.ToString(),
             transactionSpecificity = transactionSpecificity.ToString()
         };
         
         context.Entry(emittedCoupon).State = EntityState.Added;
         context.SaveChanges();
         context.Entry(emittedCoupon).State = EntityState.Detached;
     }
 }
 public CalculResultBean getResultBeanWithoutRemises(ObservableCollection<TableAvoir> AvoirCollection,
     ObservableCollection<TableEchangeDirect> EchangeDirectCollection,
     ObservableCollection<TableProduct> ProductsCollection)
 {
     decimal avoirsSum = getAvoirSumFromCollection(AvoirCollection);
     decimal echangeSum = getEchangeSumFromCollection(AvoirCollection);
     decimal bonCadeauSum = getBonCadeauSumFromCollection(AvoirCollection);
     decimal echangeDirectSum = getEchangeDirectSumFromCollection(EchangeDirectCollection);
     decimal productsSum = getProductsSumFromCollection(ProductsCollection);
     
     CalculResultBean result = new CalculResultBean
     {
         totalProduits = productsSum,
         totalAvoir = avoirsSum,
         totalEchangeDirect = echangeDirectSum,
         totalEchange = echangeSum,
         totalEchangeAndAvoir = echangeSum + avoirsSum,
         totalBonCadeau = bonCadeauSum
     };
     
     return result;
 }