public FilterDefinition <T> GetDefinition <T>()
 {
     if (_category == "$in")
     {
         var value    = _token.Value <JArray>("v");
         var elements = value?.Values <JValue>()?.Select(x => x.Value)?.Where(IsValuable)?.ToList();
         return(TenjinUtils.IsArrayNotEmpty(elements) ? Builders <T> .Filter.In(_name, elements) : default);
예제 #2
0
        public override async Task Add(DocumentImport entity)
        {
            await base.Add(entity);

            if (TenjinUtils.IsArrayNotEmpty(entity.Infos))
            {
                foreach (var info in entity.Infos)
                {
                    var filter = Builders <WarehouseInventory> .Filter.And(
                        Builders <WarehouseInventory> .Filter.Eq(x => x.MaterialCode, info.Code),
                        Builders <WarehouseInventory> .Filter.Eq(x => x.WarehouseCode, entity.WarehouseFromCode),
                        Builders <WarehouseInventory> .Filter.Eq(x => x.UnitCode, info.UnitCode));

                    var updater = Builders <WarehouseInventory> .Update
                                  .Inc(x => x.Inventory, info.Quantity)
                                  .Set(x => x.UnitCode, info.UnitCode)
                                  .Set(x => x.WarehouseCode, entity.WarehouseFromCode)
                                  .Set(x => x.MaterialCode, info.Code)
                                  .Set(x => x.MaterialGroupCode, info.MaterialGroupCode)
                                  .Set(x => x.MaterialSubGroupCode, info.MaterialSubGroupCode)
                                  .Set(x => x.MaterialGroupTypeCode, info.MaterialGroupTypeCode)
                                  .Set(x => x.SerialNumber, info.SerialNumber)
                                  .Set(x => x.IsPublished, true)
                                  .Set(x => x.Specification, info.Specification);

                    await _context.WarehouseInventoryRepository.UpsertOne(filter, updater);
                }
            }
        }
        public override async Task Add(DocumentExport entity)
        {
            entity.IsPublished = true;
            await base.Add(entity);

            if (TenjinUtils.IsArrayNotEmpty(entity.Infos))
            {
                foreach (var info in entity.Infos)
                {
                    var filter = Builders <WarehouseInventory> .Filter.And(
                        Builders <WarehouseInventory> .Filter.Eq(x => x.MaterialCode, info.Code),
                        Builders <WarehouseInventory> .Filter.Eq(x => x.WarehouseCode, entity.WarehouseFromCode),
                        Builders <WarehouseInventory> .Filter.Eq(x => x.UnitCode, info.UnitCode));

                    var updater = Builders <WarehouseInventory> .Update
                                  .Inc(x => x.Inventory, -info.Quantity);

                    await _context.WarehouseInventoryRepository.UpsertOne(filter, updater);
                }
            }
        }