public byte[] UpdateItem(Guid guid, ISyncDataObject mergedData, int companyId, string storeId)
        {
            var temp = mergedData as Package;

            using (var db = SyncDbContextFactory.Factory <LocalCeDbContext>())
            {
                var _promotions                   = temp.GetEntities <CommodityPromotion>();
                var _promotionsSyncIds            = _promotions.Select(o => o.SyncItemId).ToList();
                var commodityBundlings            = temp.GetEntities <Bundling>();
                var commodityBundlingsSyncIds     = commodityBundlings.Select(o => o.SyncItemId).ToList();
                var commodityBundlingLists        = temp.GetEntities <BundlingList>();
                var commodityBundlingListsSyncIds = commodityBundlingLists.Select(o => o.SyncItemId).ToList();

                db.CommodityPromotions.Where(o => _promotionsSyncIds.Contains(o.SyncItemId)).ToList().ForEach(o => o.InitEntity(_promotions.FirstOrDefault(p => o.SyncItemId == p.SyncItemId)));
                db.Bundlings.Where(o => commodityBundlingsSyncIds.Contains(o.SyncItemId)).ToList().ForEach(o => o.InitEntity(commodityBundlings.FirstOrDefault(p => o.SyncItemId == p.SyncItemId)));
                db.BundlingLists.Where(o => commodityBundlingListsSyncIds.Contains(o.SyncItemId)).ToList().ForEach(o => o.InitEntity(commodityBundlingLists.FirstOrDefault(p => o.SyncItemId == p.SyncItemId)));
                db.SaveChanges();

                StoreManager.PubEvent("MarketingRefresh", new { StoreId = storeId, CompanyId = companyId });
                try
                {
                    var bunding = commodityBundlings.FirstOrDefault();
                    if (bunding != null)
                    {
                        var qRefresh = new List <Pharos.ObjectModels.DTOs.MemoryCacheRefreshQuery>();
                        var item     = new ObjectModels.DTOs.MemoryCacheRefreshQuery()
                        {
                            CompanyId = companyId, StoreId = storeId, Barcode = bunding.NewBarcode, ProductType = ObjectModels.ProductType.Bundling, ProductCode = ""
                        };
                        qRefresh.Add(item);
                        Pharos.Logic.ApiData.Pos.Cache.ProductCache.RefreshProduct(qRefresh);
                    }
                }
                catch { }

                var version = GetVersion(guid, companyId, storeId, db);
                return(version.SyncItemVersion);
            }
        }
        public byte[] UpdateItem(Guid guid, ISyncDataObject mergedData, int companyId, string storeId)
        {
            var temp = mergedData as Pharos.SyncService.SyncEntities.ProductRecord;

            using (var db = SyncDbContextFactory.Factory <LocalCeDbContext>())
            {
                var dbEntity = db.ProductRecords.FirstOrDefault(o => o.SyncItemId == guid && o.CompanyId == companyId);
                dbEntity.InitEntity(temp);
                db.SaveChanges();
                try
                {
                    var qRefresh = new List <Pharos.ObjectModels.DTOs.MemoryCacheRefreshQuery>();
                    var item     = new ObjectModels.DTOs.MemoryCacheRefreshQuery()
                    {
                        CompanyId = companyId, StoreId = storeId, Barcode = temp.Barcode, ProductCode = temp.ProductCode
                    };
                    switch (temp.Nature)
                    {
                    case 0:
                        item.ProductType = ObjectModels.ProductType.Normal;
                        break;

                    case 1:
                        item.ProductType = ObjectModels.ProductType.Combination;
                        break;

                    case 2:
                        item.ProductType = ObjectModels.ProductType.Split;
                        break;
                    }
                    qRefresh.Add(item);
                    Pharos.Logic.ApiData.Pos.Cache.ProductCache.RefreshProduct(qRefresh);
                }
                catch { }
                return(temp.SyncItemVersion);
            }
        }