Exemplo n.º 1
0
        public List <Organization> Execute(StorageServiceBase storageService)
        {
            string sql = "select * from Organization where Name like @name";

            storageService.ConnectionFactory.OpenConnection();
            storageService.ConnectionFactory.CreateCommand(sql);
            storageService.ConnectionFactory.AddParameter("@name", $"%{name}%");
            var dr = storageService.ConnectionFactory.ExecuteReader();

            List <Organization> result = new List <Organization>();

            while (dr.Read())
            {
                result.Add(new Organization(
                               id: dr.GetString(0),
                               name: dr.GetString(1),
                               phone: dr.GetString(2),
                               address: dr.GetString(3)));
            }

            dr.Close();
            storageService.ConnectionFactory.CloseConnection();

            return(result);
        }
Exemplo n.º 2
0
        public Organization Execute(StorageServiceBase storageService)
        {
            string sql = "select * from Organization where Id = @id";

            storageService.ConnectionFactory.OpenConnection();
            storageService.ConnectionFactory.CreateCommand(sql);
            storageService.ConnectionFactory.AddParameter("@id", organizationId);
            var dr = storageService.ConnectionFactory.ExecuteReader();

            Organization result = null;

            if (dr.Read())
            {
                result = new Organization(
                    id: dr.GetString(0),
                    name: dr.GetString(1),
                    phone: dr.GetString(2),
                    address: dr.GetString(3));
            }

            dr.Close();
            storageService.ConnectionFactory.CloseConnection();

            return(result);
        }
Exemplo n.º 3
0
        public void Execute(StorageServiceBase storageService)
        {
            string sql = "delete from Organization where Id = @id";

            storageService.ConnectionFactory.OpenConnection();
            storageService.ConnectionFactory.CreateCommand(sql);
            storageService.ConnectionFactory.AddParameter("@id", organization.Id);
            storageService.ConnectionFactory.ExecuteCommand();
            storageService.ConnectionFactory.CloseConnection();
        }
Exemplo n.º 4
0
        public void Execute(StorageServiceBase storageService)
        {
            string sql = @"insert into Organization 
(Id, Name, Phone, Address) 
values 
(@id, @name, @phone, @address)";

            storageService.ConnectionFactory.OpenConnection();
            storageService.ConnectionFactory.CreateCommand(sql);
            storageService.ConnectionFactory.AddParameter("@id", organization.Id);
            storageService.ConnectionFactory.AddParameter("@name", organization.Name);
            storageService.ConnectionFactory.AddParameter("@phone", organization.Phone);
            storageService.ConnectionFactory.AddParameter("@address", organization.Address);
            storageService.ConnectionFactory.ExecuteCommand();
            storageService.ConnectionFactory.CloseConnection();
        }
Exemplo n.º 5
0
        public void Execute(StorageServiceBase storageService)
        {
            string sql = @"update Organization set 
Name = @name,
Phone = @phone,
Address = @address
where Id = @id
";

            storageService.ConnectionFactory.OpenConnection();
            storageService.ConnectionFactory.CreateCommand(sql);
            storageService.ConnectionFactory.AddParameter("@id", organization.Id);
            storageService.ConnectionFactory.AddParameter("@name", organization.Name);
            storageService.ConnectionFactory.AddParameter("@phone", organization.Phone);
            storageService.ConnectionFactory.AddParameter("@address", organization.Address);
            storageService.ConnectionFactory.ExecuteCommand();
            storageService.ConnectionFactory.CloseConnection();
        }