Beispiel #1
0
 public DaoResponse<Country> Delete(Country entity)
 {
     using (var connection = _dbCommProvider.CreateDbConnection())
     using (var command = _dbCommProvider.CreateDbCommand(connection, SqlQueries.DeleteCountry, CreateCountryParameter(entity)))
     {
         _dbCommProvider.ExecuteNonQuery(command);
     }
     return DaoResponse.QuerySuccessful(entity);
 }
Beispiel #2
0
        public void TestInsertCountryDbAccess()
        {
            var dao = FactoryProvider.GetFactory<IDaoProviderFactory>(
                TestDbDaoAssemblyName,
                TestDbDaoNameSpace,
                TestDbDaoClassName).CreateCountryDao();
            using (var scope = new TransactionScope())
            {
                var country = new Country
                {
                    Code="PD",
                    Name ="Pandora"
                };
                dao.Insert(country)
                    .OnFailure(response => Assert.Fail($"Insert does not work! {response.Exception}"));

                // do not commit changes; only for testing
                //scope.Complete();
            }
        }
Beispiel #3
0
        public void TestDeleteCountryDbAccess()
        {
            var dao = FactoryProvider.GetFactory<IDaoProviderFactory>(
                TestDbDaoAssemblyName,
                TestDbDaoNameSpace,
                TestDbDaoClassName).CreateCountryDao();

            using (var scope = new TransactionScope())
            {
                var country = new Country
                {
                    Code = "PD",
                    Name = "Pandora"
                };
                dao.Insert(country)
                    .OnFailure(response => Assert.Fail($"Insert does not work! {response.Exception}"));

                var getRsp = dao.SelectByCode("PD");
                getRsp
                    .OnEmptyResult(() => Assert.Fail("No data found"))
                    .OnFailure(response => Assert.Fail($"Unexpected exception occurred: {response.Exception}"));
                country = getRsp.ResultObject;

                dao.Delete(country)
                    .OnFailure(response => Assert.Fail($"Delete does not work! {response.Exception}"));

                // do not commit changes; only for testing
                //scope.Complete();
            }
        }
Beispiel #4
0
 public DaoResponse<Country> Update(Country entity)
 {
     throw new NotImplementedException();
 }
Beispiel #5
0
 private Dictionary<string, QueryParameter> CreateCountryParameter(Country entity)
 {
     return new Dictionary<string, QueryParameter>
     {
         {"?Code", new QueryParameter {ParameterValue = entity.Code}},
         {"?Name", new QueryParameter {ParameterValue = entity.Name}}
     };
 }
Beispiel #6
0
 private Country CreateCountryObject(IDataReader dataReader)
 {
     var country = new Country
     {
         Code = _dbCommProvider.CastDbObject<string>(dataReader, "Code"),
         Name = _dbCommProvider.CastDbObject<string>(dataReader, "Name")
     };
     return country;
 }