コード例 #1
0
 public bool Add(AddStorageConfigurationDTO dto)
 {
     Collection.InsertOne(new ConfigurationDocument
     {
         Type            = dto.Type,
         Value           = dto.Value,
         Name            = dto.Name,
         IsActive        = dto.IsActive,
         CreationDate    = DateTime.Now,
         LastModifyDate  = DateTime.Now,
         ApplicationName = dto.ApplicationName
     });
     return(true);
 }
コード例 #2
0
        public bool Add(AddStorageConfigurationDTO dto)
        {
            using (var context = new ConfigurationContext(GetConfigurationContextOptions()))
            {
                context.Configurations.Add(new Configuration
                {
                    Type            = dto.Type,
                    Value           = dto.Value,
                    Name            = dto.Name,
                    IsActive        = dto.IsActive,
                    CreationDate    = DateTime.Now,
                    LastModifyDate  = DateTime.Now,
                    ApplicationName = dto.ApplicationName
                });

                context.SaveChanges();
                return(true);
            }
        }
コード例 #3
0
        public async Task <bool> AddAsync(AddStorageConfigurationDTO dto)
        {
            using (var dbConnection = Connection)
            {
                var query = "INSERT INTO \"Configuration\" (\"Name\", \"Type\", \"Value\",\"IsActive\",\"ApplicationName\",\"CreationDate\", \"LastModifyDate\")"
                            + " VALUES(@Name, @Type, @Value,@IsActive, @ApplicationName,@CreationDate, @LastModifyDate )";
                dbConnection.Open();
                var res = await dbConnection.ExecuteAsync(query, new
                {
                    Value           = dto.Value,
                    Name            = dto.Name,
                    ApplicationName = dto.ApplicationName,
                    IsActive        = dto.IsActive,
                    Type            = dto.Type,
                    CreationDate    = DateTime.Now,
                    LastModifyDate  = DateTime.Now
                });

                return(res > 0);
            }
        }