// Add your own data access methods here.  If you wish to
        // expose your public method to a WCF service, marked them with
        // the attribute [NCPublish], and another T4 template will generate your service contract
        public void DeleteSymbol(string symbole)
        {
            try
            {
                using (var unitOfWork = new EFUnitOfWork())
                {
                    var priceRepo =
                        new PriceRepository(new EFRepository <Price>(), unitOfWork);

                    ObjectSet <Price> priceObj =
                        ((CurrentDeskClientsEntities)priceRepo.Repository.UnitOfWork.Context).Prices;

                    var price = priceObj.Where(s => s.Symbole == symbole).FirstOrDefault();
                    if (price != null)
                    {
                        priceRepo.Delete(price);
                        priceRepo.Save();
                    }
                }
            }
            catch (Exception ex)
            {
                CommonErrorLogger.CommonErrorLog(ex, System.Reflection.MethodBase.GetCurrentMethod().Name);
            }
        }
        public void DeletePrice(List <string> lstSymbole)
        {
            try
            {
                using (var unitOfWork = new EFUnitOfWork())
                {
                    var priceRepo =
                        new PriceRepository(new EFRepository <Price>(), unitOfWork);

                    ObjectSet <Price> priceObj =
                        ((CurrentDeskClientsEntities)priceRepo.Repository.UnitOfWork.Context).Prices;

                    var lstPrice = priceObj.Where(p => lstSymbole.Contains(p.Symbole)).ToList();

                    foreach (var price in lstPrice)
                    {
                        priceRepo.Delete(price);
                    }
                    priceRepo.Save();
                }
            }
            catch (Exception ex)
            {
                CommonErrorLogger.CommonErrorLog(ex, System.Reflection.MethodBase.GetCurrentMethod().Name);
            }
        }
        /// <summary>
        /// This method returns exchange rate for a pair of currency symbols
        /// </summary>
        /// <param name="fromCurr">fromCurr</param>
        /// <param name="toCurr">toCurr</param>
        /// <param name="inverse">inverse</param>
        /// <returns></returns>
        public decimal GetExchangeRateForCurrencyPair(string fromCurr, string toCurr, ref bool inverse)
        {
            try
            {
                using (var unitOfWork = new EFUnitOfWork())
                {
                    var priceRepo =
                        new PriceRepository(new EFRepository <Price>(), unitOfWork);

                    ObjectSet <Price> priceObj =
                        ((CurrentDeskClientsEntities)priceRepo.Repository.UnitOfWork.Context).Prices;

                    //Get fromTo currency pair price
                    var price = priceObj.Where(p => p.Symbole.StartsWith(fromCurr + toCurr)).FirstOrDefault();

                    //If null then go for toFrom pair price
                    if (price == null)
                    {
                        price   = priceObj.Where(p => p.Symbole.StartsWith(toCurr + fromCurr)).FirstOrDefault();
                        inverse = true;
                        return((decimal)price.Ask);
                    }
                    else
                    {
                        inverse = false;
                        return((decimal)price.Bid);
                    }
                }
            }
            catch (Exception ex)
            {
                CommonErrorLogger.CommonErrorLog(ex, System.Reflection.MethodBase.GetCurrentMethod().Name);
                throw;
            }
        }
        public void InsertPrice(List <Price> lstPrice)
        {
            try
            {
                using (var unitOfWork = new EFUnitOfWork())
                {
                    var priceRepo =
                        new PriceRepository(new EFRepository <Price>(), unitOfWork);


                    ObjectSet <Price> priceObj =
                        ((CurrentDeskClientsEntities)priceRepo.Repository.UnitOfWork.Context).Prices;

                    var lstSymbole = lstPrice.Select(s => s.Symbole).ToList();

                    //Get the existing price from DB and update with New DB
                    var lstDBPrice = priceObj.Where(p => lstSymbole.Contains(p.Symbole)).ToList();
                    foreach (var uPrice in lstDBPrice)
                    {
                        var newPrice = lstPrice.Where(s => s.Symbole == uPrice.Symbole.Trim()).FirstOrDefault();
                        if (newPrice != null)
                        {
                            uPrice.Ask = newPrice.Ask;
                            uPrice.Bid = newPrice.Bid;
                        }
                    }

                    //Add new price
                    var lstDBPriceSymbole = lstDBPrice.Select(p => p.Symbole.Trim()).ToList();
                    var newPricesToAdd    = lstPrice.Where(lp => !lstDBPriceSymbole.Contains(lp.Symbole)).Distinct().ToList();
                    foreach (var price in newPricesToAdd)
                    {
                        priceRepo.Add(price);
                    }

                    priceRepo.Save();
                }
            }
            catch (Exception ex)
            {
                CommonErrorLogger.CommonErrorLog(ex, System.Reflection.MethodBase.GetCurrentMethod().Name);
            }
        }