public async Task <int> CreateScanRequest(ScanRequest scanRequest)
        {
            var entity = ScanRequestEntity.MapFrom(scanRequest);

            _dbContext.ScanRequests.Add(entity);
            await _dbContext.SaveChangesAsync();

            return(entity.Id);
        }
Example #2
0
        public async Task <Property> CreatePropertyAsync(Property property)
        {
            var entity = PropertyEntity.MapFrom(property);

            _dbContext.Properties.Add(entity);
            await _dbContext.SaveChangesAsync();

            return(PropertyEntity.MapTo(entity));
        }
Example #3
0
        public async Task CreateSiteConfiguration(SiteConfiguration siteConfiguration)
        {
            if (_dbContext.SiteConfigurations.Any(sc => sc.SiteId == siteConfiguration.SiteId))
            {
                throw new BadRequestException("SiteConfiguration already exists");
            }

            siteConfiguration.Password = Encode(siteConfiguration.Password);
            _dbContext.SiteConfigurations.Add(SiteConfigurationEntity.MapFrom(siteConfiguration));
            await _dbContext.SaveChangesAsync();
        }
        private async Task AddProperties(SiemensDbContext context, Guid id, string properties, string functionProperties)
        {
            var entry = context.SystemObjects.Find(id);

            entry.Attributes           = properties;
            entry.FunctionProperties   = functionProperties;
            context.Entry(entry).State = EntityState.Modified;
            await context.SaveChangesAsync();
        }
        private async Task Create(SiemensDbContext context, SystemObjectEntity SystemObject)
        {
            var existing = context.SystemObjects.FirstOrDefault(x => x.SiteId == SystemObject.SiteId && x.ObjectId == SystemObject.ObjectId && x.Name == SystemObject.Name && x.Designation == SystemObject.Designation);

            if (existing != null)
            {
                SystemObject.Id = existing.Id;
                context.Entry(SystemObject).State = EntityState.Modified;
            }
            else
            {
                context.SystemObjects.Add(SystemObject);
            }
            await context.SaveChangesAsync();
        }