Пример #1
0
 public UploadedDataService(InventoryPnDbContext dbContext,
                            IUserService userService,
                            IEFormCoreService coreService)
 {
     _dbContext   = dbContext;
     _userService = userService;
     _coreService = coreService;
 }
        private void GetContext(string connectionStr)
        {
            var contextFactory = new InventoryPnContextFactory();

            DbContext = contextFactory.CreateDbContext(new[] { connectionStr });

            DbContext.Database.Migrate();
            DbContext.Database.EnsureCreated();
        }
        //private readonly IEFormCoreService _coreService;

        public InventoryItemTypeService(InventoryPnDbContext dbContext,
                                        IInventoryLocalizationService inventoryLocalizationService,
                                        IUserService userService /*,
                                                                  * IEFormCoreService coreService*/)
        {
            _userService = userService;
            _inventoryLocalizationService = inventoryLocalizationService;
            //_coreService = coreService;
            _dbContext = dbContext;
        }
Пример #4
0
 public InventoryTagsService(
     IInventoryLocalizationService inventoryLocalizationService,
     ILogger <InventoryTagsService> logger,
     InventoryPnDbContext dbContext,
     IUserService userService)
 {
     _inventoryLocalizationService = inventoryLocalizationService;
     _logger      = logger;
     _dbContext   = dbContext;
     _userService = userService;
 }
Пример #5
0
 public InventoryItemService(
     InventoryPnDbContext dbContext,
     IInventoryLocalizationService inventoryLocalizationService,
     IUserService userService,
     IEFormCoreService coreService,
     IPluginDbOptions <InventoryBaseSettings> options)
 {
     _userService = userService;
     _inventoryLocalizationService = inventoryLocalizationService;
     _coreService = coreService;
     _dbContext   = dbContext;
     _options     = options;
 }
Пример #6
0
        //private readonly IBus _bus;


        public InventoryPnSettingsService(ILogger <InventoryPnSettingsService> logger,
                                          IInventoryLocalizationService inventoryLocalizationService,
                                          InventoryPnDbContext dbContext,
                                          IPluginDbOptions <InventoryBaseSettings> options,
                                          IUserService userService,
                                          IEFormCoreService coreService /*,
                                                                         * IRebusService rebusService*/)
        {
            _logger      = logger;
            _dbContext   = dbContext;
            _options     = options;
            _userService = userService;
            _inventoryLocalizationService = inventoryLocalizationService;
            _coreService = coreService;
            //_bus = rebusService.GetBus();
        }
Пример #7
0
        public async Task Create(InventoryPnDbContext dbContext)
        {
            CreatedAt     = DateTime.UtcNow;
            UpdatedAt     = DateTime.UtcNow;
            Version       = 1;
            WorkflowState = Constants.WorkflowStates.Created;

            await dbContext.AddAsync(this);

            await dbContext.SaveChangesAsync();

            var res = MapVersion(this);

            if (res != null)
            {
                await dbContext.AddAsync(res);

                await dbContext.SaveChangesAsync();
            }
        }
Пример #8
0
        public static void SeedData(InventoryPnDbContext dbContext)
        {
            var seedData          = new InventoryConfigurationSeedData();
            var configurationList = seedData.Data;

            foreach (var configurationItem in configurationList)
            {
                if (!dbContext.PluginConfigurationValues.Any(x => x.Name == configurationItem.Name))
                {
                    var newConfigValue = new PluginConfigurationValue()
                    {
                        Name            = configurationItem.Name,
                        Value           = configurationItem.Value,
                        CreatedAt       = DateTime.UtcNow,
                        UpdatedAt       = DateTime.UtcNow,
                        Version         = 1,
                        WorkflowState   = Constants.WorkflowStates.Created,
                        CreatedByUserId = 1
                    };
                    dbContext.PluginConfigurationValues.Add(newConfigValue);
                    dbContext.SaveChanges();
                }
            }

            // Seed plugin permissions
            var newPermissions = InventoryPermissionsSeedData.Data
                                 .Where(p => dbContext.PluginPermissions.All(x => x.ClaimName != p.ClaimName))
                                 .Select(p => new PluginPermission
            {
                PermissionName  = p.PermissionName,
                ClaimName       = p.ClaimName,
                CreatedAt       = DateTime.UtcNow,
                Version         = 1,
                WorkflowState   = Constants.WorkflowStates.Created,
                CreatedByUserId = 1
            });

            dbContext.PluginPermissions.AddRange(newPermissions);

            dbContext.SaveChanges();
        }
Пример #9
0
        private async Task UpdateInternal(InventoryPnDbContext dbContext, string state = null)
        {
            if (state != null)
            {
                WorkflowState = state;
            }

            if (dbContext.ChangeTracker.HasChanges())
            {
                Version  += 1;
                UpdatedAt = DateTime.UtcNow;

                await dbContext.SaveChangesAsync();

                var res = MapVersion(this);
                if (res != null)
                {
                    await dbContext.AddAsync(res);

                    await dbContext.SaveChangesAsync();
                }
            }
        }
Пример #10
0
 public async Task Delete(InventoryPnDbContext dbContext)
 {
     await UpdateInternal(dbContext, Constants.WorkflowStates.Removed);
 }
Пример #11
0
 public async Task Update(InventoryPnDbContext dbContext)
 {
     await UpdateInternal(dbContext);
 }