Пример #1
0
        public int CreateStock(Stocks stock)
        {
            int _newStockid = 0;

            try
            {
                ReadStock           createdData   = new ReadStock();
                ESGetDetail         createdESData = new ESGetDetail();
                ElasticSearchClient createES      = new ElasticSearchClient();
                createdData = _dataAccessLayer.CreateDbStock(stock);
                string cacheKey = CreateKey(createdData.ID);
                using (MemcachedClient client = new MemcachedClient("memcached"))
                {
                    client.Store(StoreMode.Add, cacheKey, createdData, DateTime.Now.AddMinutes(15));
                }
                createdESData = ConvertCachetoESData(createdData);
                //getCreatedData = Mapper.Map<ReadStock, ESGetDetail>(getCreatedData);
                createES.CreateESStock(createdESData);
                _newStockid = createdESData.ID;
            }
            catch (Exception)
            {
                throw;
            }
            return(_newStockid);
        }