Пример #1
0
        public void BackupData()
        {
            var stores = this._octaneStoreRepository.GetAll();

            foreach (var store in stores)
            {
                var input = new HisStockDto()
                {
                    Amount    = store.Amount,
                    YearMonth = store.CreationTime.ToString("yyyyMM"),
                    Category  = 1,
                    Id        = store.Id
                };
                Add(input);
            }

            var cards = this._oilCardRepository.GetAll();

            foreach (var card in cards)
            {
                var input = new HisStockDto()
                {
                    Amount    = card.Amount,
                    YearMonth = card.CreationTime.ToString("yyyyMM"),
                    Category  = 1,
                    Id        = card.Id
                };
                Add(input);
            }
        }
Пример #2
0
        private void Add(HisStockDto input)
        {
            var item = this._hisOctaneStoreStockRepository.FirstOrDefault(
                r => r.YearMonth == input.YearMonth && r.Category == input.Category);

            if (item == null)
            {
                item = new HisCarStoreStock()
                {
                    YearMonth     = input.YearMonth,
                    Category      = input.Category,
                    OctaneStoreId = input.Id,
                    Amount        = input.Amount
                };
                this._hisOctaneStoreStockRepository.Insert(item);
            }
            else
            {
                item.Amount = input.Amount;
                this._hisOctaneStoreStockRepository.Update(item);
            }
        }