Ejemplo n.º 1
0
 public DaoResponse<Category> Insert(Category entity)
 {
     using (var connection = _dbCommProvider.CreateDbConnection())
     using (var command = _dbCommProvider.CreateDbCommand(connection, SqlQueries.InsertCategory, CreateCategoryParameter(entity)))
     {
         _dbCommProvider.ExecuteNonQuery(command);
     }
     return DaoResponse.QuerySuccessful(entity);
 }
Ejemplo n.º 2
0
 private Dictionary<string, QueryParameter> CreateCategoryParameter(Category entity)
 {
     return new Dictionary<string, QueryParameter>
     {
         {"?CategoryId", new QueryParameter {ParameterValue = entity.CategoryId}},
         {"?Name", new QueryParameter {ParameterValue = entity.Name}},
         {"?Color", new QueryParameter {ParameterValue = entity.Color}}
     };
 }
Ejemplo n.º 3
0
        public void TestInsertCategoryDbAccess()
        {
            var dao = FactoryProvider.GetFactory<IDaoProviderFactory>(
                TestDbDaoAssemblyName,
                TestDbDaoNameSpace,
                TestDbDaoClassName).CreateCategoryDao();
            using (var scope = new TransactionScope())
            {
                var category = new Category
                {
                    CategoryId = "KT",
                    Name = "Klassik Tanz",
                    Color = "#4533b4"
                };
                dao.Insert(category)
                    .OnFailure(response => Assert.Fail($"Insert does not work! {response.Exception}"));

                // do not commit changes; only for testing
                //scope.Complete();
            }
        }
Ejemplo n.º 4
0
 private Category CreateCategoryObject(IDataReader dataReader)
 {
     var category = new Category
     {
         CategoryId = _dbCommProvider.CastDbObject<string>(dataReader, "CategoryId"),
         Name = _dbCommProvider.CastDbObject<string>(dataReader, "Name"),
         Color = _dbCommProvider.CastDbObject<string>(dataReader, "Color")
     };
     return category;
 }
Ejemplo n.º 5
0
 public DaoResponse<Category> Update(Category entity)
 {
     throw new NotImplementedException();
 }